Add music to status bar
Signed-off-by: Severin Kaderli <severin.kaderli@gmail.com>
This commit is contained in:
parent
474a3d4f30
commit
ef20a492de
5 changed files with 69 additions and 4 deletions
|
@ -186,6 +186,7 @@ bindsym XF86MonBrightnessUp exec --no-startup-id light -A 5
|
|||
bindsym XF86MonBrightnessDown exec --no-startup-id light -U 5
|
||||
|
||||
# Music controls
|
||||
bindsym XF86AudioStop exec --no-startup-id cmus-remote -s
|
||||
bindsym XF86AudioPlay exec --no-startup-id cmus-remote -u
|
||||
bindsym $mod+KP_Enter exec --no-startup-id cmus-remote -u
|
||||
bindsym XF86AudioNext exec --no-startup-id cmus-remote -n
|
||||
|
@ -220,8 +221,7 @@ exec discord
|
|||
exec nemo
|
||||
exec nemo
|
||||
exec keepassxc
|
||||
|
||||
#exec termite -e cmus --name cmus
|
||||
exec termite -e cmus --name cmus
|
||||
|
||||
# Assign programs to specific workspaces
|
||||
###
|
||||
|
|
|
@ -47,6 +47,17 @@ tray-position = right
|
|||
inherit = bar/top
|
||||
monitor = eDP-1
|
||||
|
||||
[bar/bottom]
|
||||
inherit = bar/top
|
||||
bottom = true
|
||||
modules-left =
|
||||
modules-center =
|
||||
modules-right = music
|
||||
|
||||
[bar/bottom2]
|
||||
inherit = bar/bottom
|
||||
monitor = eDP-1
|
||||
|
||||
|
||||
[module/i3]
|
||||
type = internal/i3
|
||||
|
@ -182,4 +193,11 @@ exec = echo -e "\uf011"
|
|||
format = <label>
|
||||
label = %output%
|
||||
interval = 5
|
||||
click-left = $HOME/bin/power.sh
|
||||
click-left = $HOME/bin/power.sh
|
||||
|
||||
[module/music]
|
||||
type = custom/script
|
||||
exec = $HOME/bin/music.sh
|
||||
format = <label>
|
||||
label = %output%
|
||||
interval = 1
|
|
@ -21,3 +21,5 @@ while pgrep -x polybar >/dev/null; do sleep 1; done
|
|||
# Launch bar1 and bar2
|
||||
polybar top &
|
||||
polybar top2 &
|
||||
polybar bottom &
|
||||
polybar bottom2 &
|
||||
|
|
37
system/bin/music.sh
Executable file
37
system/bin/music.sh
Executable 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"
|
|
@ -14,10 +14,12 @@
|
|||
|
||||
TEXT="Choose action"
|
||||
WIDTH=400
|
||||
HEIGHT=200
|
||||
HEIGHT=300
|
||||
ACTIONS=(
|
||||
"Reboot"
|
||||
"Shutdown"
|
||||
"Performance Mode"
|
||||
"Powersave Mode"
|
||||
)
|
||||
|
||||
action=$(zenity --list --width="${WIDTH}" --height="${HEIGHT}" --text="${TEXT}" --column="Action" "${ACTIONS[@]}")
|
||||
|
@ -29,5 +31,11 @@ then
|
|||
elif [ "${action}" == "Shutdown" ]
|
||||
then
|
||||
systemctl poweroff
|
||||
elif [ "${action}" == "Performance Mode" ]
|
||||
then
|
||||
gksudo "cpupower frequency-set -g performance"
|
||||
elif [ "${action}" == "Powersave Mode" ]
|
||||
then
|
||||
gksudo "cpupower frequency-set -g powersave"
|
||||
fi
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue