-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdjmixes
executable file
·33 lines (26 loc) · 1.04 KB
/
djmixes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
# TODO: Loop current playing track
# All djmixes
FILENAME="$HOME/DjMixes"
# TODO: Check if an argument e.g. --artist alicia is provided; if so, only play songs by that artist
if [ "$#" -gt 0 ]; then
echo "TODO: Check if an argument e.g. Goggins is provided; if so, use it as the filename"
fi
# File to store the PID of the running cvlc process
PID_FILE="/tmp/cvlc.pid"
# Check if the PID file exists and kill the process if it does
if [ -f "$PID_FILE" ]; then
if ps -p $(cat "$PID_FILE") > /dev/null; then
echo "Shuffling..."
kill $(cat "$PID_FILE")
fi
rm "$PID_FILE"
fi
# Run cvlc to shuffle and play the playlist
# nohup allows the command to run in the background even if the terminal is closed
# --no-video disables video playback
# --random shuffles the playlist
# --rate=1.99999 adjusts playback speed slightly (you can adjust this or remove it if not needed)
nohup cvlc --no-video --random --rate=1.99999 "$FILENAME" > /tmp/nohup.djmixes.out 2>&1 &
# Save the PID of the new cvlc process
echo $! > "$PID_FILE"