aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Wilken2024-06-04 14:47:13 +0200
committerTimo Wilken2024-06-04 14:47:13 +0200
commite749c97ffb35eba54d94d6069613475971d69c90 (patch)
treea8cc544ed6b4868296153778adab499520af87a5
parent3ef917bec25342730c8f3e15406e1fca8175ec4d (diff)
Allow configuring thermal zone shown in polybar
This is highly likely to be different on different machines.
-rw-r--r--tw/home/cern.scm1
-rw-r--r--tw/services/desktop.scm12
-rw-r--r--tw/services/files/polybar.ini3
3 files changed, 11 insertions, 5 deletions
diff --git a/tw/home/cern.scm b/tw/home/cern.scm
index a653bde7..842b8658 100644
--- a/tw/home/cern.scm
+++ b/tw/home/cern.scm
@@ -58,6 +58,7 @@
(bluetooth? #t)
(battery-name "BAT0")
(ac-adapter-name "AC")
+ (thermal-zone "0")
(monitors
(list (home-monitor-configuration
(name "eDP-1")
diff --git a/tw/services/desktop.scm b/tw/services/desktop.scm
index 53385761..1aa2bb2d 100644
--- a/tw/services/desktop.scm
+++ b/tw/services/desktop.scm
@@ -103,6 +103,11 @@ true, configure the user interface to use it.")
See @code{/sys/class/power_supply}.")
(ac-adapter-name maybe-string "The device name of the system's mains power
supply, if any. See @code{/sys/class/power_supply}.")
+ ;; The default mirrors the previously hard-coded value from polybar.ini, for
+ ;; compatibility. It is probably not a great default; "0" might be better.
+ (thermal-zone (string "1") "The number of the thermal sensor used to show
+the system temperature. Run @code{grep '^' /sys/class/thermal/thermal_zone*/type}
+to list zones and their types.")
(monitors list-of-monitors "List of monitor declarations to apply."))
(define polybar-wrapper
@@ -124,7 +129,7 @@ supply, if any. See @code{/sys/class/power_supply}.")
(when monitor-connected?
(execl #$(file-append polybar "/bin/polybar") "polybar"))))))
-(define (polybar-service monitor battery-name ac-adapter-name)
+(define (polybar-service monitor battery-name ac-adapter-name thermal-zone)
(shepherd-service
(documentation (string-append "Polybar desktop bar for monitor " monitor "."))
(provision (list (symbol-append 'polybar- (string->symbol monitor))))
@@ -135,6 +140,7 @@ supply, if any. See @code{/sys/class/power_supply}.")
(cons* #$(string-append "POLYBAR_MONITOR=" monitor)
#$(string-append "POLYBAR_BATTERY=" (maybe-value battery-name ""))
#$(string-append "POLYBAR_AC_ADAPTER=" (maybe-value ac-adapter-name ""))
+ #$(string-append "POLYBAR_THERMAL_ZONE=" thermal-zone)
(default-environment-variables))))
(stop #~(make-kill-destructor))))
@@ -329,7 +335,7 @@ show_border=1
(define (home-shepherd-services config)
"Run various daemons in my user profile."
(match-record config <home-desktop-configuration>
- (nvidia-driver? bluetooth? desktop-background battery-name ac-adapter-name monitors)
+ (nvidia-driver? bluetooth? desktop-background battery-name ac-adapter-name thermal-zone monitors)
`(,(shepherd-service
(documentation "NetworkManager applet; provides a GUI for network connections.")
(provision '(nm-applet))
@@ -424,7 +430,7 @@ show_border=1
(stop #~(make-kill-destructor))))
'())
- ,@(map (compose (cut polybar-service <> battery-name ac-adapter-name)
+ ,@(map (compose (cut polybar-service <> battery-name ac-adapter-name thermal-zone)
home-monitor-configuration-name)
monitors))))
diff --git a/tw/services/files/polybar.ini b/tw/services/files/polybar.ini
index 54f6ff19..5c398c4a 100644
--- a/tw/services/files/polybar.ini
+++ b/tw/services/files/polybar.ini
@@ -153,8 +153,7 @@ ramp-coreload-7-foreground = ${colors.alert}
[module/temp]
type = internal/temperature
-; head /sys/class/thermal/thermal_zone*/type
-thermal-zone = 1
+thermal-zone = ${env:POLYBAR_THERMAL_ZONE}
format-prefix = "🌡 "
format-prefix-foreground = ${colors.primary}
format-warn-prefix = "🌡 "