gate network/bluetooth/powerprofile processes on module enable flag
This commit is contained in:
parent
25bc3954cb
commit
208a9023b8
3 changed files with 10 additions and 9 deletions
|
|
@ -35,7 +35,7 @@ M.BarSection {
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: proc
|
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\""]
|
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 {
|
stdout: StdioCollector {
|
||||||
onStreamFinished: root._parse(text)
|
onStreamFinished: root._parse(text)
|
||||||
|
|
@ -44,7 +44,7 @@ M.BarSection {
|
||||||
// Event-driven: watch BlueZ DBus property changes
|
// Event-driven: watch BlueZ DBus property changes
|
||||||
Process {
|
Process {
|
||||||
id: btMonitor
|
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"]
|
command: ["sh", "-c", "dbus-monitor --system \"interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',path_namespace='/org/bluez'\" 2>/dev/null"]
|
||||||
stdout: SplitParser {
|
stdout: SplitParser {
|
||||||
splitMarker: "\n"
|
splitMarker: "\n"
|
||||||
|
|
@ -58,7 +58,7 @@ M.BarSection {
|
||||||
}
|
}
|
||||||
Timer {
|
Timer {
|
||||||
interval: 60000
|
interval: 60000
|
||||||
running: true
|
running: M.Modules.bluetooth.enable
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: proc.running = true
|
onTriggered: proc.running = true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ M.BarSection {
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: proc
|
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:-}\""]
|
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 {
|
stdout: StdioCollector {
|
||||||
onStreamFinished: {
|
onStreamFinished: {
|
||||||
|
|
@ -53,7 +53,7 @@ M.BarSection {
|
||||||
// Event-driven: re-poll on any network change
|
// Event-driven: re-poll on any network change
|
||||||
Process {
|
Process {
|
||||||
id: monitor
|
id: monitor
|
||||||
running: true
|
running: M.Modules.network.enable
|
||||||
command: ["nmcli", "monitor"]
|
command: ["nmcli", "monitor"]
|
||||||
stdout: SplitParser {
|
stdout: SplitParser {
|
||||||
splitMarker: "\n"
|
splitMarker: "\n"
|
||||||
|
|
@ -71,7 +71,7 @@ M.BarSection {
|
||||||
// Fallback poll
|
// Fallback poll
|
||||||
Timer {
|
Timer {
|
||||||
interval: 60000
|
interval: 60000
|
||||||
running: true
|
running: M.Modules.network.enable
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: proc.running = true
|
onTriggered: proc.running = true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ pragma Singleton
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
|
import "." as M
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: root
|
id: root
|
||||||
|
|
@ -10,7 +11,7 @@ QtObject {
|
||||||
readonly property bool powerSaver: profile === "power-saver"
|
readonly property bool powerSaver: profile === "power-saver"
|
||||||
|
|
||||||
property var _proc: Process {
|
property var _proc: Process {
|
||||||
running: true
|
running: M.Modules.powerProfile.enable
|
||||||
command: ["powerprofilesctl", "get"]
|
command: ["powerprofilesctl", "get"]
|
||||||
stdout: StdioCollector {
|
stdout: StdioCollector {
|
||||||
onStreamFinished: root.profile = text.trim()
|
onStreamFinished: root.profile = text.trim()
|
||||||
|
|
@ -18,7 +19,7 @@ QtObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
property var _monitor: Process {
|
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"]
|
command: ["sh", "-c", "dbus-monitor --system \"interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',path='/net/hadess/PowerProfiles'\" 2>/dev/null"]
|
||||||
stdout: SplitParser {
|
stdout: SplitParser {
|
||||||
splitMarker: "\n"
|
splitMarker: "\n"
|
||||||
|
|
@ -33,7 +34,7 @@ QtObject {
|
||||||
|
|
||||||
property var _poll: Timer {
|
property var _poll: Timer {
|
||||||
interval: 60000
|
interval: 60000
|
||||||
running: true
|
running: M.Modules.powerProfile.enable
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: root._proc.running = true
|
onTriggered: root._proc.running = true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue