From 8c01563c46e1ab19bc7a1adf55ff9fcff7de66a3 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 17 May 2026 17:59:50 +0200 Subject: [PATCH] Don't need notifications for changes that are obvious --- bin/omarchy-hyprland-monitor-scaling-set | 2 - .../plugins/bar/widgets/networkPanel.qml | 132 +++++++++++++++++- 2 files changed, 131 insertions(+), 3 deletions(-) diff --git a/bin/omarchy-hyprland-monitor-scaling-set b/bin/omarchy-hyprland-monitor-scaling-set index c55c6a1d..056326f6 100755 --- a/bin/omarchy-hyprland-monitor-scaling-set +++ b/bin/omarchy-hyprland-monitor-scaling-set @@ -41,5 +41,3 @@ elif [[ -f $MONITOR_LUA ]] && grep -Eq '^hl\.monitor\(\{ output = "", mode = "pr -e 's|^hl\.env\("GDK_SCALE", ".*"\)|hl.env("GDK_SCALE", "'"$NEW_GDK_SCALE"'")|' \ "$MONITOR_LUA" fi - -notify-send -a omarchy-action -u low "󰍹 Display scaling set to ${NEW_SCALE}x" diff --git a/default/quickshell/omarchy-shell/plugins/bar/widgets/networkPanel.qml b/default/quickshell/omarchy-shell/plugins/bar/widgets/networkPanel.qml index 924f5db3..99b7c0b4 100644 --- a/default/quickshell/omarchy-shell/plugins/bar/widgets/networkPanel.qml +++ b/default/quickshell/omarchy-shell/plugins/bar/widgets/networkPanel.qml @@ -19,6 +19,8 @@ Item { property var wifiNetworks: [] property bool scanning: false property bool wifiStationAvailable: false + property string dnsProvider: "" + property string pendingDnsProvider: "" readonly property string kind: bar ? bar.networkKind : "disconnected" readonly property string label: bar ? bar.networkLabel : "" @@ -36,6 +38,7 @@ Item { function refresh() { if (!detailsProc.running) detailsProc.running = true + if (!dnsProc.running) dnsProc.running = true if (!wifiProc.running) { scanning = true wifiProc.running = true @@ -101,6 +104,31 @@ Item { return icons[index] } + function updateDns(raw) { + var value = String(raw || "").trim() + dnsProvider = value || "DHCP" + } + + function dnsCommand(provider) { + return "pkexec " + root.bar.shellQuote(root.bar.omarchyPath + "/bin/omarchy-setup-dns") + " " + root.bar.shellQuote(provider) + } + + function setDns(provider) { + if (!root.bar || !provider || actionProc.running) return + + if (provider === "Custom") { + var launcher = root.bar.shellQuote(root.bar.omarchyPath + "/bin/omarchy-launch-floating-terminal-with-presentation") + root.bar.run(launcher + " " + root.bar.shellQuote(root.dnsCommand(provider))) + root.popupOpen = false + return + } + + root.pendingDnsProvider = provider + actionProc.command = ["bash", "-lc", root.dnsCommand(provider)] + actionProc.running = true + root.popupOpen = false + } + implicitWidth: button.implicitWidth implicitHeight: button.implicitHeight @@ -178,7 +206,36 @@ iwctl station "$station" get-networks rssi-dbms 2>/dev/null \\ } } - Process { id: actionProc } + Process { + id: dnsProc + command: ["bash", "-c", ` +dns=$(awk -F= '/^[[:space:]]*DNS[[:space:]]*=/ { value=$0; sub(/^[^=]*=/, "", value); print value; exit }' /etc/systemd/resolved.conf 2>/dev/null) +compact=$(printf '%s' "$dns" | tr -d '[:space:]') +if [[ -z $compact ]]; then + echo DHCP +elif [[ $dns == *cloudflare-dns.com* || $dns == *"1.1.1.1"* || $dns == *"2606:4700:4700::1111"* ]]; then + echo Cloudflare +elif [[ $dns == *dns.google* || $dns == *"8.8.8.8"* || $dns == *"2001:4860:4860::8888"* ]]; then + echo Google +else + echo Custom +fi +`] + stdout: StdioCollector { + waitForEnd: true + onStreamFinished: root.updateDns(text) + } + } + + Process { + id: actionProc + onExited: function(exitCode) { + if (root.pendingDnsProvider !== "") { + if (exitCode === 0) root.dnsProvider = root.pendingDnsProvider + root.pendingDnsProvider = "" + } + } + } Common.WidgetButton { id: button @@ -372,6 +429,79 @@ iwctl station "$station" get-networks rssi-dbms 2>/dev/null \\ } } + // DNS provider selection. + Rectangle { + width: parent.width + height: 1 + color: Qt.rgba(root.bar.foreground.r, root.bar.foreground.g, root.bar.foreground.b, 0.12) + } + + Column { + width: parent.width + spacing: 8 + + Text { + text: "DNS provider" + color: Qt.darker(root.bar.foreground, 1.4) + font.family: root.bar.fontFamily + font.pixelSize: 10 + font.bold: true + } + + Row { + width: parent.width + spacing: 6 + + Common.PillButton { + text: "DHCP" + tooltipText: "Use DNS from DHCP" + tooltipBackground: root.bar.background + tooltipForeground: root.bar.foreground + foreground: root.bar.foreground + horizontalPadding: 10 + verticalPadding: 6 + active: root.dnsProvider === "DHCP" + onClicked: root.setDns("DHCP") + } + + Common.PillButton { + text: "Cloudflare" + tooltipText: "Set DNS to Cloudflare" + tooltipBackground: root.bar.background + tooltipForeground: root.bar.foreground + foreground: root.bar.foreground + horizontalPadding: 10 + verticalPadding: 6 + active: root.dnsProvider === "Cloudflare" + onClicked: root.setDns("Cloudflare") + } + + Common.PillButton { + text: "Google" + tooltipText: "Set DNS to Google" + tooltipBackground: root.bar.background + tooltipForeground: root.bar.foreground + foreground: root.bar.foreground + horizontalPadding: 10 + verticalPadding: 6 + active: root.dnsProvider === "Google" + onClicked: root.setDns("Google") + } + + Common.PillButton { + text: "Custom" + tooltipText: "Set custom DNS servers" + tooltipBackground: root.bar.background + tooltipForeground: root.bar.foreground + foreground: root.bar.foreground + horizontalPadding: 10 + verticalPadding: 6 + active: root.dnsProvider === "Custom" + onClicked: root.setDns("Custom") + } + } + } + // Wi-Fi networks (only if a Wi-Fi station is available). Rectangle { visible: root.wifiStationAvailable