Add redshift module

This commit is contained in:
Yash Karandikar 2023-01-01 13:05:14 -06:00
parent 0448843f2a
commit 2b6d4c7f12
4 changed files with 46 additions and 11 deletions

View file

@ -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

View file

@ -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

View 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

View file

@ -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