player-cmus: add more features
This commit is contained in:
parent
f8a5b857fa
commit
af9e02acb2
@ -54,6 +54,7 @@ Is this your first time here? You should definitely take a look at these scripts
|
||||
[](polybar-scripts/info-softwarecounter/)
|
||||
[](polybar-scripts/info-twitch-countdown/)
|
||||
[](polybar-scripts/info-twitch-countdown/)
|
||||
[](polybar-scripts/player-cmus/)
|
||||
[](polybar-scripts/info-todotxt/)
|
||||
[](polybar-scripts/info-wifionice/)
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Script: player-cmus
|
||||
|
||||
A small script that shows the current song.
|
||||
A script that displays information about the current track (artist, title, position, duration).
|
||||
|
||||

|
||||
|
||||
@ -15,5 +15,5 @@ exec-if = cmus-remote -Q
|
||||
interval = 5
|
||||
click-left = cmus-remote -n
|
||||
click-right = cmus-remote -r
|
||||
click-middle = ~/polybar-scripts/player-cmus.sh --toggle
|
||||
click-middle = cmus-remote -u
|
||||
```
|
||||
|
33
polybar-scripts/player-cmus/player-cmus.sh
Normal file → Executable file
33
polybar-scripts/player-cmus/player-cmus.sh
Normal file → Executable file
@ -1,16 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
case "$1" in
|
||||
--toggle)
|
||||
if cmus-remote -Q | grep -q 'status playing'; then
|
||||
cmus-remote -u
|
||||
else
|
||||
cmus-remote -p
|
||||
status=$(cmus-remote -Q | grep status | awk -F\ '{print $2}')
|
||||
title=$(cmus-remote -Q | grep title | awk -F\ '{$1=$2=""; print $0}' | sed 's|^[[:blank:]]*||g')
|
||||
artist=$(cmus-remote -Q | grep '[[:space:]]artist' | awk -F\ '{$1=$2=""; print $0}' | sed 's|^[[:blank:]]*||g')
|
||||
position=$(cmus-remote -Q | grep position | awk -F\ '{print $2}')
|
||||
duration=$(cmus-remote -Q | grep duration | awk -F\ '{print $2}')
|
||||
|
||||
pos_minutes=$(("$position" / 60))
|
||||
pos_minutes=$(printf "%02d" "$pos_minutes")
|
||||
pos_seconds=$(("$position" % 60))
|
||||
pos_seconds=$(printf "%02d" "$pos_seconds")
|
||||
|
||||
dur_minutes=$(("$duration" / 60))
|
||||
dur_minutes=$(printf "%02d" "$dur_minutes")
|
||||
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
|
||||
;;
|
||||
*)
|
||||
if cmus-remote -Q | grep -q 'status playing'; then
|
||||
cmus-remote -Q | grep 'file' | awk -F/ '{print $NF}'
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 414 B After Width: | Height: | Size: 4.4 KiB |
Loading…
x
Reference in New Issue
Block a user