From dbfedc2cb8745195e1f9d6d76443d453761dcab5 Mon Sep 17 00:00:00 2001 From: lucy Date: Sat, 14 Feb 2026 12:33:31 +0100 Subject: [PATCH] switch to just icons --- modules/bar/Bar.qml | 5 +- modules/bar/Battery.qml | 88 ------------------ modules/bar/Network.qml | 95 ------------------- modules/bar/StatusIcons.qml | 181 ++++++++++++++++++++++++++++++++++++ modules/bar/Volume.qml | 69 -------------- modules/bar/Workspaces.qml | 2 +- reusables/CustomIcon.qml | 2 +- 7 files changed, 184 insertions(+), 258 deletions(-) delete mode 100644 modules/bar/Battery.qml delete mode 100644 modules/bar/Network.qml create mode 100644 modules/bar/StatusIcons.qml delete mode 100644 modules/bar/Volume.qml diff --git a/modules/bar/Bar.qml b/modules/bar/Bar.qml index d34c224..1a52b9a 100644 --- a/modules/bar/Bar.qml +++ b/modules/bar/Bar.qml @@ -59,11 +59,8 @@ Variants { clip: true anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter - Network {} - Volume {} - Battery {} SysTray {} - SettingsIcon {} + StatusIcons {} } } } diff --git a/modules/bar/Battery.qml b/modules/bar/Battery.qml deleted file mode 100644 index cbfa866..0000000 --- a/modules/bar/Battery.qml +++ /dev/null @@ -1,88 +0,0 @@ -import Quickshell.Services.UPower -import QtQuick.Layouts -import QtQuick -import Quickshell.Widgets -import Qt5Compat.GraphicalEffects -import Quickshell -import qs -import qs.reusables -import qs.settings - -Loader { - id: batLoader - active: UPower.displayDevice.isLaptopBattery - - sourceComponent: Rectangle { - id: container - radius: implicitHeight / 2 - color: Colors.surfaceContainer - anchors.verticalCenter: parent.verticalCenter - implicitWidth: UPower.displayDevice.isLaptopBattery ? root.implicitWidth + 20 : 0 - implicitHeight: Settings.config.barHeight - 10 - Item { - id: root - anchors.centerIn: parent - - property bool frame1: UPower.displayDevice.percentage <= 0.16 - property bool frame2: UPower.displayDevice.percentage < 0.32 - property bool frame3: UPower.displayDevice.percentage < 0.48 - property bool frame4: UPower.displayDevice.percentage < 0.74 - property bool frame5: UPower.displayDevice.percentage < 0.90 - property bool frame6: UPower.displayDevice.percentage <= 1 - - function getBatteryIcon() { - if (UPower.displayDevice.state == UPowerDeviceState.Charging) { - return "battery_android_frame_bolt"; - } - if (frame1) { - return "battery_android_frame_1"; - } - if (frame2) { - return "battery_android_frame_2"; - } - if (frame3) { - return "battery_android_frame_3"; - } - if (frame4) { - return "battery_android_frame_4"; - } - if (frame5) { - return "battery_android_frame_5"; - } - if (frame6) { - return "battery_android_frame_full"; - } - } - function getProfileIcon() { - if (PowerProfiles.profile.toString() == "2") { - return "power-profile-performance-symbolic"; - } - if (PowerProfiles.profile.toString() == "1") { - return "power-profile-balanced-symbolic"; - } - if (PowerProfiles.profile.toString() == "0") { - return "power-profile-power-saver-symbolic"; - } - } - - implicitWidth: batRow.width - implicitHeight: Settings.config.barHeight - - RowLayout { - id: batRow - anchors.centerIn: parent - height: parent.height - spacing: 5 - CustomText { - id: batText - - text: Math.round(UPower.displayDevice.percentage * 100) + "%" - } - CustomIcon { - id: batIcon - text: root.getBatteryIcon() - } - } - } - } -} diff --git a/modules/bar/Network.qml b/modules/bar/Network.qml deleted file mode 100644 index ba4cc74..0000000 --- a/modules/bar/Network.qml +++ /dev/null @@ -1,95 +0,0 @@ -pragma ComponentBehavior: Bound -import Quickshell.Networking -import QtQuick -import QtQuick.Layouts -import qs.reusables -import qs.settings -import qs - -Rectangle { - id: root - // This is the background of the entire bar/module - // You might want to make this transparent if you only want the "pills" to show - implicitHeight: Settings.config.barHeight - 10 - implicitWidth: mainLayout.implicitWidth + 20 - color: Colors.surfaceContainer - radius: implicitHeight / 2 - - // --- Logic Functions --- - function getIcon(device) { - if (device.type === DeviceType.Wifi) { - for (var i = 0; i < device.networks.values.length; i++) { - var net = device.networks.values[i]; - if (net.connected) { - if (net.signalStrength <= 0.20) - return "\uf0b0"; - //signa_wifi_0_bar - if (net.signalStrength <= 0.40) - return "\uebe4"; - //network_wifi_1_bar - if (net.signalStrength <= 0.60) - return "\uebd6"; - //network_wifi_2_bar - if (net.signalStrength <= 0.80) - return "\uebe1"; - //network_wifi_3_bar - if (net.signalStrength >= 0.80) - return "\ue1d8"; - // signal_wifi_4_bar - } - } - return "\ue1da"; - } else if (device.connected) { - return "settings_ethernet"; - } - return "\ue1da"; - // signal_wifi_off - } - - function getStatus(device) { - if (device.type === DeviceType.Wifi) { - for (var i = 0; i < device.networks.values.length; i++) { - var net = device.networks.values[i]; - if (net.connected) { - return net.name; - } - } - return "Disconnected"; - } - return device.connected ? "Connected" : "Disconnected"; - } - - // --- Main Layout --- - RowLayout { - id: mainLayout - anchors.centerIn: parent - spacing: 10 // Space between multiple device pills (if you have ethernet + wifi) - - Repeater { - id: netRepeater - model: Networking.devices - - delegate: RowLayout { - id: innerContent - required property var modelData - // THIS fixes the centering issue: - spacing: 8 - - CustomIcon { - id: netIcon - Layout.alignment: Qt.AlignVCenter - text: root.getIcon(innerContent.modelData) - } - - CustomText { - id: netText - Layout.topMargin: 1 - Layout.alignment: Qt.AlignVCenter - text: root.getStatus(innerContent.modelData) - // Ensures the text font aligns vertically within its own line-height - verticalAlignment: Text.AlignVCenter - } - } - } - } -} diff --git a/modules/bar/StatusIcons.qml b/modules/bar/StatusIcons.qml new file mode 100644 index 0000000..985d4b0 --- /dev/null +++ b/modules/bar/StatusIcons.qml @@ -0,0 +1,181 @@ +pragma ComponentBehavior: Bound +import Quickshell +import Quickshell.Io +import Quickshell.Services.Pipewire +import Quickshell.Networking +import Quickshell.Services.UPower +import QtQuick +import QtQuick.Layouts +import qs +import qs.reusables +import qs.settings + +Rectangle { + id: root + implicitWidth: statusLayout.implicitWidth + 10 + implicitHeight: Settings.config.barHeight - 10 + color: Colors.surfaceContainer + radius: implicitHeight / 2 + property var sink: Pipewire.defaultAudioSink + property var sinkReady: Pipewire.defaultAudioSink.ready + property var bat: UPower.displayDevice + Process { + id: lowBat + running: false + command: ["sh", "-c", "notify-send", "'Low battery!'", "'Plug in your device!'"] + } + // wifi functions + function getIcon(device) { + if (device.type === DeviceType.Wifi) { + for (var i = 0; i < device.networks.values.length; i++) { + var net = device.networks.values[i]; + if (net.connected) { + if (net.signalStrength <= 0.20) + return "\uf0b0"; + //signa_wifi_0_bar + if (net.signalStrength <= 0.40) + return "\uebe4"; + //network_wifi_1_bar + if (net.signalStrength <= 0.60) + return "\uebd6"; + //network_wifi_2_bar + if (net.signalStrength <= 0.80) + return "\uebe1"; + //network_wifi_3_bar + if (net.signalStrength >= 0.80) + return "\ue1d8"; + // signal_wifi_4_bar + } + } + return "\ue1da"; + } else if (device.connected) { + return "settings_ethernet"; + } + return "\ue1da"; + // signal_wifi_off + } + + property bool frame1: UPower.displayDevice.percentage <= 0.16 + property bool frame2: UPower.displayDevice.percentage < 0.32 + property bool frame3: UPower.displayDevice.percentage < 0.48 + property bool frame4: UPower.displayDevice.percentage < 0.74 + property bool frame5: UPower.displayDevice.percentage < 0.90 + property bool frame6: UPower.displayDevice.percentage <= 1 + function getBatteryIcon() { + if (UPower.displayDevice.state == UPowerDeviceState.Charging) { + return "battery_android_frame_bolt"; + } + if (frame1) { + lowBat.running = true; + return "battery_android_frame_1"; + } + if (frame2) { + return "battery_android_frame_2"; + } + if (frame3) { + return "battery_android_frame_3"; + } + if (frame4) { + return "battery_android_frame_4"; + } + if (frame5) { + return "battery_android_frame_5"; + } + if (frame6) { + return "battery_android_frame_full"; + } + } + + function getStatus(device) { + if (device.type === DeviceType.Wifi) { + for (var i = 0; i < device.networks.values.length; i++) { + var net = device.networks.values[i]; + if (net.connected) { + return net.name; + } + } + return "Disconnected"; + } + return device.connected ? "Connected" : "Disconnected"; + } + // pipewire function + function getVolumeIcon() { + // Safety check: if Pipewire is dead or sink is missing + if (!sink) + return "volume_off"; + + // If muted, show the hush icon + if (sink.audio.muted) + return "volume_off"; + + // Volume is usually 0.0 to 1.0 (0% to 100%) + const vol = sink.audio.volume; + + if (vol <= 0.25) + return "volume_mute"; + if (vol < 0.75) + return "volume_down"; + if (vol <= 1.00) + return "volume_up"; + + // If it's loud, prepare the ears! + return "volume_up"; + } + RowLayout { + id: statusLayout + anchors.centerIn: parent + spacing: 10 + CustomIcon { + id: volumeIcon + Layout.alignment: Qt.AlignVCenter + PwObjectTracker { + objects: Pipewire.ready ? Pipewire.defaultAudioSink : [] + } + text: root.getVolumeIcon() + MouseArea { + id: pavuArea + Process { + id: pavuLauncher + command: ["sh", "-c", "pavucontrol"] + } + anchors.fill: parent + onClicked: pavuLauncher.exec(pavuLauncher.command) + acceptedButtons: Qt.LeftButton + cursorShape: Qt.PointingHandCursor + hoverEnabled: true + } + } + + Repeater { + id: netRepeater + Layout.alignment: Qt.AlignVCenter + model: Networking.devices + + delegate: CustomIcon { + id: netIcon + Layout.alignment: Qt.AlignVCenter + required property var modelData + text: root.getIcon(modelData) + } + } + CustomIcon { + id: batIcon + Layout.alignment: Qt.AlignVCenter + text: root.getBatteryIcon() + } + CustomIcon { + id: settingsIcon + text: "settings" + MouseArea { + id: settingsArea + anchors.fill: settingsIcon + onClicked: { + Settings.config.settingsShown = true; + } + acceptedButtons: Qt.LeftButton + cursorShape: Qt.PointingHandCursor + hoverEnabled: true + } + } + } +} diff --git a/modules/bar/Volume.qml b/modules/bar/Volume.qml deleted file mode 100644 index 3237cee..0000000 --- a/modules/bar/Volume.qml +++ /dev/null @@ -1,69 +0,0 @@ -import Quickshell.Io -import QtQuick.Layouts -import QtQuick -import Quickshell.Services.Pipewire -import qs.settings -import qs.reusables -import qs - -Rectangle { - id: root - radius: implicitHeight / 2 - color: pavuArea.containsMouse ? Colors.primaryContainer : Colors.surfaceContainer - implicitWidth: textRow.implicitWidth + 20 - implicitHeight: Settings.config.barHeight - 10 - property var sink: Pipewire.defaultAudioSink - function getVolumeIcon() { - // Safety check: if Pipewire is dead or sink is missing - if (!sink) - return "volume_off"; - - // If muted, show the hush icon - if (sink.audio.muted) - return "volume_off"; - - // Volume is usually 0.0 to 1.0 (0% to 100%) - const vol = sink.audio.volume; - - if (vol <= 0.25) - return "volume_mute"; - if (vol < 0.75) - return "volume_down"; - if (vol <= 1.00) - return "volume_up"; - - // If it's loud, prepare the ears! - return "volume_up"; - } - RowLayout { - id: textRow - spacing: 2 - anchors.centerIn: parent - height: parent.height - CustomText { - id: volumeText - PwObjectTracker { - objects: Pipewire.ready ? Pipewire.defaultAudioSink : [] - } - text: Pipewire.ready ? Math.round(root.sink.audio.volume * 100) + "%" : "failure" - opacity: Pipewire.ready ? root.sink.audio.muted ? 0.5 : 1 : 0 - } - CustomIcon { - id: volumeIcon - opacity: Pipewire.ready ? root.sink.audio.muted ? 0.5 : 1 : 0 - text: Pipewire.ready ? root.getVolumeIcon() : null - } - } - MouseArea { - id: pavuArea - Process { - id: pavuLauncher - command: ["sh", "-c", "pavucontrol"] - } - anchors.fill: parent - onClicked: pavuLauncher.exec(pavuLauncher.command) - acceptedButtons: Qt.LeftButton - cursorShape: Qt.PointingHandCursor - hoverEnabled: true - } -} diff --git a/modules/bar/Workspaces.qml b/modules/bar/Workspaces.qml index 3754146..84a1cc0 100644 --- a/modules/bar/Workspaces.qml +++ b/modules/bar/Workspaces.qml @@ -38,7 +38,7 @@ Rectangle { } required property var modelData - width: Settings.config.barHeight - 5 + width: Settings.config.barHeight - 8 height: Settings.config.barHeight - 10 color: modelData.focused ? Colors.primaryContainer : "transparent" Behavior on width { diff --git a/reusables/CustomIcon.qml b/reusables/CustomIcon.qml index ba9760b..d0aad4e 100644 --- a/reusables/CustomIcon.qml +++ b/reusables/CustomIcon.qml @@ -12,7 +12,7 @@ Text { font { hintingPreference: Font.PreferNoHinting family: "Material Symbols Rounded" - pixelSize: Settings.config.fontSize + pixelSize: iconSize weight: Font.Normal + (Font.DemiBold - Font.Normal) * truncatedFill variableAxes: { "FILL": truncatedFill,