diff --git a/modules/Bluetooth.qml b/modules/Bluetooth.qml index 7e74c1f..43582b4 100644 --- a/modules/Bluetooth.qml +++ b/modules/Bluetooth.qml @@ -35,7 +35,7 @@ M.BarSection { Process { id: proc - running: true + running: M.Modules.bluetooth.enable command: ["sh", "-c", "s=$(bluetoothctl show 2>/dev/null); " + "[ -z \"$s\" ] && echo unavailable && exit; " + "echo \"$s\" | grep -q 'Powered: yes' || { echo off:; exit; }; " + "info=$(bluetoothctl info 2>/dev/null); " + "d=$(echo \"$info\" | awk -F': ' '/\\tName:/{n=$2}/Connected: yes/{c=1}END{if(c)print n}'); " + "[ -n \"$d\" ] && echo \"connected:$d\" || { echo on:; exit; }; " + "bat=$(echo \"$info\" | awk -F': ' '/Battery Percentage.*\\(/{gsub(/[^0-9]/,\"\",$2);print $2}'); " + "[ -n \"$bat\" ] && echo \"bat:$bat\""] stdout: StdioCollector { onStreamFinished: root._parse(text) @@ -44,7 +44,7 @@ M.BarSection { // Event-driven: watch BlueZ DBus property changes Process { id: btMonitor - running: true + running: M.Modules.bluetooth.enable command: ["sh", "-c", "dbus-monitor --system \"interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',path_namespace='/org/bluez'\" 2>/dev/null"] stdout: SplitParser { splitMarker: "\n" @@ -58,7 +58,7 @@ M.BarSection { } Timer { interval: 60000 - running: true + running: M.Modules.bluetooth.enable repeat: true onTriggered: proc.running = true } diff --git a/modules/Network.qml b/modules/Network.qml index 033c0ab..adff5df 100644 --- a/modules/Network.qml +++ b/modules/Network.qml @@ -16,7 +16,7 @@ M.BarSection { Process { id: proc - running: true + running: M.Modules.network.enable command: ["sh", "-c", "line=$(nmcli -t -f NAME,TYPE,DEVICE connection show --active 2>/dev/null | head -1); if [ -z \"$line\" ]; then dev=$(nmcli -t -f DEVICE,STATE device 2>/dev/null | grep ':connected' | grep -v ':unmanaged\\|:unavailable\\|:disconnected\\|:connecting' | head -1 | cut -d: -f1); [ -n \"$dev\" ] && line=\"linked:linked:$dev\"; fi; [ -z \"$line\" ] && exit 0; echo \"$line\"; dev=$(echo \"$line\" | cut -d: -f3); ip=$(nmcli -t -f IP4.ADDRESS device show \"$dev\" 2>/dev/null | head -1 | cut -d: -f2); echo \"ip:${ip:-}\"; sig=$(nmcli -t -f GENERAL.SIGNAL device show \"$dev\" 2>/dev/null | head -1 | cut -d: -f2); echo \"sig:${sig:-}\""] stdout: StdioCollector { onStreamFinished: { @@ -53,7 +53,7 @@ M.BarSection { // Event-driven: re-poll on any network change Process { id: monitor - running: true + running: M.Modules.network.enable command: ["nmcli", "monitor"] stdout: SplitParser { splitMarker: "\n" @@ -71,7 +71,7 @@ M.BarSection { // Fallback poll Timer { interval: 60000 - running: true + running: M.Modules.network.enable repeat: true onTriggered: proc.running = true } diff --git a/modules/PowerProfileService.qml b/modules/PowerProfileService.qml index 185745f..2c11f65 100644 --- a/modules/PowerProfileService.qml +++ b/modules/PowerProfileService.qml @@ -2,6 +2,7 @@ pragma Singleton import QtQuick import Quickshell.Io +import "." as M QtObject { id: root @@ -10,7 +11,7 @@ QtObject { readonly property bool powerSaver: profile === "power-saver" property var _proc: Process { - running: true + running: M.Modules.powerProfile.enable command: ["powerprofilesctl", "get"] stdout: StdioCollector { onStreamFinished: root.profile = text.trim() @@ -18,7 +19,7 @@ QtObject { } property var _monitor: Process { - running: true + running: M.Modules.powerProfile.enable command: ["sh", "-c", "dbus-monitor --system \"interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',path='/net/hadess/PowerProfiles'\" 2>/dev/null"] stdout: SplitParser { splitMarker: "\n" @@ -33,7 +34,7 @@ QtObject { property var _poll: Timer { interval: 60000 - running: true + running: M.Modules.powerProfile.enable repeat: true onTriggered: root._proc.running = true }