feat: eww temperature monitoring

wayland/eww
Leni Aniva 2024-06-02 23:51:55 -07:00
parent 9b2bd7ad99
commit 07aef5a19b
Signed by: aniva
GPG Key ID: 4D9B1C8D10EA4C50
2 changed files with 83 additions and 21 deletions

View File

@ -34,12 +34,27 @@ $memory_bg: #333333;
// previously bluetooth colour // previously bluetooth colour
$memory: #caa9c7; $memory: #caa9c7;
//$memory: #88bbeb; //$memory: #88bbeb;
$temperature: #ddb6f2; $temperature-bg: rgba(180, 180, 180, 0.5);
$temperature_critical: #ff6666; $temperature: #b6b2b3;
$battery: #b6b2b3; $temperature-critical: #ff6666;
$battery: #ddb6f2;
// Styles all scales // 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 { scale trough {
all: unset; all: unset;
background-color: #333333; 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 { box .cpu {
.progress { .progress {
background-color: $cpu_bg; background-color: $cpu_bg;

View File

@ -1,4 +1,5 @@
(defvar amixer "amixer -D pulse") (defvar amixer "amixer -D pulse")
(defvar temperature-monitor "psensor")
(defwindow vbar (defwindow vbar
:exclusive true :exclusive true
@ -14,9 +15,12 @@
:reserve (struts :side "left" :distance "20px") :reserve (struts :side "left" :distance "20px")
(centerbox (centerbox
:orientation "v" :orientation "v"
(box :orientation "v" :space-evenly false :valign "start" (box
:orientation "v" :space-evenly false :valign "start"
(label (label
:class "launcher" :valign "start" :width "20px" :height "20px" :class "launcher"
:valign "start"
:width "20px" :height "20px"
:unindent true :unindent true
:tooltip active-window-title :tooltip active-window-title
:text "☯") :text "☯")
@ -29,7 +33,7 @@
(widget-tray) (widget-tray)
(widget-volume) (widget-volume)
(widget-microphone) (widget-microphone)
;(widget-temperature) (widget-temperature)
(widget-cpu) (widget-cpu)
(widget-memory) (widget-memory)
(widget-clock) (widget-clock)
@ -41,7 +45,8 @@
:class "workspaces" :class "workspaces"
:orientation "v" :orientation "v"
:space-evenly true :space-evenly true
:valign "start" :spacing 10 :spacing 10
:valign "start"
:halign "center" :halign "center"
(for workspace in workspaces (for workspace in workspaces
(button (button
@ -61,6 +66,7 @@
:orientation "v" :orientation "v"
:space-evenly false :space-evenly false
:valign "center" :valign "center"
:tooltip {media-position-text}
(eventbox (eventbox
:onclick "playerctl play-pause" :onclick "playerctl play-pause"
(circular-progress (circular-progress
@ -68,7 +74,6 @@
:width 20 :width 20
:height 20 :height 20
:thickness 5 :thickness 5
:tooltip {media-position-text}
:value {100.0 * media-position / (media-length / 1000000.0)} :value {100.0 * media-position / (media-length / 1000000.0)}
:visible {media-current != "" && media-length != 1} :visible {media-current != "" && media-length != 1}
)) ))
@ -148,21 +153,45 @@
:xalign 0.5 :yalign 0.5 :xalign 0.5 :yalign 0.5
:noindent true :noindent true
:text { current-microphone-state == "off" ? "" : "" })))) :text { current-microphone-state == "off" ? "" : "" }))))
(defpoll current-volume :interval "1s" "amixer sget Master | 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-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 :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 }'") (defpoll current-microphone-state :interval "1s" "amixer sget Capture | grep 'Left:' | awk -F'[][]' '{ print $4 }'")
(defvar show-volume false) (defvar show-volume false)
(defvar show-microphone 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 [] (defwidget widget-temperature []
(label (eventbox
:class "temperature" :onclick temperature-monitor
:width 20 (box
:height 20 :class "temperature"
:tooltip {EWW_TEMPS} :orientation "h"
:text "" :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 [] (defwidget widget-cpu []
(box (box
:class "cpu" :class "cpu"
@ -205,9 +234,11 @@
:width 20 :width 20
:tooltip {formattime(EWW_TIME, "%F (%a) %T [%Z]")} :tooltip {formattime(EWW_TIME, "%F (%a) %T [%Z]")}
;(box :class "icon" "") ;(box :class "icon" "")
"${clock.m}" "${clock.d}" (label :text "${clock.m}")
(box :class "icon" "") (label :text "${clock.d}")
"${clock.H}" "${clock.M}" (label :class "icon" :text "")
(label :text "${clock.H}")
(label :text "${clock.M}")
)) ))
(defpoll clock :initial "{}" :interval "10s" (defpoll clock :initial "{}" :interval "10s"