From 2192caf8ad14679d6bbaf28b3b1890a25eb76be8 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Fri, 24 Apr 2026 01:41:01 -0700 Subject: [PATCH] qs: ethernet --- .../shell/bar/connections/Bluetooth.qml | 7 - .../shell/bar/connections/Network.qml | 163 ++++++++++++------ .../quickshell/shell/icons/ethernet-slash.svg | 1 + .../quickshell/shell/icons/ethernet-x.svg | 1 + .../quickshell/shell/icons/ethernet.svg | 1 + 5 files changed, 115 insertions(+), 58 deletions(-) create mode 100644 modules/user/modules/quickshell/shell/icons/ethernet-slash.svg create mode 100644 modules/user/modules/quickshell/shell/icons/ethernet-x.svg create mode 100644 modules/user/modules/quickshell/shell/icons/ethernet.svg diff --git a/modules/user/modules/quickshell/shell/bar/connections/Bluetooth.qml b/modules/user/modules/quickshell/shell/bar/connections/Bluetooth.qml index 3e075c2..78842a3 100644 --- a/modules/user/modules/quickshell/shell/bar/connections/Bluetooth.qml +++ b/modules/user/modules/quickshell/shell/bar/connections/Bluetooth.qml @@ -82,13 +82,6 @@ ClickableIcon { Item { Layout.fillWidth: true } - ClickableIcon { - image: root.adapter.enabled ? "root:/icons/bluetooth-slash.svg" : "root:/icons/bluetooth.svg" - implicitHeight: 24 - implicitWidth: height - onClicked: root.adapter.enabled = !root.adapter.enabled - } - ActivityButton { image: "root:/icons/binoculars.svg" implicitHeight: 24 diff --git a/modules/user/modules/quickshell/shell/bar/connections/Network.qml b/modules/user/modules/quickshell/shell/bar/connections/Network.qml index 6b6143f..b9391f9 100644 --- a/modules/user/modules/quickshell/shell/bar/connections/Network.qml +++ b/modules/user/modules/quickshell/shell/bar/connections/Network.qml @@ -11,9 +11,29 @@ import qs.bar ClickableIcon { id: root required property var bar; - readonly property WifiDevice adapter: Networking.devices.values[0] ?? null + readonly property WifiDevice adapter: Networking.devices.values.find(d => d.type === DeviceType.Wifi) + readonly property WiredDevice eth: Networking.devices.values.find(d => d.type === DeviceType.Wired) readonly property bool connected: adapter.connected readonly property WifiNetwork activeNetwork: adapter.networks.values.find(network => network.connected) + readonly property string wifiIcon: { + if (root.adapter) { + if (!Networking.wifiEnabled) return "root:/icons/wifi-slash.svg"; + if (!root.adapter.connected) return "root:/icons/wifi-x.svg"; + return `root:/icons/wifi-${Math.round(root.activeNetwork.signalStrength * 3)}.svg` + } + + return "root:/icons/wifi-x.svg"; + } + + readonly property string ethIcon: { + if (root.eth) { + if (!root.eth.network) return "root:/icons/ethernet-x.svg"; + else if (!root.eth.network.connected) return "root:/icons/ethernet-slash.svg"; + else return "root:/icons/ethernet.svg"; + } + + return "root:/icons/ethernet-x.svg"; + } property bool showMenu: false @@ -35,9 +55,17 @@ ClickableIcon { implicitHeight: width fillWindowWidth: true acceptedButtons: Qt.LeftButton | Qt.RightButton - image: Networking.wifiEnabled - ? (connected ? `root:/icons/wifi-${Math.round(root.activeNetwork.signalStrength * 3)}.svg` : "root:/icons/wifi-x.svg") - : "root:/icons/wifi-slash.svg" + image: { + if (root.eth?.network && root.eth.network.connected) { + return "root:/icons/ethernet.svg"; + } else if (Networking.wifiEnabled) { + return root.wifiIcon; + } else if (root.eth?.network) { + return "root:/icons/ethernet-slash.svg"; + } else { + return "root:/icons/ethernet-x.svg"; + } + } property var tooltip: TooltipItem { tooltip: bar.tooltip @@ -67,64 +95,97 @@ ClickableIcon { SmoothedAnimation { property: "y"; velocity: 350 } } - RowLayout { + Loader { width: parent.width + active: root.eth != null + visible: active + sourceComponent: ColumnLayout { + RowLayout { + Layout.fillWidth: true - ClickableIcon { - image: root.image - implicitHeight: 40 - implicitWidth: height - onClicked: root.adapter.enabled = !root.adapter.enabled - } + ClickableIcon { + image: root.ethIcon + implicitHeight: 40 + implicitWidth: height + onClicked: { + const n = root.eth.network; + if (n.connected) n.disconnect(); + else n.connect(); + } + } - Label { - text: `Wifi (${root.adapter.name})` - } + Label { + text: `Ethernet (${root.eth?.name ?? ""})` + } + } - Item { Layout.fillWidth: true } - - ClickableIcon { - image: Networking.wifiEnabled ? "root:/icons/wifi-slash.svg" : "root:/icons/wifi-x.svg" - implicitHeight: 24 - implicitWidth: height - onClicked: Networking.wifiEnabled = !Networking.wifiEnabled - } - - ActivityButton { - image: "root:/icons/binoculars.svg" - implicitHeight: 24 - implicitWidth: height - onClicked: root.adapter.scannerEnabled = !root.adapter.scannerEnabled - showAction: root.adapter.scannerEnabled - Layout.rightMargin: 4 + Rectangle { + Layout.fillWidth: true + implicitHeight: 1 + color: ShellGlobals.colors.separator + visible: root.adapter != null + } } } - Rectangle { + Loader { width: parent.width - implicitHeight: 1 - visible: root.adapter.networks.values.length > 0 + active: root.adapter != null + visible: active + sourceComponent: ColumnLayout { + RowLayout { + Layout.fillWidth: true + ClickableIcon { + image: root.wifiIcon + implicitHeight: 40 + implicitWidth: height + onClicked: Networking.wifiEnabled = !Networking.wifiEnabled + } - color: ShellGlobals.colors.separator - } + Label { + text: `Wifi (${root.adapter.name})` + } - Repeater { - model: ScriptModel { - values: [...root.adapter.networks.values].sort((a, b) => { - if (a.connected && !b.connected) return -1; - if (b.connected && !a.connected) return 1; - if (a.bonded && !b.bonded) return -1; - if (b.bonded && !a.bonded) return 1; - return b.name - a.name; - }) - } + Item { Layout.fillWidth: true } - delegate: NetworkDelegate { - required property var modelData - device: root.adapter - network: modelData - width: parent.width - onConnectionAttempted: root.adapter.scannerEnabled = false + ActivityButton { + image: "root:/icons/binoculars.svg" + implicitHeight: 24 + implicitWidth: height + onClicked: root.adapter.scannerEnabled = !root.adapter.scannerEnabled + showAction: root.adapter.scannerEnabled + Layout.rightMargin: 4 + } + } + + Rectangle { + Layout.fillWidth: parent + implicitHeight: 1 + visible: root.adapter.networks.values.length > 0 + + color: ShellGlobals.colors.separator + } + + Repeater { + model: ScriptModel { + values: [...root.adapter.networks.values].sort((a, b) => { + if (a.connected && !b.connected) return -1; + if (b.connected && !a.connected) return 1; + if (a.bonded && !b.bonded) return -1; + if (b.bonded && !a.bonded) return 1; + return b.name - a.name; + }) + } + + delegate: NetworkDelegate { + required property var modelData + Layout.fillWidth: parent + device: root.adapter + network: modelData + width: parent.width + onConnectionAttempted: root.adapter.scannerEnabled = false + } + } } } } diff --git a/modules/user/modules/quickshell/shell/icons/ethernet-slash.svg b/modules/user/modules/quickshell/shell/icons/ethernet-slash.svg new file mode 100644 index 0000000..940ed38 --- /dev/null +++ b/modules/user/modules/quickshell/shell/icons/ethernet-slash.svg @@ -0,0 +1 @@ + diff --git a/modules/user/modules/quickshell/shell/icons/ethernet-x.svg b/modules/user/modules/quickshell/shell/icons/ethernet-x.svg new file mode 100644 index 0000000..cdee1a8 --- /dev/null +++ b/modules/user/modules/quickshell/shell/icons/ethernet-x.svg @@ -0,0 +1 @@ + diff --git a/modules/user/modules/quickshell/shell/icons/ethernet.svg b/modules/user/modules/quickshell/shell/icons/ethernet.svg new file mode 100644 index 0000000..403d18d --- /dev/null +++ b/modules/user/modules/quickshell/shell/icons/ethernet.svg @@ -0,0 +1 @@ +