improve eww

This commit is contained in:
2026-09-10 19:54:50 +02:00
parent e551d36e1c
commit 7bb27f9373
46 changed files with 1296 additions and 1092 deletions
@@ -1,12 +1,4 @@
(deflisten netinfo
:initial '{"wifi":{"ssid":"","ip":"","freq":0,"band":"","gen":"","signal":0},"ethernet":{"state":"down","ip":"","speed":"","interface":""},"usb":{"interface":"","ip":""}}'
"scripts/net/netinfo")
(deflisten bt-devices
:initial "[]"
"scripts/net/bt-devices")
; --- Shared widgets ---
(defwidget netinfo-row [label value]
@@ -34,10 +26,10 @@
:icon-on "󰤨" :icon-off "󰖪")
(box :orientation "v" :space-evenly false
:visible {net.wifi.connected}
(netinfo-row :label "SSID" :value {netinfo.wifi.ssid})
(netinfo-row :label "IP" :value {netinfo.wifi.ip})
(netinfo-row :label "Signal" :value "${net.wifi.icon} ${netinfo.wifi.signal} dBm")
(netinfo-row :label "Freq" :value "${netinfo.wifi.freq} MHz · ${netinfo.wifi.band} · ${netinfo.wifi.gen}"))
(netinfo-row :label "SSID" :value {net.wifi.ssid})
(netinfo-row :label "IP" :value {net.wifi.ip})
(netinfo-row :label "Signal" :value "${net.wifi.icon} ${net.wifi.signal} dBm")
(netinfo-row :label "Freq" :value "${net.wifi.freq} MHz · ${net.wifi.band} · ${net.wifi.gen}"))
(label :class "netinfo-dim" :halign "start"
:visible {!net.wifi.connected}
:text {net.wifi.enabled ? "Not connected" : "Disabled"})))
@@ -47,8 +39,8 @@
(defwidget usb-net-section []
(box :orientation "v" :space-evenly false :class "sys-section"
(section-header :title "USB" :accent "usb-accent")
(netinfo-row :label "Interface" :value {netinfo.usb.interface})
(netinfo-row :label "IP" :value {netinfo.usb.ip})))
(netinfo-row :label "Interface" :value {net.usb.interface})
(netinfo-row :label "IP" :value {net.usb.ip})))
; --- Ethernet ---
@@ -57,9 +49,9 @@
(section-header :title "Ethernet" :accent "eth-accent")
(box :orientation "v" :space-evenly false
:visible {net.ethernet.connected}
(netinfo-row :label "Interface" :value {netinfo.ethernet.interface})
(netinfo-row :label "IP" :value {netinfo.ethernet.ip})
(netinfo-row :label "Speed" :value {netinfo.ethernet.speed}))
(netinfo-row :label "Interface" :value {net.ethernet.interface})
(netinfo-row :label "IP" :value {net.ethernet.ip})
(netinfo-row :label "Speed" :value {net.ethernet.speed}))
(label :class "netinfo-dim" :halign "start"
:visible {!net.ethernet.connected}
:text "No carrier")))
@@ -79,16 +71,16 @@
(box :orientation "v" :space-evenly false :class "sys-section"
(section-header-toggle
:title "Bluetooth" :accent "blt-accent"
:enabled {bluetooth.powered}
:onclick {bluetooth.powered ? "bluetoothctl power off" : "bluetoothctl power on"}
:enabled {bt.powered}
:onclick {bt.powered ? "bluetoothctl power off" : "bluetoothctl power on"}
:icon-on "󰂯" :icon-off "󰂲")
(scroll :vscroll true :hscroll false :height 90
:visible {bluetooth.powered}
:visible {bt.powered}
(box :orientation "v" :space-evenly false
(for device in {bt-devices}
(for device in {bt.devices}
(bt-device-row :device {device}))))
(label :class "netinfo-dim" :halign "start"
:visible {!bluetooth.powered}
:visible {!bt.powered}
:text "Disabled")))
; --- Root ---
@@ -1,4 +1,8 @@
; Monitor the popup is currently open on (set by scripts/panel-toggle), so a
; panel switch on the same monitor is an in-place revealer transition.
(defvar popup-screen "")
(defwidget popup-win []
(box :space-evenly false :orientation "v"
(revealer :reveal {active-panel == "sys"} :transition "slidedown" :duration 120
@@ -18,7 +18,7 @@
(pm-btn :icon "󰍁" :label "Lock"
:onclick "scripts/lock")
(pm-btn :icon "󰤄" :label "Suspend"
:onclick "scripts/lock & systemctl suspend")
:onclick "scripts/lock; systemctl suspend")
(pm-btn :icon "󰗼" :label "Sign out"
:onclick "hyprctl eval \"hl.dispatch(hl.dsp.exit())\"")
(pm-btn :icon "󰅖" :label "Cancel"
@@ -77,6 +77,6 @@
(defwidget radio-mod []
(module
(eventbox
:onclick "(sleep 0.1 && scripts/panel-toggle radio)"
:onclick "scripts/panel-toggle radio"
(box :orientation "v"
(label :show-truncated false :class "icon-text" :text "󰝚")))))
@@ -1,17 +1,15 @@
(defpoll swap :interval "30s" "scripts/sys/swap")
(defpoll cpu-freq-min :interval "60s"
(defpoll cpu-freq-min :interval "60s" :initial "0"
"awk '{print $1/1000}' /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq")
(defpoll cpu-freq-max :interval "60s"
(defpoll cpu-freq-max :interval "60s" :initial "1"
"awk '{print $1/1000}' /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq")
(defpoll cpu-temp :interval "4s"
(defpoll cpu-temp :interval "4s" :initial "0"
"scripts/sys/cputemp")
(defpoll cpu-freq-avg :interval "2s"
(defpoll cpu-freq-avg :interval "2s" :initial "0"
"awk '{sum+=$1; count++} END {printf \"%.1f\", sum/count/1000000}' /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq")
(deflisten cpu-grid :initial '[[{"core":0,"usage":0,"freq":0}]]'
"bash scripts/sys/cpugrid")
; The CPU grid is fed by the EWW_CPU magic variable (2 s); jq() reshapes the
; core list into rows of four.
; --- Shared ---
@@ -46,7 +44,7 @@
(box :orientation "v" :space-evenly false :class "sys-section"
(section-header :title "CPU" :accent "cpu-accent")
(box :orientation "v" :space-evenly false :halign "center"
(for row in {cpu-grid}
(for row in {jq(EWW_CPU.cores, '[.[] | .core |= ltrimstr("cpu")] | [range(0; length; 4) as $i | .[$i:$i + 4]]')}
(box :orientation "h" :space-evenly false
(for core in {row}
(cpu-core-cell :core {core})))))
@@ -162,13 +160,13 @@
(overlay
(circular-progress
:width 72 :height 72
:value {100*swap.used/swap.total}
:value {memory.swap.total > 0 ? 100 * memory.swap.used / memory.swap.total : 0}
:start-at 0 :clockwise true :thickness 7
:class "swap-ring"
:tooltip "Swap\n${swap.human.used} / ${swap.human.total}")
:tooltip "Swap\n${memory.swap.human.used} / ${memory.swap.human.total}")
(box :orientation "v" :valign "center" :halign "center" :space-evenly false
(label :class "ram-used-label" :text "${swap.human.used}")
(label :class "ram-total-label" :text "${swap.human.total}"))))
(label :class "ram-used-label" :text "${memory.swap.human.used}")
(label :class "ram-total-label" :text "${memory.swap.human.total}"))))
)
)
)
@@ -185,8 +183,7 @@
:start-at 0
:clockwise true
:thickness 6
:class "bat-ring"
:style "color: ${battery.color};"
:class "bat-ring bat-${battery.state}"
:tooltip "Battery ${round(battery.percentage, 0)}%\n${battery.status} @ ${battery.wattage}")
(label :class "bat-ring-label"
:text "${round(battery.percentage, 0)}%"))