aboutsummaryrefslogtreecommitdiff
path: root/scripts/music/player.sh
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2020-12-24 00:06:27 +0530
committerAkshay Nair <phenax5@gmail.com>2020-12-24 00:06:27 +0530
commit865728068c965e066d0f8971c5b5ba26e12e7dce (patch)
treec16195f0a04cf7d004fe5b396255734f4d60bb00 /scripts/music/player.sh
parent649ef5f225039e498358c3d056dfd7fcbc56f014 (diff)
downloadnixos-config-865728068c965e066d0f8971c5b5ba26e12e7dce.tar.gz
nixos-config-865728068c965e066d0f8971c5b5ba26e12e7dce.zip
Adds scripts and links scripts and wallpapers
Diffstat (limited to 'scripts/music/player.sh')
-rwxr-xr-xscripts/music/player.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/scripts/music/player.sh b/scripts/music/player.sh
new file mode 100755
index 0000000..76f4988
--- /dev/null
+++ b/scripts/music/player.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+player() { playerctl --player=mopidy "$@"; }
+
+# Get player state
+#get_play_state() { player metadata --format '{{status}}' || echo 'Stopped'; }
+get_play_state() {
+ local state=$(mpc status | awk '/\[\w*\]/ {print $1}');
+ case "$state" in
+ '[playing]') echo "Playing" ;;
+ '[paused]') echo "Paused" ;;
+ *) echo "Stopped" ;;
+ esac;
+}
+
+# Get title - artist (song label)
+#get_label() { player metadata --format '{{title}} - {{artist}}' || echo '...'; }
+get_label() {
+ echo -n "$(mpc current | cut -c1-20)";
+ echo "...";
+}
+
+# Play/Pause toggle:
+play_pause() {
+ #player play-pause;
+ mpc toggle;
+ update-dwmblock music;
+}
+
+# Next/Prev
+next() {
+ #player next;
+ mpc next;
+ update-dwmblock music;
+}
+prev() {
+ #player previous;
+ mpc prev;
+ update-dwmblock music;
+}
+
+notify() {
+ update-dwmblock music;
+}
+
+case "$1" in
+ play_pause|pp) play_pause ;;
+ next|n) next ;;
+ prev|p) prev ;;
+ dump_metadata) get_metadata ;;
+ get_label) get_label ;;
+ get_play_state) get_play_state ;;
+ notify) notify ;;
+ *) echo "Learn how to use shit before you use them" ;;
+esac
+