working mpris and bluetooth menu
This commit is contained in:
69
Services/BluetoothManager.qml
Normal file
69
Services/BluetoothManager.qml
Normal file
@@ -0,0 +1,69 @@
|
||||
pragma Singleton
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Bluetooth
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
property BluetoothAdapter defaultAdapter: Bluetooth.defaultAdapter
|
||||
property string defaultAdapterName: Bluetooth.defaultAdapter.adapterId
|
||||
|
||||
function getConnected() {
|
||||
let deviceList = getDevicesList();
|
||||
for (let device in deviceList) {
|
||||
let currentDevice = deviceList[device];
|
||||
if (currentDevice.connected == true) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function getDevicesList() {
|
||||
return root.defaultAdapter.devices.values;
|
||||
}
|
||||
|
||||
function getIcon(name) {
|
||||
const icons = {
|
||||
"audio-card": "",
|
||||
"audio-input-microphone": "",
|
||||
"audio-headphones": "",
|
||||
"audio-headset": "",
|
||||
"battery": "",
|
||||
"camera-photo": "",
|
||||
"computer": "",
|
||||
"input-keyboard": "",
|
||||
"input-mouse": "",
|
||||
"input-gaming": "",
|
||||
"phone": ""
|
||||
};
|
||||
|
||||
return icons[name] || "";
|
||||
}
|
||||
|
||||
function pairTrustConnect(device) {
|
||||
device.pair();
|
||||
device.trusted = true;
|
||||
device.connect();
|
||||
}
|
||||
|
||||
function toggleDiscover() {
|
||||
if (defaultAdapter.discovering == true) {
|
||||
defaultAdapter.discovering = false;
|
||||
} else {
|
||||
defaultAdapter.discovering = true;
|
||||
discoveringTimeout.running = true;
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: discoveringTimeout
|
||||
|
||||
interval: 15000
|
||||
repeat: false
|
||||
running: false
|
||||
|
||||
onTriggered: defaultAdapter.discovering = false
|
||||
}
|
||||
}
|
||||
27
Services/MprisManager.qml
Normal file
27
Services/MprisManager.qml
Normal file
@@ -0,0 +1,27 @@
|
||||
pragma Singleton
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Services.Mpris
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
property MprisPlayer defaultPlayer: Mpris.players.values[0]
|
||||
property real pos: defaultPlayer.position / defaultPlayer.length
|
||||
|
||||
function getPlaying() {
|
||||
if (!defaultPlayer) {
|
||||
return false;
|
||||
} else {
|
||||
return defaultPlayer.playbackState == MprisPlaybackState.Playing;
|
||||
}
|
||||
}
|
||||
|
||||
function prev() {
|
||||
defaultPlayer.previous();
|
||||
}
|
||||
|
||||
function skip() {
|
||||
defaultPlayer.next();
|
||||
}
|
||||
}
|
||||
@@ -2,3 +2,5 @@ module Services
|
||||
singleton Time 1.0 Time.qml
|
||||
singleton NotificationManager 1.0 NotificationManager.qml
|
||||
singleton WorkspaceManager 1.0 WorkspaceManager.qml
|
||||
singleton BluetoothManager 1.0 BluetoothManager.qml
|
||||
singleton MprisManager 1.0 MprisManager.qml
|
||||
|
||||
Reference in New Issue
Block a user