Add music to status bar

Signed-off-by: Severin Kaderli <severin.kaderli@gmail.com>
This commit is contained in:
Severin Kaderli 2018-12-25 17:25:23 +01:00
parent 474a3d4f30
commit ef20a492de
Signed by: severinkaderli
GPG key ID: F419F8835B72F0C4
5 changed files with 69 additions and 4 deletions

37
system/bin/music.sh Executable file
View file

@ -0,0 +1,37 @@
#!/bin/bash
#
# SCRIPT NAME:
# music.sh
#
# AUTHOR:
# Severin Kaderli <severin.kaderli@gmail.com>
#
# DESCRIPTION:
# Prints out the title of the current playing song using cmus-remote.
#
# USAGE:
# ./music.sh
QUERY="$(cmus-remote -Q)"
STATUS="$(echo "$QUERY" | grep -e "status " | cut -d " " -f 2)"
ARTIST="$(echo "$QUERY" | grep -e " artist " | cut -d " " -f 3-)"
ALBUM="$(echo "$QUERY" | grep -e " album " | cut -d " " -f 3-)"
TITLE="$(echo "$QUERY" | grep -e " title " | cut -d " " -f 3-)"
position="$(echo "$QUERY" | grep -e "position " | cut -d " " -f 2)"
duration="$(echo "$QUERY" | grep -e "duration " | cut -d " " -f 2)"
pos_minutes=$(printf "%02d" $(("$position" / 60)))
pos_seconds=$(printf "%02d" $(("$position" % 60)))
dur_minutes=$(printf "%02d" $(("$duration" / 60)))
dur_seconds=$(printf "%02d" $(("$duration" % 60)))
OUTPUT="$ARTIST | $ALBUM | $TITLE | $pos_minutes:$pos_seconds / $dur_minutes:$dur_seconds"
if [ "$STATUS" != "playing" ]; then
OUTPUT="Not playing"
fi
echo "$OUTPUT"