diff options
Diffstat (limited to 'services')
| -rw-r--r-- | services/Audio.qml | 36 | ||||
| -rw-r--r-- | services/IdleInhibitor.qml | 56 | ||||
| -rw-r--r-- | services/Notifs.qml | 22 | ||||
| -rw-r--r-- | services/Time.qml | 8 | ||||
| -rw-r--r-- | services/VPN.qml | 7 |
5 files changed, 60 insertions, 69 deletions
diff --git a/services/Audio.qml b/services/Audio.qml index 71ccb86..20d9cc8 100644 --- a/services/Audio.qml +++ b/services/Audio.qml @@ -19,15 +19,20 @@ Singleton { acc.sinks.push(node); else if (node.audio) acc.sources.push(node); + } else if (node.isStream && node.audio) { + // Application streams (output streams) + acc.streams.push(node); } return acc; }, { sources: [], - sinks: [] + sinks: [], + streams: [] }) readonly property list<PwNode> sinks: nodes.sinks readonly property list<PwNode> sources: nodes.sources + readonly property list<PwNode> streams: nodes.streams readonly property PwNode sink: Pipewire.defaultAudioSink readonly property PwNode source: Pipewire.defaultAudioSource @@ -79,6 +84,33 @@ Singleton { Pipewire.preferredDefaultAudioSource = newSource; } + function setStreamVolume(stream: PwNode, newVolume: real): void { + if (stream?.ready && stream?.audio) { + stream.audio.muted = false; + stream.audio.volume = Math.max(0, Math.min(Config.services.maxVolume, newVolume)); + } + } + + function setStreamMuted(stream: PwNode, muted: bool): void { + if (stream?.ready && stream?.audio) { + stream.audio.muted = muted; + } + } + + function getStreamVolume(stream: PwNode): real { + return stream?.audio?.volume ?? 0; + } + + function getStreamMuted(stream: PwNode): bool { + return !!stream?.audio?.muted; + } + + function getStreamName(stream: PwNode): string { + if (!stream) return qsTr("Unknown"); + // Try application name first, then description, then name + return stream.applicationName || stream.description || stream.name || qsTr("Unknown Application"); + } + onSinkChanged: { if (!sink?.ready) return; @@ -109,7 +141,7 @@ Singleton { } PwObjectTracker { - objects: [...root.sinks, ...root.sources] + objects: [...root.sinks, ...root.sources, ...root.streams] } CavaProvider { diff --git a/services/IdleInhibitor.qml b/services/IdleInhibitor.qml deleted file mode 100644 index 29409ab..0000000 --- a/services/IdleInhibitor.qml +++ /dev/null @@ -1,56 +0,0 @@ -pragma Singleton - -import Quickshell -import Quickshell.Io -import Quickshell.Wayland - -Singleton { - id: root - - property alias enabled: props.enabled - readonly property alias enabledSince: props.enabledSince - - onEnabledChanged: { - if (enabled) - props.enabledSince = new Date(); - } - - PersistentProperties { - id: props - - property bool enabled - property date enabledSince - - reloadableId: "idleInhibitor" - } - - IdleInhibitor { - enabled: props.enabled - window: PanelWindow { - implicitWidth: 0 - implicitHeight: 0 - color: "transparent" - mask: Region {} - } - } - - IpcHandler { - target: "idleInhibitor" - - function isEnabled(): bool { - return props.enabled; - } - - function toggle(): void { - props.enabled = !props.enabled; - } - - function enable(): void { - props.enabled = true; - } - - function disable(): void { - props.enabled = false; - } - } -} diff --git a/services/Notifs.qml b/services/Notifs.qml index 4a89c7f..2ebc32d 100644 --- a/services/Notifs.qml +++ b/services/Notifs.qml @@ -195,15 +195,8 @@ Singleton { mask: Region {} Image { - anchors.fill: parent - source: Qt.resolvedUrl(notif.image) - fillMode: Image.PreserveAspectCrop - cache: false - asynchronous: true - opacity: 0 - - onStatusChanged: { - if (status !== Image.Ready) + function tryCache(): void { + if (status !== Image.Ready || width != Config.notifs.sizes.image || height != Config.notifs.sizes.image) return; const cacheKey = notif.appName + notif.summary + notif.id; @@ -225,6 +218,17 @@ Singleton { notif.dummyImageLoader.active = false; }); } + + anchors.fill: parent + source: Qt.resolvedUrl(notif.image) + fillMode: Image.PreserveAspectCrop + cache: false + asynchronous: true + opacity: 0 + + onStatusChanged: tryCache() + onWidthChanged: tryCache() + onHeightChanged: tryCache() } } } diff --git a/services/Time.qml b/services/Time.qml index c4b3913..a07d9ef 100644 --- a/services/Time.qml +++ b/services/Time.qml @@ -1,6 +1,8 @@ pragma Singleton +import qs.config import Quickshell +import QtQuick Singleton { property alias enabled: clock.enabled @@ -9,6 +11,12 @@ Singleton { readonly property int minutes: clock.minutes readonly property int seconds: clock.seconds + readonly property string timeStr: format(Config.services.useTwelveHourClock ? "hh:mm:A" : "hh:mm") + readonly property list<string> timeComponents: timeStr.split(":") + readonly property string hourStr: timeComponents[0] ?? "" + readonly property string minuteStr: timeComponents[1] ?? "" + readonly property string amPmStr: timeComponents[2] ?? "" + function format(fmt: string): string { return Qt.formatDateTime(clock.date, fmt); } diff --git a/services/VPN.qml b/services/VPN.qml index 412bda4..431c8ec 100644 --- a/services/VPN.qml +++ b/services/VPN.qml @@ -12,8 +12,11 @@ Singleton { property bool connected: false readonly property bool connecting: connectProc.running || disconnectProc.running - readonly property bool enabled: Config.utilities.vpn.enabled - readonly property var providerInput: (Config.utilities.vpn.provider && Config.utilities.vpn.provider.length > 0) ? Config.utilities.vpn.provider[0] : "wireguard" + readonly property bool enabled: Config.utilities.vpn.provider.some(p => typeof p === "object" ? (p.enabled === true) : false) + readonly property var providerInput: { + const enabledProvider = Config.utilities.vpn.provider.find(p => typeof p === "object" ? (p.enabled === true) : false); + return enabledProvider || "wireguard"; + } readonly property bool isCustomProvider: typeof providerInput === "object" readonly property string providerName: isCustomProvider ? (providerInput.name || "custom") : String(providerInput) readonly property string interfaceName: isCustomProvider ? (providerInput.interface || "") : "" |