switch to just icons

This commit is contained in:
lucy 2026-02-14 12:33:31 +01:00
parent f52d54175a
commit dbfedc2cb8
7 changed files with 184 additions and 258 deletions

View File

@ -59,11 +59,8 @@ Variants {
clip: true
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
Network {}
Volume {}
Battery {}
SysTray {}
SettingsIcon {}
StatusIcons {}
}
}
}

View File

@ -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()
}
}
}
}
}

View File

@ -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
}
}
}
}
}

181
modules/bar/StatusIcons.qml Normal file
View File

@ -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
}
}
}
}

View File

@ -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
}
}

View File

@ -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 {

View File

@ -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,