Add a Caffeine inhibitor, app stream volumes and vertical bar sliders
CaffeineService holds a systemd-inhibit idle/sleep lock while active. AudioService lists app playback streams and tracks their volume only while a view holds a Demand on it. GlassBarSlider fills from the bottom when vertical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d6a6cf69f4
commit
0dcf37346c
4 files changed
+94
-18
No files matched your search
@@ -10,9 +10,36 @@ Singleton {
|
||||
readonly property var source: backend.defaultAudioSource
|
||||
readonly property var outputs: backend.nodes.values.filter(n => n.audio && n.isSink && !n.isStream)
|
||||
readonly property var inputs: backend.nodes.values.filter(n => n.audio && !n.isSink && !n.isStream)
|
||||
// App playback streams, e.g. the players EasyEffects processes.
|
||||
readonly property var streams: backend.nodes.values.filter(n => n.audio && n.isStream && !n.isSink)
|
||||
readonly property bool available: backend.ready
|
||||
// Views listing streams hold a Demand on this, so their volumes are only
|
||||
// tracked while shown.
|
||||
property int streamConsumers: 0
|
||||
PwObjectTracker {
|
||||
objects: root.backend === Pipewire ? [root.sink, root.source].filter(n => n !== null) : []
|
||||
objects: root.backend === Pipewire ? [root.sink, root.source].filter(n => n !== null).concat(root.streamConsumers > 0 ? root.streams : []) : []
|
||||
}
|
||||
function streamName(node) {
|
||||
const p = node && node.properties || {};
|
||||
return p["application.name"] || node.description || p["media.name"] || node.name || "Unknown";
|
||||
}
|
||||
// Icon path: the stream's own icon name, else its app's desktop entry.
|
||||
function streamIcon(node) {
|
||||
const p = node && node.properties || {};
|
||||
const named = p["application.icon-name"] ? Quickshell.iconPath(p["application.icon-name"], true) : "";
|
||||
return named || ApplicationsService.icon(ApplicationsService.byId(p["application.process.binary"] || "") || ApplicationsService.byId(p["application.name"] || ""));
|
||||
}
|
||||
function streamVolume(node, value) {
|
||||
if (!node || !node.audio || !Number.isFinite(value))
|
||||
return false;
|
||||
node.audio.volume = Math.max(0, Math.min(1, value));
|
||||
return true;
|
||||
}
|
||||
function streamMute(node) {
|
||||
if (!node || !node.audio)
|
||||
return false;
|
||||
node.audio.muted = !node.audio.muted;
|
||||
return true;
|
||||
}
|
||||
function volume(input, value) {
|
||||
const node = input ? source : sink;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
pragma Singleton
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
|
||||
// Keeps the session awake while on: holds a systemd idle and sleep inhibitor,
|
||||
// which hypridle and logind both honour. Off again after a shell restart.
|
||||
Singleton {
|
||||
id: root
|
||||
property bool active: false
|
||||
property var command: ["systemd-inhibit", "--what=idle:sleep", "--who=glassMxrph", "--why=Caffeine", "--mode=block", "sleep", "infinity"]
|
||||
readonly property bool running: inhibitor.running
|
||||
function toggle() {
|
||||
active = !active;
|
||||
return true;
|
||||
}
|
||||
Process {
|
||||
id: inhibitor
|
||||
command: root.command
|
||||
running: root.active
|
||||
// The inhibitor exiting on its own (logind refused it) turns the tile off.
|
||||
onRunningChanged: if (!running && root.active)
|
||||
root.active = false
|
||||
}
|
||||
IpcHandler {
|
||||
target: "caffeine"
|
||||
function toggle(): bool {
|
||||
return root.toggle();
|
||||
}
|
||||
function status(): string {
|
||||
return JSON.stringify({
|
||||
active: root.active,
|
||||
running: inhibitor.running
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,3 +19,4 @@ singleton PluginService 1.0 PluginService.qml
|
||||
singleton NotificationService 1.0 NotificationService.qml
|
||||
singleton ClipboardService 1.0 ClipboardService.qml
|
||||
singleton EmojiService 1.0 EmojiService.qml
|
||||
singleton CaffeineService 1.0 CaffeineService.qml
|
||||
Reference in new issue
Block a user