bluetooth: fix devices
Also add animation for bar bluetooth devices
This commit is contained in:
parent
ae878e390f
commit
0d5389a687
2 changed files with 19 additions and 13 deletions
|
|
@ -10,6 +10,9 @@ StyledRect {
|
|||
|
||||
readonly property color colour: Appearance.colours.rosewater
|
||||
|
||||
animate: true
|
||||
clip: true
|
||||
|
||||
MaterialIcon {
|
||||
id: network
|
||||
|
||||
|
|
|
|||
|
|
@ -9,14 +9,17 @@ Singleton {
|
|||
|
||||
property bool powered
|
||||
property bool discovering
|
||||
readonly property list<Device> devices: []
|
||||
property list<Device> devices: []
|
||||
readonly property list<Device> connected: devices.filter(d => d.connected)
|
||||
|
||||
Process {
|
||||
running: true
|
||||
command: ["bluetoothctl"]
|
||||
stdout: SplitParser {
|
||||
onRead: getInfo.running = true
|
||||
onRead: {
|
||||
getInfo.running = true;
|
||||
getDevices.running = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -35,19 +38,19 @@ Singleton {
|
|||
Process {
|
||||
id: getDevices
|
||||
running: true
|
||||
command: ["fish", "-c", `for a in (bluetoothctl devices | cut -d ' ' -f 2); bluetoothctl info $a | jq -R 'reduce (inputs / ":") as [$key, $value] ({}; .[$key | ltrimstr("\t")] = ($value | ltrimstr(" ")))' | jq -c --arg addr $a '.Address = $addr'; end`]
|
||||
command: ["fish", "-c", `for a in (bluetoothctl devices | cut -d ' ' -f 2); bluetoothctl info $a | jq -R 'reduce (inputs / ":") as [$key, $value] ({}; .[$key | ltrimstr("\t")] = ($value | ltrimstr(" ")))' | jq -c --arg addr $a '.Address = $addr'; end | jq -sc`]
|
||||
stdout: SplitParser {
|
||||
onRead: data => {
|
||||
const d = JSON.parse(data);
|
||||
root.devices.push(deviceComp.createObject(root, {
|
||||
name: d.Name,
|
||||
alias: d.Alias,
|
||||
address: d.Address,
|
||||
icon: d.Icon,
|
||||
connected: d.Connected === "yes",
|
||||
paired: d.Paired === "yes",
|
||||
trusted: d.Trusted === "yes"
|
||||
}));
|
||||
const devices = JSON.parse(data);
|
||||
root.devices = devices.map(d => deviceComp.createObject(root, {
|
||||
name: d.Name,
|
||||
alias: d.Alias,
|
||||
address: d.Address,
|
||||
icon: d.Icon,
|
||||
connected: d.Connected === "yes",
|
||||
paired: d.Paired === "yes",
|
||||
trusted: d.Trusted === "yes"
|
||||
})).filter(d => d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue