diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2025-09-09 21:40:07 +0200 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2025-09-09 21:40:07 +0200 |
| commit | 9fab3828698199718a3d2f2faf8826f77d9258f7 (patch) | |
| tree | 6e6d567a3877b425bdd0329e898cd00013c766fb /accounts/gkleen@sif/shell | |
| parent | df1632d1c15cba4b7a361f8159b9988919ef8277 (diff) | |
| download | nixos-9fab3828698199718a3d2f2faf8826f77d9258f7.tar nixos-9fab3828698199718a3d2f2faf8826f77d9258f7.tar.gz nixos-9fab3828698199718a3d2f2faf8826f77d9258f7.tar.bz2 nixos-9fab3828698199718a3d2f2faf8826f77d9258f7.tar.xz nixos-9fab3828698199718a3d2f2faf8826f77d9258f7.zip | |
...
Diffstat (limited to 'accounts/gkleen@sif/shell')
| -rw-r--r-- | accounts/gkleen@sif/shell/quickshell/UnixIPC.qml | 49 | ||||
| -rw-r--r-- | accounts/gkleen@sif/shell/quickshell/VolumeOSD.qml | 55 | ||||
| -rw-r--r-- | accounts/gkleen@sif/shell/quickshell/shell.qml | 2 |
3 files changed, 92 insertions, 14 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell/UnixIPC.qml b/accounts/gkleen@sif/shell/quickshell/UnixIPC.qml new file mode 100644 index 00000000..7b308ec0 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/UnixIPC.qml | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | import Quickshell | ||
| 2 | import Quickshell.Io | ||
| 3 | import Quickshell.Services.Pipewire | ||
| 4 | |||
| 5 | Scope { | ||
| 6 | id: root | ||
| 7 | |||
| 8 | SocketServer { | ||
| 9 | active: true | ||
| 10 | path: `${Quickshell.env("XDG_RUNTIME_DIR")}/shell.sock` | ||
| 11 | handler: Socket { | ||
| 12 | parser: SplitParser { | ||
| 13 | onRead: line => { | ||
| 14 | try { | ||
| 15 | const command = JSON.parse(line); | ||
| 16 | |||
| 17 | if (command.Volume) | ||
| 18 | root.onCommandVolume(command.Volume); | ||
| 19 | else | ||
| 20 | console.warn("UnixIPC: Command not handled:", JSON.stringify(command)); | ||
| 21 | } catch (e) { | ||
| 22 | console.warn("UnixIPC: Failed to parse command:", line, e); | ||
| 23 | } | ||
| 24 | } | ||
| 25 | } | ||
| 26 | |||
| 27 | onError: e => { | ||
| 28 | if (e == 1) | ||
| 29 | return; | ||
| 30 | console.warn("QLocalSocket::LocalSocketError", e); | ||
| 31 | } | ||
| 32 | } | ||
| 33 | } | ||
| 34 | |||
| 35 | PwObjectTracker { | ||
| 36 | objects: [ Pipewire.defaultAudioSink, Pipewire.defaultAudioSource ] | ||
| 37 | } | ||
| 38 | function onCommandVolume(command) { | ||
| 39 | if (command.muted === "toggle") | ||
| 40 | Pipewire.defaultAudioSink.audio.muted = !Pipewire.defaultAudioSink.audio.muted; | ||
| 41 | if (command.volume === "up") | ||
| 42 | Pipewire.defaultAudioSink.audio.volume += 0.02; | ||
| 43 | if (command.volume === "down") | ||
| 44 | Pipewire.defaultAudioSink.audio.volume -= 0.02; | ||
| 45 | |||
| 46 | if (command["mic-muted"] === "toggle") | ||
| 47 | Pipewire.defaultAudioSource.audio.muted = !Pipewire.defaultAudioSource.audio.muted; | ||
| 48 | } | ||
| 49 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/VolumeOSD.qml b/accounts/gkleen@sif/shell/quickshell/VolumeOSD.qml index 02dcf227..16fb5dea 100644 --- a/accounts/gkleen@sif/shell/quickshell/VolumeOSD.qml +++ b/accounts/gkleen@sif/shell/quickshell/VolumeOSD.qml | |||
| @@ -7,11 +7,11 @@ import Quickshell.Widgets | |||
| 7 | Scope { | 7 | Scope { |
| 8 | id: root | 8 | id: root |
| 9 | 9 | ||
| 10 | property bool show: false | 10 | property string show: "" |
| 11 | property bool inhibited: true | 11 | property bool inhibited: true |
| 12 | 12 | ||
| 13 | PwObjectTracker { | 13 | PwObjectTracker { |
| 14 | objects: [ Pipewire.defaultAudioSink ] | 14 | objects: [ Pipewire.defaultAudioSink, Pipewire.defaultAudioSource ] |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | Connections { | 17 | Connections { |
| @@ -19,11 +19,25 @@ Scope { | |||
| 19 | target: Pipewire.defaultAudioSink?.audio | 19 | target: Pipewire.defaultAudioSink?.audio |
| 20 | 20 | ||
| 21 | function onVolumeChanged() { | 21 | function onVolumeChanged() { |
| 22 | root.show = true; | 22 | root.show = "sink"; |
| 23 | hideTimer.restart(); | 23 | hideTimer.restart(); |
| 24 | } | 24 | } |
| 25 | function onMutedChanged() { | 25 | function onMutedChanged() { |
| 26 | root.show = true; | 26 | root.show = "sink"; |
| 27 | hideTimer.restart(); | ||
| 28 | } | ||
| 29 | } | ||
| 30 | |||
| 31 | Connections { | ||
| 32 | enabled: Pipewire.defaultAudioSource | ||
| 33 | target: Pipewire.defaultAudioSource?.audio | ||
| 34 | |||
| 35 | function onVolumeChanged() { | ||
| 36 | root.show = "source"; | ||
| 37 | hideTimer.restart(); | ||
| 38 | } | ||
| 39 | function onMutedChanged() { | ||
| 40 | root.show = "source"; | ||
| 27 | hideTimer.restart(); | 41 | hideTimer.restart(); |
| 28 | } | 42 | } |
| 29 | } | 43 | } |
| @@ -36,7 +50,7 @@ Scope { | |||
| 36 | Timer { | 50 | Timer { |
| 37 | id: hideTimer | 51 | id: hideTimer |
| 38 | interval: 1000 | 52 | interval: 1000 |
| 39 | onTriggered: root.show = false | 53 | onTriggered: root.show = "" |
| 40 | } | 54 | } |
| 41 | 55 | ||
| 42 | Timer { | 56 | Timer { |
| @@ -44,7 +58,7 @@ Scope { | |||
| 44 | interval: 100 | 58 | interval: 100 |
| 45 | running: true | 59 | running: true |
| 46 | onTriggered: { | 60 | onTriggered: { |
| 47 | root.show = false; | 61 | root.show = ""; |
| 48 | root.inhibited = false; | 62 | root.inhibited = false; |
| 49 | } | 63 | } |
| 50 | } | 64 | } |
| @@ -97,13 +111,20 @@ Scope { | |||
| 97 | implicitHeight: parent.height | 111 | implicitHeight: parent.height |
| 98 | 112 | ||
| 99 | icon: { | 113 | icon: { |
| 100 | if (!Pipewire.defaultAudioSink || Pipewire.defaultAudioSink.audio.muted) | 114 | if (root.show == "sink") { |
| 101 | return "volume-off"; | 115 | if (!Pipewire.defaultAudioSink || Pipewire.defaultAudioSink.audio.muted) |
| 102 | if (Pipewire.defaultAudioSink.audio.volume <= 0.33) | 116 | return "volume-off"; |
| 103 | return "volume-low"; | 117 | if (Pipewire.defaultAudioSink.audio.volume <= 0.33) |
| 104 | if (Pipewire.defaultAudioSink.audio.volume <= 0.67) | 118 | return "volume-low"; |
| 105 | return "volume-medium"; | 119 | if (Pipewire.defaultAudioSink.audio.volume <= 0.67) |
| 106 | return "volume-high"; | 120 | return "volume-medium"; |
| 121 | return "volume-high"; | ||
| 122 | } else if (root.show == "source") { | ||
| 123 | if (!Pipewire.defaultAudioSource || Pipewire.defaultAudioSource.audio.muted) | ||
| 124 | return "microphone-off"; | ||
| 125 | return "microphone"; | ||
| 126 | } | ||
| 127 | return "volume-high"; | ||
| 107 | } | 128 | } |
| 108 | } | 129 | } |
| 109 | 130 | ||
| @@ -123,7 +144,13 @@ Scope { | |||
| 123 | 144 | ||
| 124 | color: Pipewire.defaultAudioSink?.audio.muted ? "#70ffffff" : "white" | 145 | color: Pipewire.defaultAudioSink?.audio.muted ? "#70ffffff" : "white" |
| 125 | 146 | ||
| 126 | implicitWidth: parent.width * (Pipewire.defaultAudioSink?.audio.volume ?? 0) | 147 | implicitWidth: { |
| 148 | if (root.show == "sink") | ||
| 149 | return parent.width * (Pipewire.defaultAudioSink?.audio.volume ?? 0); | ||
| 150 | else if (root.show == "source") | ||
| 151 | return parent.width * (Pipewire.defaultAudioSource?.audio.volume ?? 0); | ||
| 152 | return 0; | ||
| 153 | } | ||
| 127 | } | 154 | } |
| 128 | } | 155 | } |
| 129 | } | 156 | } |
diff --git a/accounts/gkleen@sif/shell/quickshell/shell.qml b/accounts/gkleen@sif/shell/quickshell/shell.qml index 3657f77f..3bb2ae00 100644 --- a/accounts/gkleen@sif/shell/quickshell/shell.qml +++ b/accounts/gkleen@sif/shell/quickshell/shell.qml | |||
| @@ -43,4 +43,6 @@ ShellRoot { | |||
| 43 | Lockscreen {} | 43 | Lockscreen {} |
| 44 | 44 | ||
| 45 | VolumeOSD {} | 45 | VolumeOSD {} |
| 46 | |||
| 47 | UnixIPC {} | ||
| 46 | } | 48 | } |
