Bind clipboard shortcut to plugin-owned IPC
This commit is contained in:
+14
-1
@@ -110,8 +110,21 @@ Item {
|
|||||||
function onOpenPanelIdsChanged() { root.syncShellOpenState() }
|
function onOpenPanelIdsChanged() { root.syncShellOpenState() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Direct IPC avoids the host panel Loader selecting a stale instance after
|
||||||
|
// plugin rescans. Keybindings should target this handler, not shell.toggle.
|
||||||
|
IpcHandler {
|
||||||
|
target: "alanfortlink.clipboard"
|
||||||
|
function open(): void { root.open() }
|
||||||
|
function close(): void { root.close() }
|
||||||
|
function show(): void { root.open() }
|
||||||
|
function hide(): void { root.close() }
|
||||||
|
function toggle(): void { root.toggle() }
|
||||||
|
function pause(payloadJson: string): string { return root.pause(payloadJson) }
|
||||||
|
function isPaused(): string { return root.isPaused() }
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------ pause
|
// ------------------------------------------------------------ pause
|
||||||
// Toggle via IPC: omarchy-shell shell call alanfortlink.clipboard pause '{"paused":true}'
|
// Toggle via IPC: omarchy-shell alanfortlink.clipboard pause '{"paused":true}'
|
||||||
// (or {"paused":false}, or {"paused":"toggle"}), and Ctrl+Space in the picker.
|
// (or {"paused":false}, or {"paused":"toggle"}), and Ctrl+Space in the picker.
|
||||||
function setPaused(next) {
|
function setPaused(next) {
|
||||||
root.paused = !!next
|
root.paused = !!next
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ For a custom binding, edit the **live** config —
|
|||||||
but is not sourced):
|
but is not sourced):
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
o.bind("ALT + SHIFT + V", "Clipboard manager (clipboard-history)",
|
o.bind("SUPER + SHIFT + V", "Clipboard manager (clipboard-history)",
|
||||||
"omarchy-shell shell toggle alanfortlink.clipboard")
|
"omarchy-shell alanfortlink.clipboard toggle")
|
||||||
```
|
```
|
||||||
|
|
||||||
(If your config is still legacy `bindings.conf`: `bindd = ALT SHIFT, V, …`.)
|
(If your config is still legacy `bindings.conf`: `bindd = ALT SHIFT, V, …`.)
|
||||||
@@ -92,8 +92,8 @@ Updating: `omarchy plugin update alanfortlink.clipboard` · Uninstall: `omarchy
|
|||||||
Pause/resume is also scriptable — useful for automation or a custom binding:
|
Pause/resume is also scriptable — useful for automation or a custom binding:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
omarchy-shell shell call alanfortlink.clipboard pause '{"paused":"toggle"}'
|
omarchy-shell alanfortlink.clipboard pause '{"paused":"toggle"}'
|
||||||
omarchy-shell shell call alanfortlink.clipboard isPaused
|
omarchy-shell alanfortlink.clipboard isPaused
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|||||||
+34
-18
@@ -5,7 +5,7 @@
|
|||||||
# - rescans + enables it (shell.json gets plugins[] entry; the built-in
|
# - rescans + enables it (shell.json gets plugins[] entry; the built-in
|
||||||
# omarchy.clipboard is recorded in disabledPlugins[] and routed here)
|
# omarchy.clipboard is recorded in disabledPlugins[] and routed here)
|
||||||
# - checks and installs dependencies transparently (QR/OCR degrade without them)
|
# - checks and installs dependencies transparently (QR/OCR degrade without them)
|
||||||
# - rebinds ALT+SHIFT+V from vicinae to this picker (backs up bindings.lua/.conf)
|
# - binds SUPER+SHIFT+V and ALT+SHIFT+V directly to this picker (with backup)
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
@@ -58,36 +58,52 @@ fi
|
|||||||
echo "==> Enabling $PLUGIN_ID (replaces built-in omarchy.clipboard)"
|
echo "==> Enabling $PLUGIN_ID (replaces built-in omarchy.clipboard)"
|
||||||
omarchy plugin enable "$PLUGIN_ID"
|
omarchy plugin enable "$PLUGIN_ID"
|
||||||
|
|
||||||
echo "==> Rebinding ALT+SHIFT+V"
|
echo "==> Binding SUPER+SHIFT+V and ALT+SHIFT+V directly to $PLUGIN_ID"
|
||||||
# Omarchy's live config may be bindings.lua (Quattro) or legacy bindings.conf —
|
# Do not route through `shell toggle`: plugin rescans can leave its panel Loader
|
||||||
# edit whichever exists and let the other alone.
|
# stale. The plugin-owned IPC target always controls the mapped picker window.
|
||||||
rebound=0
|
rebound=0
|
||||||
if [[ -f $HOME/.config/hypr/bindings.lua ]]; then
|
if [[ -f $HOME/.config/hypr/bindings.lua ]]; then
|
||||||
LUA="$HOME/.config/hypr/bindings.lua"
|
LUA="$HOME/.config/hypr/bindings.lua"
|
||||||
if grep -q 'omarchy-shell shell toggle alanfortlink.clipboard' "$LUA"; then
|
tmp=$(mktemp)
|
||||||
echo " bindings.lua already points at alanfortlink.clipboard"
|
python3 - "$LUA" >"$tmp" <<'PY'
|
||||||
rebound=1
|
import re, sys
|
||||||
elif grep -q 'ALT + SHIFT + V' "$LUA"; then
|
text = open(sys.argv[1]).read()
|
||||||
|
command = "omarchy-shell alanfortlink.clipboard toggle"
|
||||||
|
for chord in ("SUPER + SHIFT + V", "ALT + SHIFT + V"):
|
||||||
|
line = f'o.bind("{chord}", "Clipboard manager (clipboard-history)", "{command}")'
|
||||||
|
pattern = re.compile(r'^\s*o\.bind\("' + re.escape(chord) + r'".*$', re.M)
|
||||||
|
if pattern.search(text):
|
||||||
|
text = pattern.sub(line, text, count=1)
|
||||||
|
else:
|
||||||
|
text = text.rstrip() + "\n" + line + "\n"
|
||||||
|
sys.stdout.write(text)
|
||||||
|
PY
|
||||||
|
if ! cmp -s "$LUA" "$tmp"; then
|
||||||
cp "$LUA" "$LUA.bak.$(date +%s)"
|
cp "$LUA" "$LUA.bak.$(date +%s)"
|
||||||
sed -i 's|^o.bind("ALT + SHIFT + V", "Clipboard manager (vicinae)", "vicinae deeplink vicinae://launch/clipboard/history")|o.bind("ALT + SHIFT + V", "Clipboard manager (clipboard-history)", "omarchy-shell shell toggle alanfortlink.clipboard")|' "$LUA"
|
mv "$tmp" "$LUA"
|
||||||
echo " rebound in bindings.lua (vicinae binding replaced)"
|
echo " updated bindings.lua (backup created)"
|
||||||
|
else
|
||||||
|
rm -f "$tmp"
|
||||||
|
echo " bindings.lua already correct"
|
||||||
|
fi
|
||||||
rebound=1
|
rebound=1
|
||||||
fi
|
elif [[ -f $HOME/.config/hypr/bindings.conf ]]; then
|
||||||
fi
|
|
||||||
if [[ $rebound != 1 && -f $HOME/.config/hypr/bindings.conf ]] && grep -q "^bindd = ALT SHIFT, V, " "$HOME/.config/hypr/bindings.conf"; then
|
|
||||||
CONF="$HOME/.config/hypr/bindings.conf"
|
CONF="$HOME/.config/hypr/bindings.conf"
|
||||||
cp "$CONF" "$CONF.bak.$(date +%s)"
|
cp "$CONF" "$CONF.bak.$(date +%s)"
|
||||||
sed -i 's|^bindd = ALT SHIFT, V, .*|bindd = ALT SHIFT, V, Clipboard manager (clipboard-history), exec, omarchy-shell shell toggle alanfortlink.clipboard|' "$CONF"
|
sed -i '/^bindd = \(SUPER\|ALT\) SHIFT, V, /d' "$CONF"
|
||||||
echo " rebound in bindings.conf"
|
printf '%s\n' \
|
||||||
|
'bindd = SUPER SHIFT, V, Clipboard manager (clipboard-history), exec, omarchy-shell alanfortlink.clipboard toggle' \
|
||||||
|
'bindd = ALT SHIFT, V, Clipboard manager (clipboard-history), exec, omarchy-shell alanfortlink.clipboard toggle' >>"$CONF"
|
||||||
|
echo " updated bindings.conf (backup created)"
|
||||||
rebound=1
|
rebound=1
|
||||||
fi
|
fi
|
||||||
if (( rebound )); then
|
if (( rebound )); then
|
||||||
hyprctl reload >/dev/null
|
hyprctl reload >/dev/null
|
||||||
else
|
else
|
||||||
echo " no ALT+SHIFT+V binding found — add manually to ~/.config/hypr/bindings.lua:"
|
echo "ERROR: no live Hyprland bindings file found" >&2
|
||||||
echo ' o.bind("ALT + SHIFT + V", "Clipboard manager (clipboard-history)", "omarchy-shell shell toggle alanfortlink.clipboard")'
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Done. Press ALT+SHIFT+V to open the clipboard picker."
|
echo "Done. Press SUPER+SHIFT+V (or ALT+SHIFT+V) to open the clipboard picker."
|
||||||
echo "Edit code in $REPO_DIR; run 'omarchy-shell shell rescanPlugins' after changes."
|
echo "Edit code in $REPO_DIR; run 'omarchy-shell shell rescanPlugins' after changes."
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
"schemaVersion": 1,
|
"schemaVersion": 1,
|
||||||
"id": "alanfortlink.clipboard",
|
"id": "alanfortlink.clipboard",
|
||||||
"name": "Clipboard History",
|
"name": "Clipboard History",
|
||||||
"version": "1.0.4",
|
"version": "1.0.5",
|
||||||
"author": "alanfortlink",
|
"author": "alanfortlink",
|
||||||
"description": "Raycast-style clipboard history: fuzzy search over content, type, app and date, with rich per-type previews",
|
"description": "Raycast-style clipboard history: fuzzy search over content, type, app and date, with rich per-type previews",
|
||||||
"kinds": [
|
"kinds": [
|
||||||
|
|||||||
Reference in New Issue
Block a user