;; -*-lisp-*- (deflisten system--data :initial "{}" `~/.config/eww/scripts/system.py`) (defwidget system-battery [battery] (box :orientation "v" :halign "start" :class "module text" :space-evenly false :spacing 0 (label :class {EWW_BATTERY[battery].status == 'Charging' || EWW_BATTERY[battery].status == 'Full' ? 'green' : EWW_BATTERY[battery].capacity <= 25 ? 'highlight' : 'special'} :text "${EWW_BATTERY[battery].capacity}%") (label :text "${EWW_BATTERY[battery].status == 'Charging' || EWW_BATTERY[battery].status == 'Full' ? 'external' : 'internal'} power"))) (defwidget system-battery-gauge-small [battery] (box :orientation "v" :halign "center" :width 35 :space-evenly false :spacing 10 :class "" (label :text "PWR" :class "special") (box :halign "center" (overlay (system--small-gauge :value {EWW_BATTERY[battery].capacity} :threshold 25 :invert-threshold true :green {EWW_BATTERY[battery].status == "Charging" || EWW_BATTERY[battery].capacity == 100}))))) (defwidget system-name [] (label :halign "center" :valign "center" :class "module text big nebula" :text {system--data.hostname})) (defwidget system-cpu-avg [] (box :orientation "v" :halign "start" :class "module text" :space-evenly false :spacing 0 (label :class {system--data.cpu.avg > 90 ? 'highlight' : 'special'} :text "${system--data.cpu.avg_display}%") (label :text "cpu utilization"))) (defwidget system--cpu-core [core] (label :class {core.value > 90 ? "highlight" : "special"} :text "${core.display}%")) (defwidget system-cpu-percore [] (box :orientation "v" :halign "start" :class "module text" :space-evenly false ;; (box :orientation "h" ;; :halign "center" ;; :space-evenly false ;; (for core in {system--data.cpu.cores} ;; (system--cpu-core :core core))) (label :class "special" :text {system--data.cpu.cores_display}) (label :text "per-core cpu utilization") )) (defwidget system-memory [] (box :orientation "v" :halign "start" :class "module text" :space-evenly false (label :class {system--data.memory.percent > 85 ? "highlight" : "special"} :text "${round(system--data.memory.used / 1024 / 1024 / 1024, 2)} / ${round(system--data.memory.total / 1024 / 1024 / 1024, 2)} GiB") (label :text "system memory"))) (defwidget system--gauge [value ?threshold ?green] (overlay :width 80 :height 80 (circular-progress :value 75 :class "gauge-gutter" :start-at 37.5 :thickness 2) (circular-progress :value {value * 0.75} :class 'gauge ${value > (threshold ?: 80) ? "highlight" : ""}' :start-at 37.5 :thickness 2))) (defwidget system--small-gauge [value ?threshold ?green ?invert-threshold] (overlay :width 30 :height 30 (circular-progress :value 75 :class "gauge-gutter" :start-at 37.5 :thickness 2) (circular-progress :value {value * 0.75} :class 'gauge ${(green ?: false) ? "green" : (((invert-threshold ?: false) ? (value < (threshold ?: 20)) : (value > (threshold ?: 80))) ? "highlight" : "")}' :start-at 37.5 :thickness 2))) (defwidget cpu-mem-gauges [] (box :orientation "v" :space-evenly false :spacing 20 :width 95 :halign "start" (system--cpu-gauge) (system--gpu-gauge))) (defwidget gpu-gauges [] (box :orientation "v" :space-evenly false :spacing 20 :width 95 :halign "end" (system--memory-gauge) (system--vram-gauge))) (defwidget system-gauges [] (box :orientation "h" :space-evenly false :width 200 :halign "start" :spacing 10 (cpu-mem-gauges) (gpu-gauges))) (defwidget system--memory-gauge [] (box :orientation "v" :halign "end" :width 95 :space-evenly false :spacing 10 :class "nebula" (label :text "RAM" :class "medium special") (box :halign "center" (overlay (system--gauge :value {system--data.memory.percent}) (transform :translate-y "-2px" (box :halign "center" :valign "center" :orientation "h" :space-evenly false (label :text "%" :class "invisible") (label :text {round(system--data.memory.percent, 0)} :class "medium special") (transform :translate-y "3px" (label :text "%" :class "offline")))))))) (defwidget system--memory-gauge-small [] (box :orientation "v" :halign "center" :width 35 :space-evenly false :spacing 10 :class "" (label :text "MEM" :class "special") (box :halign "center" (overlay (system--small-gauge :value {system--data.memory.percent}))))) (defwidget system--cpu-gauge [] (box :orientation "v" :halign "start" :width 95 :space-evenly false :spacing 10 :class "nebula" (label :text "CPU" :class "medium special") (box :halign "center" (overlay (system--gauge :value {system--data.cpu.avg}) (transform :translate-y "-2px" (box :halign "center" :valign "center" :orientation "h" :space-evenly false (label :text "%" :class "invisible") (label :text {system--data.cpu.avg_display} :class "medium special") (transform :translate-y "3px" (label :text "%" :class "offline")))))) )) (defwidget system--cpu-gauge-small [] (box :orientation "v" :halign "center" :width 35 :space-evenly false :spacing 10 :class "" (label :text "CPU" :class "special") (box :halign "center" (overlay (system--small-gauge :value {system--data.cpu.avg} :threshold 80))))) (defwidget system--gpu-gauge [] (box :orientation "v" :halign "start" :width 95 :space-evenly false :spacing 10 :class "nebula" (label :text "GPU" :class "medium special") (box :halign "center" (overlay (system--gauge :value {system--data.gpu.load * 100}) (transform :translate-y "-2px" (box :halign "center" :valign "center" :orientation "h" :space-evenly false (label :text "%" :class "invisible") (label :text {round(system--data.gpu.load * 100, 0)} :class "medium special") (transform :translate-y "3px" (label :text "%" :class "offline")))))))) (defwidget system--gpu-gauge-small [] (box :orientation "v" :halign "center" :width 35 :space-evenly false :spacing 10 :class "" (label :text "GPU" :class "special") (box :halign "center" (overlay (system--small-gauge :value {system--data.gpu.load * 100}))))) (defwidget system--vram-gauge [] (box :orientation "v" :halign "start" :width 95 :space-evenly false :spacing 10 :class "nebula" (label :text "VRAM" :class "medium special") (box :halign "center" (overlay (system--gauge :value {system--data.gpu.memory * 100}) (transform :translate-y "-2px" (box :halign "center" :valign "center" :orientation "h" :space-evenly false (label :text "%" :class "invisible") (label :text {round(system--data.gpu.memory * 100, 0)} :class "medium special") (transform :translate-y "3px" (label :text "%" :class "offline")))))))) (defwidget system--vram-gauge-small [] (box :orientation "v" :halign "center" :width 35 :space-evenly false :spacing 10 :class "" (label :text "VMEM" :class "special") (box :halign "center" (overlay (system--small-gauge :value {system--data.gpu.memory * 100}))))) (defwidget system--gauge-generic [value value-fmt big-text little-text ?subscript ?threshold] (box :orientation "h" :halign "start" :class "module gauge-widget" :space-evenly true :spacing 0 (overlay :width 100 (circular-progress :value 100 :class "gauge-hole" :start-at 0 :thickness 50 ) (circular-progress :value 80 :class "gauge-gutter" :start-at 35 :thickness 2) (circular-progress :value {value * 0.8} :class 'gauge ${value > (threshold ?: 80) ? "highlight" : ""}' :start-at 35 :thickness 2) (transform :translate-y "-5px" :translate-x "3px" (box :halign "center" :valign "center" :class "big nebula" :space-evenly false "${value-fmt}" (box :class "normal offline" :halign "start" :valign "end" (transform :translate-y "-2px" :translate-x "1px" {subscript}))))) (transform :translate-y "-5px" (box :orientation "v" :halign "center" :valign "center" :space-evenly false (label :text {big-text} :class "big nebula") (label :text {little-text} :class "nebula special")))))