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-softwarecounter/)
|
||||||
[](polybar-scripts/info-twitch-countdown/)
|
[](polybar-scripts/info-twitch-countdown/)
|
||||||
[](polybar-scripts/info-twitch-countdown/)
|
[](polybar-scripts/info-twitch-countdown/)
|
||||||
|
[](polybar-scripts/player-cmus/)
|
||||||
[](polybar-scripts/info-todotxt/)
|
[](polybar-scripts/info-todotxt/)
|
||||||
[](polybar-scripts/info-wifionice/)
|
[](polybar-scripts/info-wifionice/)
|
||||||
|
|
||||||
|
@ -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).
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@ -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
35
polybar-scripts/player-cmus/player-cmus.sh
Normal file → Executable 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 |
Loading…
x
Reference in New Issue
Block a user