Add legacy install and shortcut migration
This commit is contained in:
@@ -76,6 +76,25 @@ o.bind("SUPER + SHIFT + V", "Clipboard manager",
|
||||
|
||||
Updating: `omarchy plugin update alanfortlink.clipboard` · Uninstall: `omarchy plugin remove alanfortlink.clipboard`
|
||||
|
||||
### Upgrading a legacy `tank.clipboard` installation
|
||||
|
||||
Remove either old plugin id, install the current release, repair legacy direct
|
||||
bindings to Omarchy's clone-aware source id, then restart the shell:
|
||||
|
||||
```bash
|
||||
for id in tank.clipboard alanfortlink.clipboard; do
|
||||
[[ -e "$HOME/.config/omarchy/plugins/$id" || -L "$HOME/.config/omarchy/plugins/$id" ]] && \
|
||||
omarchy plugin remove "$id" --yes
|
||||
done
|
||||
omarchy plugin add https://github.com/alanfortlink/clipboard-history.git --enable --yes
|
||||
bash "$HOME/.config/omarchy/plugins/alanfortlink.clipboard/scripts/configure-bindings.sh"
|
||||
omarchy restart shell
|
||||
```
|
||||
|
||||
Clipboard history data is preserved. The repaired shortcuts always target
|
||||
`omarchy.clipboard`: Omarchy routes them to this plugin while installed and
|
||||
back to its built-in clipboard after removal.
|
||||
|
||||
## Keys
|
||||
|
||||
| Key | Action |
|
||||
|
||||
+3
-45
@@ -38,7 +38,8 @@ mkdir -p "$PLUGINS_DIR"
|
||||
ln -sTfn "$PLUGIN_DIR" "$PLUGINS_DIR/$PLUGIN_ID"
|
||||
# On other machines, install directly from git instead:
|
||||
# omarchy plugin add <this-repo-git-url> --enable
|
||||
chmod +x "$PLUGIN_DIR"/capture.py "$PLUGIN_DIR"/paste-entry.sh "$PLUGIN_DIR"/open-entry.sh
|
||||
chmod +x "$PLUGIN_DIR"/capture.py "$PLUGIN_DIR"/paste-entry.sh "$PLUGIN_DIR"/open-entry.sh \
|
||||
"$PLUGIN_DIR"/scripts/configure-bindings.sh
|
||||
|
||||
echo "==> Rescanning shell plugins"
|
||||
omarchy-shell shell rescanPlugins >/dev/null
|
||||
@@ -59,50 +60,7 @@ echo "==> Enabling $PLUGIN_ID (replaces built-in omarchy.clipboard)"
|
||||
omarchy plugin enable "$PLUGIN_ID"
|
||||
|
||||
echo "==> Binding SUPER+SHIFT+V and ALT+SHIFT+V to the clipboard source"
|
||||
# Always target the built-in source id. Omarchy routes it to this clone while
|
||||
# installed, then automatically routes it back to the built-in after removal.
|
||||
rebound=0
|
||||
if [[ -f $HOME/.config/hypr/bindings.lua ]]; then
|
||||
LUA="$HOME/.config/hypr/bindings.lua"
|
||||
tmp=$(mktemp)
|
||||
python3 - "$LUA" >"$tmp" <<'PY'
|
||||
import re, sys
|
||||
text = open(sys.argv[1]).read()
|
||||
command = "omarchy-shell shell toggle omarchy.clipboard"
|
||||
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)"
|
||||
mv "$tmp" "$LUA"
|
||||
echo " updated bindings.lua (backup created)"
|
||||
else
|
||||
rm -f "$tmp"
|
||||
echo " bindings.lua already correct"
|
||||
fi
|
||||
rebound=1
|
||||
elif [[ -f $HOME/.config/hypr/bindings.conf ]]; then
|
||||
CONF="$HOME/.config/hypr/bindings.conf"
|
||||
cp "$CONF" "$CONF.bak.$(date +%s)"
|
||||
sed -i '/^bindd = \(SUPER\|ALT\) SHIFT, V, /d' "$CONF"
|
||||
printf '%s\n' \
|
||||
'bindd = SUPER SHIFT, V, Clipboard manager, exec, omarchy-shell shell toggle omarchy.clipboard' \
|
||||
'bindd = ALT SHIFT, V, Clipboard manager, exec, omarchy-shell shell toggle omarchy.clipboard' >>"$CONF"
|
||||
echo " updated bindings.conf (backup created)"
|
||||
rebound=1
|
||||
fi
|
||||
if (( rebound )); then
|
||||
hyprctl reload >/dev/null
|
||||
else
|
||||
echo "ERROR: no live Hyprland bindings file found" >&2
|
||||
exit 1
|
||||
fi
|
||||
"$PLUGIN_DIR/scripts/configure-bindings.sh"
|
||||
|
||||
echo
|
||||
echo "Done. Press SUPER+SHIFT+V (or ALT+SHIFT+V) to open the clipboard picker."
|
||||
|
||||
Executable
+70
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
# Configure clipboard shortcuts through Omarchy's clone-aware source id.
|
||||
# The same bindings open alanfortlink.clipboard while installed and the
|
||||
# built-in omarchy.clipboard after this plugin is disabled or removed.
|
||||
set -euo pipefail
|
||||
|
||||
HYPR_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/hypr"
|
||||
LUA="$HYPR_DIR/bindings.lua"
|
||||
CONF="$HYPR_DIR/bindings.conf"
|
||||
STAMP=$(date +%s)
|
||||
changed=0
|
||||
|
||||
if [[ -f $LUA ]]; then
|
||||
tmp=$(mktemp)
|
||||
trap 'rm -f "${tmp:-}"' EXIT
|
||||
python3 - "$LUA" >"$tmp" <<'PY'
|
||||
import re
|
||||
import sys
|
||||
|
||||
path = sys.argv[1]
|
||||
text = open(path, encoding="utf-8").read()
|
||||
command = "omarchy-shell shell toggle omarchy.clipboard"
|
||||
for chord in ("SUPER + SHIFT + V", "ALT + SHIFT + V"):
|
||||
line = f'o.bind("{chord}", "Clipboard manager", "{command}")'
|
||||
pattern = re.compile(r'^\s*o\.bind\("' + re.escape(chord) + r'".*$', re.MULTILINE)
|
||||
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.clipboard.$STAMP"
|
||||
mv "$tmp" "$LUA"
|
||||
changed=1
|
||||
echo "Updated $LUA (backup: $LUA.bak.clipboard.$STAMP)"
|
||||
else
|
||||
echo "$LUA already uses clone-aware clipboard bindings"
|
||||
fi
|
||||
elif [[ -f $CONF ]]; then
|
||||
tmp=$(mktemp)
|
||||
trap 'rm -f "${tmp:-}"' EXIT
|
||||
grep -vE '^bindd = (SUPER|ALT) SHIFT, V, ' "$CONF" >"$tmp" || true
|
||||
printf '%s\n' \
|
||||
'bindd = SUPER SHIFT, V, Clipboard manager, exec, omarchy-shell shell toggle omarchy.clipboard' \
|
||||
'bindd = ALT SHIFT, V, Clipboard manager, exec, omarchy-shell shell toggle omarchy.clipboard' >>"$tmp"
|
||||
if ! cmp -s "$CONF" "$tmp"; then
|
||||
cp "$CONF" "$CONF.bak.clipboard.$STAMP"
|
||||
mv "$tmp" "$CONF"
|
||||
changed=1
|
||||
echo "Updated $CONF (backup: $CONF.bak.clipboard.$STAMP)"
|
||||
else
|
||||
echo "$CONF already uses clone-aware clipboard bindings"
|
||||
fi
|
||||
else
|
||||
echo "configure-bindings: no bindings.lua or bindings.conf found in $HYPR_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if (( changed )); then
|
||||
hyprctl reload >/dev/null
|
||||
fi
|
||||
|
||||
errors=$(hyprctl configerrors)
|
||||
if [[ -n $errors ]]; then
|
||||
printf '%s\n' "$errors" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Clipboard shortcuts ready: SUPER+SHIFT+V and ALT+SHIFT+V"
|
||||
Reference in New Issue
Block a user