Add bluetooth icon
This commit is contained in:
56
quickshell/services/BluetoothService.qml
Normal file
56
quickshell/services/BluetoothService.qml
Normal file
@@ -0,0 +1,56 @@
|
||||
import QtQuick
|
||||
import Quickshell.Io
|
||||
|
||||
Item {
|
||||
id: root
|
||||
signal devicesFound(var devices)
|
||||
property var connectedDevices: []
|
||||
|
||||
function deviceListChanged(newList) {
|
||||
if (newList.length !== root.connectedDevices.length) {
|
||||
return true;
|
||||
}
|
||||
for (let i = 0; i < newList.length; i++) {
|
||||
if (newList[i].mac !== root.connectedDevices[i].mac ||
|
||||
newList[i].name !== root.connectedDevices[i].name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Process {
|
||||
id: bluetoothConnectedDevicesProcess
|
||||
command: ["bluetoothctl", "devices", "Connected"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
if (!this.text) {
|
||||
root.connectedDevices = [];
|
||||
root.devicesFound([]);
|
||||
return;
|
||||
}
|
||||
var devices = this.text.trim().split("\n").map(line => {
|
||||
var parts = line.split(" ");
|
||||
return {
|
||||
mac: parts[1],
|
||||
name: parts.slice(2).join(" ")
|
||||
};
|
||||
});
|
||||
|
||||
if (root.deviceListChanged(devices)) {
|
||||
root.connectedDevices = devices;
|
||||
root.devicesFound(devices);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 2000
|
||||
running: true
|
||||
repeat: true
|
||||
onTriggered: bluetoothConnectedDevicesProcess.running = true
|
||||
}
|
||||
|
||||
Component.onCompleted: bluetoothConnectedDevicesProcess.running = true
|
||||
}
|
||||
@@ -68,7 +68,6 @@ Item {
|
||||
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
console.log("GPU usage data:", this.text);
|
||||
if (!this.text) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ ShellRoot {
|
||||
gpuUsage: stats.gpuUsage
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Variants {
|
||||
@@ -66,4 +65,3 @@ ShellRoot {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
49
quickshell/ui/BluetoothIcon.qml
Normal file
49
quickshell/ui/BluetoothIcon.qml
Normal file
@@ -0,0 +1,49 @@
|
||||
import Quickshell.Io
|
||||
import QtQuick
|
||||
|
||||
import "../constants"
|
||||
import "../services"
|
||||
|
||||
Text {
|
||||
id: root
|
||||
|
||||
// Nerd Font Bluetooth icon (nf-fa-bluetooth)
|
||||
property string iconGlyph: "\udb80\udcaf"
|
||||
property string connectedIconGlyph: "\udb80\udcb1"
|
||||
property string disconnectedIconGlyph: "\udb80\udcaf"
|
||||
|
||||
property BluetoothService bluetoothService: BluetoothService {
|
||||
onDevicesFound: function(devices) {
|
||||
if (devices.length > 0) {
|
||||
root.iconGlyph = root.connectedIconGlyph;
|
||||
root.color = Colors.md3.on_primary_fixed;
|
||||
} else {
|
||||
root.iconGlyph = root.disconnectedIconGlyph;
|
||||
root.color = Colors.md3.primary;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
text: iconGlyph
|
||||
color: Colors.md3.on_primary_fixed
|
||||
|
||||
font {
|
||||
family: Constants.fontFamily
|
||||
pixelSize: Constants.fontSize
|
||||
bold: true
|
||||
}
|
||||
|
||||
Process {
|
||||
id: bluemanManagerProcess
|
||||
command: ["blueman-manager"]
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
|
||||
onClicked: {
|
||||
bluemanManagerProcess.running = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
51
quickshell/ui/MixerEntry.qml
Normal file
51
quickshell/ui/MixerEntry.qml
Normal file
@@ -0,0 +1,51 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls
|
||||
import Quickshell.Services.Pipewire
|
||||
|
||||
ColumnLayout {
|
||||
required property PwNode node;
|
||||
|
||||
// bind the node so we can read its properties
|
||||
PwObjectTracker { objects: [ node ] }
|
||||
|
||||
RowLayout {
|
||||
Image {
|
||||
visible: source != ""
|
||||
source: {
|
||||
const icon = node.properties["application.icon-name"] ?? "audio-volume-high-symbolic";
|
||||
return `image://icon/${icon}`;
|
||||
}
|
||||
|
||||
sourceSize.width: 20
|
||||
sourceSize.height: 20
|
||||
}
|
||||
|
||||
Label {
|
||||
text: {
|
||||
// application.name -> description -> name
|
||||
const app = node.properties["application.name"] ?? (node.description != "" ? node.description : node.name);
|
||||
const media = node.properties["media.name"];
|
||||
return media != undefined ? `${app} - ${media}` : app;
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
text: node.audio.muted ? "unmute" : "mute"
|
||||
onClicked: node.audio.muted = !node.audio.muted
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Label {
|
||||
Layout.preferredWidth: 50
|
||||
text: `${Math.floor(node.audio.volume * 100)}%`
|
||||
}
|
||||
|
||||
Slider {
|
||||
Layout.fillWidth: true
|
||||
value: node.audio.volume
|
||||
onValueChanged: node.audio.volume = value
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,12 +66,17 @@ Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
|
||||
// =====================
|
||||
// RIGHT: System info
|
||||
// =====================
|
||||
RowLayout {
|
||||
spacing: 10
|
||||
|
||||
LineSeparator {}
|
||||
|
||||
BluetoothIcon {}
|
||||
|
||||
LineSeparator {}
|
||||
|
||||
BarText {
|
||||
@@ -93,6 +98,9 @@ Item {
|
||||
value: gpuUsage
|
||||
}
|
||||
|
||||
LineSeparator {}
|
||||
|
||||
|
||||
LineSeparator {}
|
||||
|
||||
Clock {}
|
||||
|
||||
Reference in New Issue
Block a user