bluetooth and wifi

This commit is contained in:
end-4
2025-04-15 20:10:52 +02:00
parent ff8cee9dde
commit 62ef2fc421
13 changed files with 373 additions and 42 deletions
@@ -0,0 +1,69 @@
pragma Singleton
import Quickshell;
import Quickshell.Io;
import QtQuick;
Singleton {
id: root
property int updateInterval: 1000
property string bluetoothDeviceName: ""
property string bluetoothDeviceAddress: ""
property bool bluetoothEnabled: false
property bool bluetoothConnected: false
function update() {
updateBluetoothDevice.running = true
updateBluetoothStatus.running = true
updateBluetoothEnabled.running = true
}
Timer {
interval: 10
running: true
repeat: true
onTriggered: {
update()
interval = root.updateInterval
}
}
// Check if Bluetooth is enabled (controller powered on)
Process {
id: updateBluetoothEnabled
command: ["sh", "-c", "bluetoothctl show | grep -q 'Powered: yes' && echo 1 || echo 0"]
running: true
stdout: SplitParser {
onRead: data => {
root.bluetoothEnabled = (parseInt(data) === 1)
}
}
}
// Get the name and address of the first connected Bluetooth device
Process {
id: updateBluetoothDevice
command: ["sh", "-c", "bluetoothctl info | awk -F': ' '/Name: /{name=$2} /Device /{addr=$2} END{print name \":\" addr}'"]
running: true
stdout: SplitParser {
onRead: data => {
let parts = data.split(":")
root.bluetoothDeviceName = parts[0] || ""
root.bluetoothDeviceAddress = parts[1] || ""
}
}
}
// Check if any device is connected
Process {
id: updateBluetoothStatus
command: ["sh", "-c", "bluetoothctl info | grep -q 'Connected: yes' && echo 1 || echo 0"]
running: true
stdout: SplitParser {
onRead: data => {
root.bluetoothConnected = (parseInt(data) === 1)
}
}
}
}
@@ -7,6 +7,15 @@ Singleton {
property int fakeScreenRounding: 1 // 0: None | 1: Always | 2: When not fullscreen
}
property QtObject apps: QtObject {
property string bluetooth: "blueberry"
property string imageViewer: "loupe"
property string network: "XDG_CURRENT_DESKTOP=\"gnome\" gnome-control-center wifi"
property string settings: "XDG_CURRENT_DESKTOP=\"gnome\" gnome-control-center"
property string taskManager: "gnome-usage"
property string terminal: "foot" // This is only for shell actions
}
property QtObject bar: QtObject {
property int workspacesShown: 10
property int batteryLowThreshold: 20
@@ -0,0 +1,53 @@
pragma Singleton
import Quickshell;
import Quickshell.Io;
import Quickshell.Services.Pipewire;
import QtQuick;
Singleton {
id: root
property int updateInterval: 1000
property string networkName: "";
property int networkStrength;
function update() {
updateNetworkName.running = true
updateNetworkStrength.running = true
}
Timer {
interval: 10
running: true
repeat: true
onTriggered: {
update()
interval = root.updateInterval;
}
}
Process {
id: updateNetworkName
command: ["sh", "-c", "nmcli -t -f NAME c show --active | head -1"]
running: true;
stdout: SplitParser {
onRead: data => {
root.networkName = data
// console.log("Network: " + data);
}
}
}
Process {
id: updateNetworkStrength
running: true
command: ["sh", "-c", "nmcli -f IN-USE,SIGNAL,SSID device wifi | awk '/^\*/{if (NR!=1) {print $2}}'"];
stdout: SplitParser {
onRead: data => {
root.networkStrength = parseInt(data);
// console.log("Network Strength: " + data);
}
}
}
}
@@ -12,10 +12,12 @@ ToolTip {
background: Rectangle {
color: Appearance.colors.colTooltip
radius: Appearance.rounding.small
implicitWidth: tooltipText.implicitWidth + 2 * padding
}
StyledText {
text: content
id: tooltipText
text: content
color: Appearance.colors.colOnTooltip
wrapMode: Text.WordWrap
}
}