From 07aef5a19b1620eff19701cfd0789b7e84b31897 Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Sun, 2 Jun 2024 23:51:55 -0700 Subject: [PATCH] feat: eww temperature monitoring --- eww/bar/eww.scss | 37 +++++++++++++++++++++++--- eww/bar/eww.yuck | 67 +++++++++++++++++++++++++++++++++++------------- 2 files changed, 83 insertions(+), 21 deletions(-) diff --git a/eww/bar/eww.scss b/eww/bar/eww.scss index d5cf9ea..c910987 100644 --- a/eww/bar/eww.scss +++ b/eww/bar/eww.scss @@ -34,12 +34,27 @@ $memory_bg: #333333; // previously bluetooth colour $memory: #caa9c7; //$memory: #88bbeb; -$temperature: #ddb6f2; -$temperature_critical: #ff6666; -$battery: #b6b2b3; +$temperature-bg: rgba(180, 180, 180, 0.5); +$temperature: #b6b2b3; +$temperature-critical: #ff6666; +$battery: #ddb6f2; // Styles all scales +progressbar trough { + all: unset; + background-color: #333333; + border-radius: 5px; + min-height: 80px; + min-width: 2px; + //margin: .3rem 0 .3rem 0; +} +trough progress { + all: unset; + background-color: #00ff00; + border-radius: 5px; + min-width: 2px; +} scale trough { all: unset; background-color: #333333; @@ -181,6 +196,22 @@ box .weather { } } +box .temperature { + color: $temperature; + border-left: 2px solid $temperature-bg; + margin-bottom: 1px; + margin-top: 1px; +} +.temperature-progress trough progress { + background-color: $temperature; +} +.temperature-progress-cpu trough progress { + background-color: mix($cpu, $temperature, 50%); +} +.temperature-progress-critical trough progress { + background-color: $temperature-critical; +} + box .cpu { .progress { background-color: $cpu_bg; diff --git a/eww/bar/eww.yuck b/eww/bar/eww.yuck index e051cf1..0ac47d1 100644 --- a/eww/bar/eww.yuck +++ b/eww/bar/eww.yuck @@ -1,4 +1,5 @@ (defvar amixer "amixer -D pulse") +(defvar temperature-monitor "psensor") (defwindow vbar :exclusive true @@ -14,9 +15,12 @@ :reserve (struts :side "left" :distance "20px") (centerbox :orientation "v" - (box :orientation "v" :space-evenly false :valign "start" + (box + :orientation "v" :space-evenly false :valign "start" (label - :class "launcher" :valign "start" :width "20px" :height "20px" + :class "launcher" + :valign "start" + :width "20px" :height "20px" :unindent true :tooltip active-window-title :text "☯") @@ -29,7 +33,7 @@ (widget-tray) (widget-volume) (widget-microphone) - ;(widget-temperature) + (widget-temperature) (widget-cpu) (widget-memory) (widget-clock) @@ -41,7 +45,8 @@ :class "workspaces" :orientation "v" :space-evenly true - :valign "start" :spacing 10 + :spacing 10 + :valign "start" :halign "center" (for workspace in workspaces (button @@ -61,6 +66,7 @@ :orientation "v" :space-evenly false :valign "center" + :tooltip {media-position-text} (eventbox :onclick "playerctl play-pause" (circular-progress @@ -68,7 +74,6 @@ :width 20 :height 20 :thickness 5 - :tooltip {media-position-text} :value {100.0 * media-position / (media-length / 1000000.0)} :visible {media-current != "" && media-length != 1} )) @@ -148,21 +153,45 @@ :xalign 0.5 :yalign 0.5 :noindent true :text { current-microphone-state == "off" ? "" : "" })))) -(defpoll current-volume :interval "1s" "amixer sget Master | grep 'Left:' | awk -F'[][]' '{ print $2 }' | tr -d '%'") -(defpoll current-volume-state :interval "1s" "amixer sget Master | grep 'Left:' | awk -F'[][]' '{ print $4 }'") -(defpoll current-microphone :interval "1s" "amixer sget Capture | grep 'Left:' | awk -F'[][]' '{ print $2 }' | tr -d '%'") +(defpoll current-volume :interval "1s" "amixer sget Master | grep 'Left:' | awk -F'[][]' '{ print $2 }' | tr -d '%'") +(defpoll current-volume-state :interval "1s" "amixer sget Master | grep 'Left:' | awk -F'[][]' '{ print $4 }'") +(defpoll current-microphone :interval "1s" "amixer sget Capture | grep 'Left:' | awk -F'[][]' '{ print $2 }' | tr -d '%'") (defpoll current-microphone-state :interval "1s" "amixer sget Capture | grep 'Left:' | awk -F'[][]' '{ print $4 }'") (defvar show-volume false) (defvar show-microphone false) +; FIXME: Maybe use a env var here instead +(defvar cpu-temp-key "ASUS_WMI_SENSORS_CPU_TEMPERATURE") +(defvar gpu-temp-key "AMDGPU_MEM") +(defvar temperature-threshold 80) + (defwidget widget-temperature [] - (label - :class "temperature" - :width 20 - :height 20 - :tooltip {EWW_TEMPS} - :text "" - )) + (eventbox + :onclick temperature-monitor + (box + :class "temperature" + :orientation "h" + :tooltip "CPU ${EWW_TEMPS[cpu-temp-key]}C; GPU ${EWW_TEMPS[gpu-temp-key]}C" + :space-evenly true + :width 20 + :halign "" :valign "center" + (progress + :class { EWW_TEMPS[cpu-temp-key] > temperature-threshold ? "temperature-progress-critical" : "temperature-progress-cpu" } + :halign "center" :valign "center" + :flipped "true" + :width 3 + :orientation "v" + :value {EWW_TEMPS[cpu-temp-key]} + ) + (progress + :class { EWW_TEMPS[gpu-temp-key] > temperature-threshold ? "temperature-progress-critical" : "temperature-progress" } + :halign "center" :valign "center" + :flipped "true" + :width 3 + :orientation "v" + :value {EWW_TEMPS[gpu-temp-key]} + ) + ))) (defwidget widget-cpu [] (box :class "cpu" @@ -205,9 +234,11 @@ :width 20 :tooltip {formattime(EWW_TIME, "%F (%a) %T [%Z]")} ;(box :class "icon" "") - "${clock.m}" "${clock.d}" - (box :class "icon" "") - "${clock.H}" "${clock.M}" + (label :text "${clock.m}") + (label :text "${clock.d}") + (label :class "icon" :text "") + (label :text "${clock.H}") + (label :text "${clock.M}") )) (defpoll clock :initial "{}" :interval "10s"