blob: 8a7548bea030daff27d7e0db7ee8c4f5100562c4 (
plain) (
blame)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#!/bin/sh
# https://sinanmohd.com
####################
## user variables ##
####################
# dir where audio files are stored
amb_dir="$HOME/.local/share/damb"
# pid file location
pid_file="/tmp/damb.pid"
# dir where config files are stored
config_dir="$HOME/.config/damb"
get_opt()
{
printf "select\nlinks\nrandom\nstream\nstop" | dmenu -p "הּ "
}
get_ambs()
{
find "$amb_dir" -type f -exec basename {} \;
}
send_err()
{
printf "error: %s\n" "$1"
notify-send " damb" "error, $1"
}
get_link()
{
grep -v "^#.*$" "$config_dir"/links |
grep "$(grep -v "^#.*$" "$config_dir"/links | cut -d '=' -f1 | dmenu -p " " -l 25)" |
cut -d '=' -f2 | tr -d ' '
}
case "$(get_opt)" in
select) ffplay -volume 20 -nodisp -loop 0 "$amb_dir/$(get_ambs | dmenu -p " " -l 25)" &
echo "$!" >> "$pid_file"
;;
links) mpv --no-video --no-resume-playback "$(get_link)" &
echo "$!" >> "$pid_file"
;;
random) ffplay -volume 20 -nodisp -loop 0 "$amb_dir/$(get_ambs | shuf -n1)" &
echo "$!" >> "$pid_file"
;;
stop) while IFS= read -r process
do
kill -2 "$process"
done < "$pid_file"
rm "$pid_file"
;;
stream) mpv --no-video "$(xclip -o -sel clip)" &
echo "$!" >> "$pid_file"
;;
"") ;; # stay quiet when user quits the program during selection
*) send_err "option not implemented";;
esac
|