radio-win

This commit is contained in:
soraefir
2026-06-12 23:49:38 +02:00
parent c724c853f5
commit ce804942a9
13 changed files with 140 additions and 117 deletions

View File

@@ -1,25 +1,37 @@
(defpoll netinfo
:interval "5s"
:initial '{"wifi":{"ssid":"","ip":"","freq":0,"band":"","gen":"","signal":0},"ethernet":{"state":"down","ip":"","speed":"","interface":""}}'
(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 row widget ---
; --- Shared widgets ---
(defwidget netinfo-row [label value]
(box :orientation "h" :space-evenly false :class "netinfo-row"
(label :class "netinfo-label" :halign "start" :text label)
(label :class "netinfo-value" :halign "end" :hexpand true :text value)))
(defwidget section-header-toggle [title accent enabled onclick icon-on icon-off]
(box :orientation "h" :space-evenly false :valign "center" :class "sys-section-header"
(box :class "section-accent ${accent}")
(label :class "sys-label" :text title :hexpand true :halign "start")
(button
:class "net-toggle-btn ${enabled ? 'net-toggle-on' : 'net-toggle-off'}"
:onclick onclick
(label :text {enabled ? icon-on : icon-off}))))
; --- WiFi ---
(defwidget wifi-net-section []
(box :orientation "v" :space-evenly false :class "sys-section"
(section-header :title "WiFi" :accent "wifi-accent")
(section-header-toggle
:title "WiFi" :accent "wifi-accent"
:enabled {net.wifi.enabled}
:onclick {net.wifi.enabled ? "rfkill block wlan" : "rfkill unblock wlan"}
:icon-on "󰤨" :icon-off "󰖪")
(box :orientation "v" :space-evenly false
:visible {net.wifi.connected}
(netinfo-row :label "SSID" :value {netinfo.wifi.ssid})
@@ -28,7 +40,15 @@
(netinfo-row :label "Freq" :value "${netinfo.wifi.freq} MHz · ${netinfo.wifi.band} · ${netinfo.wifi.gen}"))
(label :class "netinfo-dim" :halign "start"
:visible {!net.wifi.connected}
:text "Not connected")))
:text {net.wifi.enabled ? "Not connected" : "Disabled"})))
; --- USB ---
(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})))
; --- Ethernet ---
@@ -57,19 +77,31 @@
(defwidget bluetooth-net-section []
(box :orientation "v" :space-evenly false :class "sys-section"
(section-header :title "Bluetooth" :accent "blt-accent")
(box :orientation "v" :space-evenly false
(for device in {bt-devices}
(bt-device-row :device {device})))))
(section-header-toggle
:title "Bluetooth" :accent "blt-accent"
:enabled {bluetooth.powered}
:onclick {bluetooth.powered ? "bluetoothctl power off" : "bluetoothctl power on"}
:icon-on "󰂯" :icon-off "󰂲")
(scroll :vscroll true :hscroll false :height 90
:visible {bluetooth.powered}
(box :orientation "v" :space-evenly false
(for device in {bt-devices}
(bt-device-row :device {device}))))
(label :class "netinfo-dim" :halign "start"
:visible {!bluetooth.powered}
:text "Disabled")))
; --- Root ---
(defwidget net-win []
(box :class "sys-win" :space-evenly false :orientation "v"
(wifi-net-section)
(box :class "section-sep")
(box :visible {net.usb.connected} :space-evenly false :orientation "v"
(usb-net-section)
(box :class "section-sep"))
(ethernet-net-section)
(box :class "section-sep")
(wifi-net-section)
(box :class "section-sep")
(bluetooth-net-section)))
(defwindow net