aboutsummaryrefslogtreecommitdiff
path: root/damb
diff options
context:
space:
mode:
authorsinanmohd <pcmsinan@gmail.com>2022-12-05 18:30:35 +0530
committersinanmohd <pcmsinan@gmail.com>2023-03-11 19:05:02 +0530
commit6e99499c1f13008581f9070206b71c0a51cdb28e (patch)
tree9b1be1ac30912793b1d233059f6f4ef9d1a5d1ef /damb
initial commit
Diffstat (limited to 'damb')
-rwxr-xr-xdamb60
1 files changed, 60 insertions, 0 deletions
diff --git a/damb b/damb
new file mode 100755
index 0000000..8a7548b
--- /dev/null
+++ b/damb
@@ -0,0 +1,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