add caffeine to polybar

Amolith created

Change summary

dot_config/polybar/caffeine.sh     | 22 ++++++++++++++++++++++
dot_config/polybar/config.ini.tmpl |  9 ++++++++-
2 files changed, 30 insertions(+), 1 deletion(-)

Detailed changes

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

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 = <label>
+
 ; vim:ft=dosini