diff --git a/dot_config/polybar/caffeine.sh b/dot_config/polybar/caffeine.sh new file mode 100644 index 0000000000000000000000000000000000000000..d55c14982ae770bde262c11f90ad56f0d9250a36 --- /dev/null +++ b/dot_config/polybar/caffeine.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +case $1 in + "toggle-mode") + status=`xset -q | grep 'DPMS is' | awk '{ print $3 }'` + if [ $status == 'Enabled' ]; then + xset -dpms + xset s off + else + xset +dpms + xset s on + fi + ;; + "show-mode") + status=`xset -q | grep 'DPMS is' | awk '{ print $3 }'` + if [ $status == 'Enabled' ]; then + echo "Disabled" + else + echo "Enabled" + fi + ;; +esac diff --git a/dot_config/polybar/config.ini.tmpl b/dot_config/polybar/config.ini.tmpl index 55ca444815fe3e4efb3de88e710477c1483dc939..49a997e5da61ab1fb79c1b56e46933cf093a8c81 100644 --- a/dot_config/polybar/config.ini.tmpl +++ b/dot_config/polybar/config.ini.tmpl @@ -30,7 +30,7 @@ font-1 = "JetBrainsMono NF:style=Regular" modules-left = i3 modules-center = xwindow {{- if ne .chezmoi.hostname "glade" }} -modules-right = updates wlan pulseaudio cpu memory date time {{ if eq .chezmoi.hostname "sidhe" }}battery{{ end }} +modules-right = updates caffeine wlan pulseaudio cpu memory date time {{ if eq .chezmoi.hostname "sidhe" }}battery{{ end }} {{- else }} modules-right = wlan pulseaudio cpu memory date battery {{- end }} @@ -227,4 +227,11 @@ format-prefix = "󱄋 " margin-top = 5 margin-bottom = 5 +[module/caffeine] +type = custom/script +trail = false +exec = ~/.config/polybar/caffeine.sh +click-left = ~/.config/polybar/caffeine.sh toggle +format =