nix fmt
This commit is contained in:
parent
21f96dc68e
commit
b06e3582ff
23 changed files with 597 additions and 197 deletions
|
|
@ -13,23 +13,18 @@ M.PopupPanel {
|
|||
property Process _scanner: Process {
|
||||
id: scanner
|
||||
running: true
|
||||
command: ["sh", "-c",
|
||||
"bluetoothctl devices Paired 2>/dev/null | while read -r _ mac name; do " +
|
||||
"info=$(bluetoothctl info \"$mac\" 2>/dev/null); " +
|
||||
"conn=$(echo \"$info\" | grep -c 'Connected: yes'); " +
|
||||
"bat=$(echo \"$info\" | awk -F'[(): ]' '/Battery Percentage/{for(i=1;i<=NF;i++) if($i+0==$i && $i!=\"\") print $i}'); " +
|
||||
"echo \"$mac:$conn:${bat:-}:$name\"; " +
|
||||
"done"
|
||||
]
|
||||
command: ["sh", "-c", "bluetoothctl devices Paired 2>/dev/null | while read -r _ mac name; do " + "info=$(bluetoothctl info \"$mac\" 2>/dev/null); " + "conn=$(echo \"$info\" | grep -c 'Connected: yes'); " + "bat=$(echo \"$info\" | awk -F'[(): ]' '/Battery Percentage/{for(i=1;i<=NF;i++) if($i+0==$i && $i!=\"\") print $i}'); " + "echo \"$mac:$conn:${bat:-}:$name\"; " + "done"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
const devs = [];
|
||||
for (const line of text.trim().split("\n")) {
|
||||
if (!line) continue;
|
||||
if (!line)
|
||||
continue;
|
||||
const i1 = line.indexOf(":");
|
||||
const i2 = line.indexOf(":", i1 + 1);
|
||||
const i3 = line.indexOf(":", i2 + 1);
|
||||
if (i3 < 0) continue;
|
||||
if (i3 < 0)
|
||||
continue;
|
||||
devs.push({
|
||||
mac: line.slice(0, i1),
|
||||
connected: line.slice(i1 + 1, i2) === "1",
|
||||
|
|
@ -38,7 +33,8 @@ M.PopupPanel {
|
|||
});
|
||||
}
|
||||
devs.sort((a, b) => {
|
||||
if (a.connected !== b.connected) return a.connected ? -1 : 1;
|
||||
if (a.connected !== b.connected)
|
||||
return a.connected ? -1 : 1;
|
||||
return a.name.localeCompare(b.name);
|
||||
});
|
||||
menuWindow._devices = devs;
|
||||
|
|
@ -51,7 +47,8 @@ M.PopupPanel {
|
|||
property string action: ""
|
||||
property string mac: ""
|
||||
command: ["bluetoothctl", action, mac]
|
||||
onRunningChanged: if (!running) scanner.running = true
|
||||
onRunningChanged: if (!running)
|
||||
scanner.running = true
|
||||
}
|
||||
|
||||
Repeater {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue