diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-29 14:56:39 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-29 14:56:39 +1000 |
| commit | fa5b31292401a80484ff6f81a5b68603b3889428 (patch) | |
| tree | ce3470c70e2785589ef315a5c9981e445a0e05df | |
| parent | style: remove unneeded comments (diff) | |
| download | caelestia-shell-fa5b31292401a80484ff6f81a5b68603b3889428.tar.gz caelestia-shell-fa5b31292401a80484ff6f81a5b68603b3889428.tar.bz2 caelestia-shell-fa5b31292401a80484ff6f81a5b68603b3889428.zip | |
feat: bar network icon
| -rw-r--r-- | modules/bar/Pills.qml | 12 | ||||
| -rw-r--r-- | modules/bar/components/ActiveWindow.qml | 1 | ||||
| -rw-r--r-- | modules/bar/components/Clock.qml | 1 | ||||
| -rw-r--r-- | modules/bar/components/StatusIcons.qml | 18 | ||||
| -rw-r--r-- | services/Network.qml | 44 | ||||
| -rw-r--r-- | utils/Icons.qml | 14 |
6 files changed, 87 insertions, 3 deletions
diff --git a/modules/bar/Pills.qml b/modules/bar/Pills.qml index 2d6dfda..bf20f05 100644 --- a/modules/bar/Pills.qml +++ b/modules/bar/Pills.qml @@ -60,11 +60,23 @@ Item { anchors.right: parent.right Clock { + id: clock + vertical: BarConfig.vertical anchors.horizontalCenter: root.get(undefined, parent.horizontalCenter) anchors.verticalCenter: root.get(parent.verticalCenter, undefined) } + + StatusIcons { + anchors.left: root.get(clock.right, undefined) + anchors.leftMargin: root.get(Appearance.padding.smaller, 0) + anchors.top: root.get(undefined, clock.bottom) + anchors.topMargin: root.get(0, Appearance.padding.smaller) + + anchors.horizontalCenter: root.get(undefined, parent.horizontalCenter) + anchors.verticalCenter: root.get(parent.verticalCenter, undefined) + } } } diff --git a/modules/bar/components/ActiveWindow.qml b/modules/bar/components/ActiveWindow.qml index 40f7a64..1a2d5a5 100644 --- a/modules/bar/components/ActiveWindow.qml +++ b/modules/bar/components/ActiveWindow.qml @@ -3,7 +3,6 @@ import "root:/services" import "root:/utils" import "root:/config" import QtQuick -import QtQuick.Layouts StyledRect { id: root diff --git a/modules/bar/components/Clock.qml b/modules/bar/components/Clock.qml index 9743be4..91e978c 100644 --- a/modules/bar/components/Clock.qml +++ b/modules/bar/components/Clock.qml @@ -2,7 +2,6 @@ import "root:/widgets" import "root:/services" import "root:/config" import QtQuick -import QtQuick.Layouts StyledRect { id: root diff --git a/modules/bar/components/StatusIcons.qml b/modules/bar/components/StatusIcons.qml new file mode 100644 index 0000000..d3df67d --- /dev/null +++ b/modules/bar/components/StatusIcons.qml @@ -0,0 +1,18 @@ +import "root:/widgets" +import "root:/services" +import "root:/utils" +import "root:/config" +import QtQuick + +StyledRect { + id: root + + readonly property color colour: Appearance.colours.rosewater + + MaterialIcon { + id: icon + + text: Icons.getNetworkIcon(Network.active.strength) + color: root.colour + } +} diff --git a/services/Network.qml b/services/Network.qml new file mode 100644 index 0000000..93c8d50 --- /dev/null +++ b/services/Network.qml @@ -0,0 +1,44 @@ +pragma Singleton + +import Quickshell +import Quickshell.Io +import QtQuick + +Singleton { + id: root + + readonly property AccessPoint active: AccessPoint { + active: true + } + + Process { + running: true + command: ["nmcli", "m"] + stdout: SplitParser { + onRead: getNetworks.running = true + } + } + + Process { + id: getNetworks + running: true + command: ["nmcli", "-g", "ACTIVE,SIGNAL,FREQ,SSID", "d", "w"] + stdout: SplitParser { + onRead: data => { + const [active, strength, frequency, ssid] = data.split(":"); + if (active === "yes") { + root.active.ssid = ssid; + root.active.strength = parseInt(strength); + root.active.frequency = parseInt(frequency); + } + } + } + } + + component AccessPoint: QtObject { + property string ssid + property int strength + property int frequency + property bool active + } +} diff --git a/utils/Icons.qml b/utils/Icons.qml index 1f0a947..ac19b4e 100644 --- a/utils/Icons.qml +++ b/utils/Icons.qml @@ -152,7 +152,7 @@ Singleton { property string osIcon: "" - function getAppCategoryIcon(name) { + function getAppCategoryIcon(name: string): string { if (!name) return null; @@ -165,6 +165,18 @@ Singleton { return "terminal"; } + function getNetworkIcon(strength: int): string { + if (strength >= 80) + return "signal_wifi_4_bar"; + if (strength >= 60) + return "network_wifi_3_bar"; + if (strength >= 40) + return "network_wifi_2_bar"; + if (strength >= 20) + return "network_wifi_1_bar"; + return "signal_wifi_0_bar"; + } + FileView { path: "/etc/os-release" onLoaded: { |