From 578797498eeda477954b90810f9bdbb295308233 Mon Sep 17 00:00:00 2001 From: Joshua Yuen Date: Sat, 12 Sep 2026 15:55:33 -0400 Subject: [PATCH] Move wifi into QuickSettings popup with collapsible network list --- modules/home/ags/app/style.scss | 21 ++- modules/home/ags/app/widget/Bar.tsx | 4 - modules/home/ags/app/widget/QuickSettings.tsx | 3 + modules/home/ags/app/widget/Wifi.tsx | 120 ++++++++++-------- 4 files changed, 91 insertions(+), 57 deletions(-) diff --git a/modules/home/ags/app/style.scss b/modules/home/ags/app/style.scss index fab841d..efe11ec 100644 --- a/modules/home/ags/app/style.scss +++ b/modules/home/ags/app/style.scss @@ -92,7 +92,6 @@ $module-bg: transparentize($base02, 0.4); } .ws:hover, -.wifi:hover, .battery:hover { background: transparentize($base05, 0.88); } @@ -166,6 +165,26 @@ $module-bg: transparentize($base02, 0.4); } } +.wifi-section { + margin-top: 10px; + border-top: 1px solid $base02; + padding-top: 8px; +} + +.wifi-toggle { + padding: 4px 6px; + border-radius: 6px; + + label { + font-weight: bold; + margin: 0 2px; + } + + &:hover { + background: transparentize($base05, 0.88); + } +} + .wifi-header { label { font-weight: bold; diff --git a/modules/home/ags/app/widget/Bar.tsx b/modules/home/ags/app/widget/Bar.tsx index 176bbd6..e5e4c93 100644 --- a/modules/home/ags/app/widget/Bar.tsx +++ b/modules/home/ags/app/widget/Bar.tsx @@ -2,7 +2,6 @@ import { App, Astal, Gdk, Gtk } from "astal/gtk3" import Workspaces from "./Workspaces" import Logo from "./Logo" import Clock from "./Clock" -import { WifiWidget } from "./Wifi" import { BatteryWidget } from "./Battery" import QuickSettings from "./QuickSettings" @@ -55,17 +54,14 @@ function Corner({ side }: { side: "left" | "right" }) { export default function Bar(gdkmonitor: Gdk.Monitor) { const { TOP, LEFT, RIGHT } = Astal.WindowAnchor - const wifi = WifiWidget(gdkmonitor) const battery = BatteryWidget(gdkmonitor) const quicksettings = QuickSettings(gdkmonitor) const right: Array = [] - if (wifi.button) right.push(wifi.button) if (battery.button) right.push(battery.button) right.push(quicksettings.button) const popups: Array = [] - if (wifi.popup) popups.push(wifi.popup) if (battery.popup) popups.push(battery.popup) popups.push(quicksettings.popup) diff --git a/modules/home/ags/app/widget/QuickSettings.tsx b/modules/home/ags/app/widget/QuickSettings.tsx index c06dc4c..e718a5c 100644 --- a/modules/home/ags/app/widget/QuickSettings.tsx +++ b/modules/home/ags/app/widget/QuickSettings.tsx @@ -1,6 +1,7 @@ import AstalWp from "gi://AstalWp" import { execAsync, Variable, bind } from "astal" import Dropdown from "./Dropdown" +import { wifiIcon, WifiSection } from "./Wifi" const speaker = AstalWp.get_default().audio.default_speaker! const mic = AstalWp.get_default().audio.default_microphone @@ -49,6 +50,7 @@ export default function QuickSettings(gdkmonitor: Gdk.Monitor) { {micIcon && } + {wifiIcon && } ) @@ -95,6 +97,7 @@ export default function QuickSettings(gdkmonitor: Gdk.Monitor) { /> )} + ) diff --git a/modules/home/ags/app/widget/Wifi.tsx b/modules/home/ags/app/widget/Wifi.tsx index 19ce34f..de602a8 100644 --- a/modules/home/ags/app/widget/Wifi.tsx +++ b/modules/home/ags/app/widget/Wifi.tsx @@ -1,10 +1,11 @@ import Gtk from "gi://Gtk?version=3.0" import AstalNetwork from "gi://AstalNetwork" -import { type Binding, Variable, bind } from "astal" -import Dropdown from "./Dropdown" +import { type Binding, type Variable, Variable, bind } from "astal" const CONNECTING = [40, 50, 60, 70, 80, 90] +const wifi = AstalNetwork.get_default().wifi + function strongest(aps: AstalNetwork.AccessPoint[]) { const bySsid = new Map() for (const ap of aps) { @@ -15,6 +16,10 @@ function strongest(aps: AstalNetwork.AccessPoint[]) { return [...bySsid.values()].sort((a, b) => b.strength - a.strength) } +export const wifiIcon: Binding | null = wifi + ? bind(wifi, "icon-name") + : null + function WifiRow( ap: AstalNetwork.AccessPoint, activeSsid: Binding, @@ -43,12 +48,10 @@ function WifiRow( ) } -export function WifiWidget(gdkmonitor: Gdk.Monitor) { - const wifi = AstalNetwork.get_default().wifi +export function WifiSection({ open }: { open: Variable }) { + if (!wifi) return - if (!wifi) return { button: null, popup: null } - - const open = Variable(false) + const expanded = Variable(false) const pendingAP = Variable(null) const failed = Variable("") @@ -97,19 +100,34 @@ export function WifiWidget(gdkmonitor: Gdk.Monitor) { /> ) - const button = ( - - ) + open.subscribe((v) => { + if (v) { + wifi.scan() + } else { + expanded.set(false) + pendingAP.set(null) + failed.set("") + passwordEntry.text = "" + } + }) - const popup = ( - + return ( + - - + + ) - - open.subscribe((v) => { - if (v) { - wifi.scan() - } else { - pendingAP.set(null) - failed.set("") - passwordEntry.text = "" - } - }) - - return { button, popup } } \ No newline at end of file