From 865728068c965e066d0f8971c5b5ba26e12e7dce Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Thu, 24 Dec 2020 00:06:27 +0530 Subject: Adds scripts and links scripts and wallpapers --- scripts/music/player.sh | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 scripts/music/player.sh (limited to 'scripts/music/player.sh') 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 + -- cgit v1.3.1