Handle volume, media and notification keys in the shell (#13424)
* Step the volume in the shell instead of a script per keypress Each volume key ran omarchy-audio-output-volume: several pactl calls in bash, then omarchy-osd delivering the OSD over a qs IPC client, ~165ms from keypress to OSD, on keys that repeat while held. The volume up, down and mute keys now dispatch global shortcuts that the media service handles over PipeWire, stepping, clamping, unmuting and debouncing by the script's rules and showing the same OSD. It acts only when the default sink is an ALSA sink, which is its own physical sink. Any other default, a DSP chain or EasyEffects above all, falls back to the script, which resolves the physical sink from the live routing on every press. The precise +1/-1 keys still run the script. Keypress to OSD drops from ~168ms to ~20ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Run media and notification keys in the shell without an IPC client The media keys and the notification dismiss, invoke and history keys ran omarchy-shell, starting a qs client for one argument-free IPC call. A new ipc shortcut kind names such a call as target.method. The shell hands it to the service that owns the target, which runs its own IpcHandler function, so the key behaves exactly as the omarchy-shell call did. A call missing from the list binds through omarchy-shell. Dismissing a notification with SUPER+comma clears the popup in ~11ms instead of ~40ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bf44355a98
commit
804749970a
10 files changed
+200
-28
No files matched your search
+23
-7
@@ -1516,9 +1516,9 @@ ShellRoot {
|
||||
|
||||
// ------------------------------------------------------ global shortcuts
|
||||
//
|
||||
// Bindings that open a menu route or panel dispatch these through Hyprland,
|
||||
// so a keypress reaches the shell without spawning an omarchy-shell IPC
|
||||
// client. The list is shared with default/hypr/helpers.lua, which binds a
|
||||
// Bindings that open a menu route or panel, or step the volume, dispatch
|
||||
// these through Hyprland, so a keypress reaches the shell without spawning
|
||||
// an IPC client or script. The list is shared with default/hypr/helpers.lua, which binds a
|
||||
// route or panel missing from it through the command instead.
|
||||
|
||||
function parseShortcuts(raw) {
|
||||
@@ -1526,17 +1526,33 @@ ShellRoot {
|
||||
var lines = String(raw || "").split("\n")
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var match = /^([A-Za-z]+)\s+(\S+)\s*$/.exec(lines[i])
|
||||
if (match && (match[1] === "menu" || match[1] === "panel"))
|
||||
if (match && ["menu", "panel", "audio", "ipc"].indexOf(match[1]) !== -1)
|
||||
entries.push({ kind: match[1], target: match[2], name: match[1] + "." + match[2] })
|
||||
}
|
||||
return entries
|
||||
}
|
||||
|
||||
// The IPC targets an ipc shortcut may name, and the service that owns each.
|
||||
readonly property var ipcShortcutServices: ({ media: "omarchy.media", notifications: "omarchy.notifications" })
|
||||
|
||||
function runShortcut(entry) {
|
||||
if (entry.kind === "menu")
|
||||
if (entry.kind === "menu") {
|
||||
shell.toggle("omarchy.menu", JSON.stringify({ menu: entry.target }))
|
||||
else
|
||||
} else if (entry.kind === "ipc") {
|
||||
// "media.next" runs the media service's own IPC handler for next.
|
||||
var dot = entry.target.indexOf(".")
|
||||
var target = entry.target.slice(0, dot)
|
||||
var method = entry.target.slice(dot + 1)
|
||||
var service = shell.serviceFor(shell.ipcShortcutServices[target] || "")
|
||||
if (!service || !service.runShortcut(method))
|
||||
Util.execArgv(["omarchy-shell", target, method])
|
||||
} else if (entry.kind === "audio") {
|
||||
var media = shell.serviceFor("omarchy.media")
|
||||
if (!media || !media.handleVolumeKey(entry.target))
|
||||
Util.execArgv(["omarchy-audio-output-volume", entry.target])
|
||||
} else {
|
||||
shell.toggle(entry.target, "{}")
|
||||
}
|
||||
}
|
||||
|
||||
FileView {
|
||||
@@ -1554,7 +1570,7 @@ ShellRoot {
|
||||
|
||||
appid: "omarchy"
|
||||
name: modelData.name
|
||||
description: modelData.kind === "menu" ? "Toggle the " + modelData.target + " menu" : "Toggle the " + modelData.target + " panel"
|
||||
description: modelData.kind === "audio" ? "Volume " + modelData.target : (modelData.kind === "ipc" ? "Run " + modelData.target : "Toggle the " + modelData.target + " " + modelData.kind)
|
||||
onPressed: shell.runShortcut(modelData)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user