From 85ae438fbc238fe56bcb1c10a12ec52365053cb6 Mon Sep 17 00:00:00 2001 From: Biswakalyan Bhuyan Date: Sat, 26 Feb 2022 20:31:12 +0530 Subject: dwmbar dotfiles --- modules/mpd | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 modules/mpd (limited to 'modules/mpd') diff --git a/modules/mpd b/modules/mpd new file mode 100755 index 0000000..ecbdd4e --- /dev/null +++ b/modules/mpd @@ -0,0 +1,25 @@ +#!/bin/bash + +PREFIX_PLAY=' ' +PREFIX_PAUSE=' ' + +get_mpd() +{ + current_song="$(mpc current)" + + if [[ "$current_song" = "" ]]; then + echo " " + exit 0 + else + playpause=$(mpc | awk '/\[.*]/{split($0, a, " "); print a[1]}') + if [[ "$playpause" = "[playing]" ]]; then + current_song="$PREFIX_PLAY $current_song" + elif [[ "$playpause" = "[paused]" ]]; then + current_song="$PREFIX_PAUSE $current_song" + fi + fi + + echo "$current_song" +} + +get_mpd -- cgit v1.2.3-59-g8ed1b