player-cmus: add more features

This commit is contained in:
alexshoo 2018-11-22 12:46:40 +03:00 committed by x70b1
parent f8a5b857fa
commit af9e02acb2
4 changed files with 24 additions and 16 deletions

View File

@ -54,6 +54,7 @@ Is this your first time here? You should definitely take a look at these scripts
[![pulseaudio-rofi](polybar-scripts/info-softwarecounter/screenshots/1.png)](polybar-scripts/info-softwarecounter/) [![pulseaudio-rofi](polybar-scripts/info-softwarecounter/screenshots/1.png)](polybar-scripts/info-softwarecounter/)
[![info-twitch-countdown](polybar-scripts/info-twitch-countdown/screenshots/1.png)](polybar-scripts/info-twitch-countdown/) [![info-twitch-countdown](polybar-scripts/info-twitch-countdown/screenshots/1.png)](polybar-scripts/info-twitch-countdown/)
[![info-twitch-countdown](polybar-scripts/info-twitch-countdown/screenshots/2.png)](polybar-scripts/info-twitch-countdown/) [![info-twitch-countdown](polybar-scripts/info-twitch-countdown/screenshots/2.png)](polybar-scripts/info-twitch-countdown/)
[![player-cmus](polybar-scripts/player-cmus/screenshots/1.png)](polybar-scripts/player-cmus/)
[![info-todotxt](polybar-scripts/info-todotxt/screenshots/1.png)](polybar-scripts/info-todotxt/) [![info-todotxt](polybar-scripts/info-todotxt/screenshots/1.png)](polybar-scripts/info-todotxt/)
[![info-wifionice](polybar-scripts/info-wifionice/screenshots/1.png)](polybar-scripts/info-wifionice/) [![info-wifionice](polybar-scripts/info-wifionice/screenshots/1.png)](polybar-scripts/info-wifionice/)

View File

@ -1,6 +1,6 @@
# Script: player-cmus # Script: player-cmus
A small script that shows the current song. A script that displays information about the current track (artist, title, position, duration).
![player-cmus](screenshots/1.png) ![player-cmus](screenshots/1.png)
@ -15,5 +15,5 @@ exec-if = cmus-remote -Q
interval = 5 interval = 5
click-left = cmus-remote -n click-left = cmus-remote -n
click-right = cmus-remote -r click-right = cmus-remote -r
click-middle = ~/polybar-scripts/player-cmus.sh --toggle click-middle = cmus-remote -u
``` ```

35
polybar-scripts/player-cmus/player-cmus.sh Normal file → Executable file
View File

@ -1,16 +1,23 @@
#!/bin/sh #!/bin/sh
case "$1" in status=$(cmus-remote -Q | grep status | awk -F\ '{print $2}')
--toggle) title=$(cmus-remote -Q | grep title | awk -F\ '{$1=$2=""; print $0}' | sed 's|^[[:blank:]]*||g')
if cmus-remote -Q | grep -q 'status playing'; then artist=$(cmus-remote -Q | grep '[[:space:]]artist' | awk -F\ '{$1=$2=""; print $0}' | sed 's|^[[:blank:]]*||g')
cmus-remote -u position=$(cmus-remote -Q | grep position | awk -F\ '{print $2}')
else duration=$(cmus-remote -Q | grep duration | awk -F\ '{print $2}')
cmus-remote -p
fi pos_minutes=$(("$position" / 60))
;; pos_minutes=$(printf "%02d" "$pos_minutes")
*) pos_seconds=$(("$position" % 60))
if cmus-remote -Q | grep -q 'status playing'; then pos_seconds=$(printf "%02d" "$pos_seconds")
cmus-remote -Q | grep 'file' | awk -F/ '{print $NF}'
fi dur_minutes=$(("$duration" / 60))
;; dur_minutes=$(printf "%02d" "$dur_minutes")
esac dur_seconds=$(("$duration" % 60))
dur_seconds=$(printf "%02d" "$dur_seconds")
if [ "$status" = "stopped" ];then
echo "$status"
elif [ "$status" = "playing" ] || [ "$status" = "paused" ];then
echo "$status" \| "$artist" - "$title" \| "$pos_minutes":"$pos_seconds" / "$dur_minutes":"$dur_seconds"
fi

Binary file not shown.

Before

Width:  |  Height:  |  Size: 414 B

After

Width:  |  Height:  |  Size: 4.4 KiB