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 | |
| 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')
| -rw-r--r-- | accounts/gkleen@sif/niri/default.nix | 39 | ||||
| -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 |
4 files changed, 115 insertions, 30 deletions
diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix index e1eca4c4..1ff149bc 100644 --- a/accounts/gkleen@sif/niri/default.nix +++ b/accounts/gkleen@sif/niri/default.nix | |||
| @@ -947,22 +947,6 @@ in { | |||
| 947 | action = spawn swayosd-client "--brightness" "lower"; | 947 | action = spawn swayosd-client "--brightness" "lower"; |
| 948 | allow-when-locked = true; | 948 | allow-when-locked = true; |
| 949 | }; | 949 | }; |
| 950 | "XF86AudioRaiseVolume" = { | ||
| 951 | action = spawn swayosd-client "--output-volume" "raise"; | ||
| 952 | allow-when-locked = true; | ||
| 953 | }; | ||
| 954 | "XF86AudioLowerVolume" = { | ||
| 955 | action = spawn swayosd-client "--output-volume" "lower"; | ||
| 956 | allow-when-locked = true; | ||
| 957 | }; | ||
| 958 | "XF86AudioMute" = { | ||
| 959 | action = spawn swayosd-client "--output-volume" "mute-toggle"; | ||
| 960 | allow-when-locked = true; | ||
| 961 | }; | ||
| 962 | "XF86AudioMicMute" = { | ||
| 963 | action = spawn swayosd-client "--input-volume" "mute-toggle"; | ||
| 964 | allow-when-locked = true; | ||
| 965 | }; | ||
| 966 | 950 | ||
| 967 | "Mod+Semicolon".action = spawn makoctl "dismiss" "--group"; | 951 | "Mod+Semicolon".action = spawn makoctl "dismiss" "--group"; |
| 968 | "Mod+Shift+Semicolon".action = spawn makoctl "dismiss" "--all"; | 952 | "Mod+Shift+Semicolon".action = spawn makoctl "dismiss" "--all"; |
| @@ -982,6 +966,29 @@ in { | |||
| 982 | "Mod+K".action = spawn (lib.getExe' pkgs.worktime "worktime-ui"); | 966 | "Mod+K".action = spawn (lib.getExe' pkgs.worktime "worktime-ui"); |
| 983 | "Mod+Shift+K".action = spawn (lib.getExe' pkgs.worktime "worktime-stop"); | 967 | "Mod+Shift+K".action = spawn (lib.getExe' pkgs.worktime "worktime-stop"); |
| 984 | })) | 968 | })) |
| 969 | (lib.mapAttrsToList (name: cfg: node name [(lib.removeAttrs cfg ["action"])] [cfg.action]) (let | ||
| 970 | shell = obj: leaf "send-unix" [ | ||
| 971 | { path = ''''${XDG_RUNTIME_DIR}/shell.sock''; } | ||
| 972 | (builtins.toJSON obj + "\n") | ||
| 973 | ]; | ||
| 974 | in { | ||
| 975 | "XF86AudioRaiseVolume" = { | ||
| 976 | allow-when-locked = true; | ||
| 977 | action = shell { Volume.volume = "up"; }; | ||
| 978 | }; | ||
| 979 | "XF86AudioLowerVolume" = { | ||
| 980 | allow-when-locked = true; | ||
| 981 | action = shell { Volume.volume = "down"; }; | ||
| 982 | }; | ||
| 983 | "XF86AudioMute" = { | ||
| 984 | allow-when-locked = true; | ||
| 985 | action = shell { Volume.muted = "toggle"; }; | ||
| 986 | }; | ||
| 987 | "XF86AudioMicMute" = { | ||
| 988 | allow-when-locked = true; | ||
| 989 | action = shell { Volume."mic-muted" = "toggle"; }; | ||
| 990 | }; | ||
| 991 | })) | ||
| 985 | (map ({ name, selector, spawn, key, ...}: if key != null && selector != null && spawn != null then bind key { action = focus-or-spawn-action selector name spawn; } else null) cfg.scratchspaces) | 992 | (map ({ name, selector, spawn, key, ...}: if key != null && selector != null && spawn != null then bind key { action = focus-or-spawn-action selector name spawn; } else null) cfg.scratchspaces) |
| 986 | (map ({ name, moveKey, ...}: if moveKey != null then bind moveKey { action = kdl.magic-leaf "move-column-to-workspace" name; } else null) cfg.scratchspaces) | 993 | (map ({ name, moveKey, ...}: if moveKey != null then bind moveKey { action = kdl.magic-leaf "move-column-to-workspace" name; } else null) cfg.scratchspaces) |
| 987 | ] | 994 | ] |
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 | } |
