Add redshift module
This commit is contained in:
parent
0448843f2a
commit
2b6d4c7f12
|
@ -43,7 +43,7 @@ wm-restack = bspwm
|
|||
# clipmenu-widget: showing clipmenu service
|
||||
|
||||
# Top modules
|
||||
bottom-left = powermenu title bluetooth wireguard
|
||||
bottom-left = powermenu title bluetooth wireguard redshift
|
||||
bottom-center = i3
|
||||
bottom-right = alsa battery date
|
||||
|
||||
|
|
|
@ -220,7 +220,7 @@ format-underline = ${colors.nord9}
|
|||
|
||||
ramp-0 =
|
||||
|
||||
label = %{A1:$HOME/.config/polybar/scripts/toggle-redshift.sh:}%percentage%%%{A}
|
||||
label = %percentage%%
|
||||
ramp-foreground = ${colors.nord9}
|
||||
|
||||
[module/mpd]
|
||||
|
@ -406,3 +406,12 @@ type = custom/script
|
|||
exec = ~/.config/polybar/polybar-wireguard
|
||||
tail = false
|
||||
interval = 2
|
||||
|
||||
[module/redshift]
|
||||
type = custom/script
|
||||
format-prefix = " "
|
||||
format-prefix-foreground = ${colors.urgent}
|
||||
format-underline = ${colors.urgent}
|
||||
exec = $HOME/.config/polybar/scripts/redshift.sh period
|
||||
click-left = $HOME/.config/polybar/scripts/redshift.sh toggle
|
||||
interval = 1
|
||||
|
|
35
.config/polybar/scripts/redshift.sh
Executable file
35
.config/polybar/scripts/redshift.sh
Executable file
|
@ -0,0 +1,35 @@
|
|||
#!/bin/sh
|
||||
|
||||
|
||||
checkIfRunning() {
|
||||
if [ $(systemctl --user is-active redshift) == "active" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
changeModeToggle() {
|
||||
|
||||
if checkIfRunning ; then
|
||||
systemctl --user stop redshift
|
||||
else
|
||||
systemctl --user start redshift
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
case $1 in
|
||||
toggle)
|
||||
changeModeToggle
|
||||
;;
|
||||
period)
|
||||
if checkIfRunning ; then
|
||||
CURRENT_PERIOD=$(systemctl --user status redshift 2> /dev/null | grep "Period" | sed 's/.*: //')
|
||||
echo "$CURRENT_PERIOD"
|
||||
else
|
||||
echo "off"
|
||||
fi
|
||||
;;
|
||||
esac
|
|
@ -1,9 +0,0 @@
|
|||
#! /bin/bash
|
||||
|
||||
if pgrep -x redshift > /dev/null
|
||||
then
|
||||
pgrep redshift | xargs -n1 kill -9 | notify-send 'Redshift stopped'
|
||||
else
|
||||
notify-send 'Redshift started'
|
||||
redshift &
|
||||
fi
|
Loading…
Reference in a new issue