summaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-04-29 18:47:45 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-04-29 18:47:45 +1000
commit169450aa2e9d9058686aab0f7cf54b728ecd6efa (patch)
tree22b84e83831f975db86c676ef4716815f59ab10d /services
parentbar: increase spacing between pill content (diff)
downloadcaelestia-shell-169450aa2e9d9058686aab0f7cf54b728ecd6efa.tar.gz
caelestia-shell-169450aa2e9d9058686aab0f7cf54b728ecd6efa.tar.bz2
caelestia-shell-169450aa2e9d9058686aab0f7cf54b728ecd6efa.zip
feat: bar bluetooth devices
Diffstat (limited to 'services')
-rw-r--r--services/Bluetooth.qml70
-rw-r--r--services/Hyprland.qml4
2 files changed, 72 insertions, 2 deletions
diff --git a/services/Bluetooth.qml b/services/Bluetooth.qml
new file mode 100644
index 0000000..d749879
--- /dev/null
+++ b/services/Bluetooth.qml
@@ -0,0 +1,70 @@
+pragma Singleton
+
+import Quickshell
+import Quickshell.Io
+import QtQuick
+
+Singleton {
+ id: root
+
+ property bool powered
+ property bool discovering
+ readonly 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
+ }
+ }
+
+ Process {
+ id: getInfo
+ running: true
+ command: ["sh", "-c", "bluetoothctl show | paste -s"]
+ stdout: SplitParser {
+ onRead: data => {
+ root.powered = data.includes("Powered: yes");
+ root.discovering = data.includes("Discovering: yes");
+ }
+ }
+ }
+
+ 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`]
+ 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"
+ }));
+ }
+ }
+ }
+
+ component Device: QtObject {
+ property string name
+ property string alias
+ property string address
+ property string icon
+ property bool connected
+ property bool paired
+ property bool trusted
+ }
+
+ Component {
+ id: deviceComp
+
+ Device {}
+ }
+}
diff --git a/services/Hyprland.qml b/services/Hyprland.qml
index d786e62..df2f0ba 100644
--- a/services/Hyprland.qml
+++ b/services/Hyprland.qml
@@ -39,7 +39,7 @@ Singleton {
Process {
id: getClients
- command: ["bash", "-c", "hyprctl -j clients | jq -c"]
+ command: ["sh", "-c", "hyprctl -j clients | jq -c"]
stdout: SplitParser {
onRead: data => {
const clients = JSON.parse(data);
@@ -58,7 +58,7 @@ Singleton {
Process {
id: getActiveClient
- command: ["bash", "-c", "hyprctl -j activewindow | jq -c"]
+ command: ["sh", "-c", "hyprctl -j activewindow | jq -c"]
stdout: SplitParser {
onRead: data => {
const client = JSON.parse(data);