QR decode support (zbarimg) with searchable payload + preview panel; restructure repo root as installable omarchy plugin; plain-text safety for QR payloads
This commit is contained in:
Executable
+39
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
# Paste (or just copy) a history entry from the tank.clipboard store.
|
||||
# Usage: paste-entry.sh <entry-id> [--copy-only]
|
||||
set -euo pipefail
|
||||
|
||||
STATE="$HOME/.local/state/omarchy/clipboard-history-rich.json"
|
||||
ID="${1:-}"
|
||||
MODE="${2:-}"
|
||||
|
||||
[[ -n $ID && -r $STATE ]] || exit 0
|
||||
|
||||
entry=$(jq -c --arg id "$ID" '[.[] | select(.id == $id)][0]' "$STATE") || exit 0
|
||||
[[ $entry != "null" && -n $entry ]] || exit 0
|
||||
|
||||
type=$(jq -r '.type' <<<"$entry")
|
||||
|
||||
case "$type" in
|
||||
image)
|
||||
path=$(jq -r '.path' <<<"$entry")
|
||||
mime=$(jq -r '.mime // "image/png"' <<<"$entry")
|
||||
[[ -r $path ]] || exit 0
|
||||
wl-copy --type "$mime" <"$path"
|
||||
;;
|
||||
files)
|
||||
while IFS= read -r p; do
|
||||
printf 'file://%s\n' "$(python3 -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1]))' "$p")"
|
||||
done < <(jq -r '.paths[]' <<<"$entry") | wl-copy --type text/uri-list
|
||||
;;
|
||||
*)
|
||||
jq -j '.text' <<<"$entry" | wl-copy
|
||||
;;
|
||||
esac
|
||||
|
||||
[[ $MODE == "--copy-only" ]] && exit 0
|
||||
|
||||
# Give the layer surface a moment to close and focus to fall back to the
|
||||
# previously-focused window, then paste via the universal Shift+Insert.
|
||||
sleep 0.15
|
||||
wtype -M shift -k Insert -m shift 2>/dev/null || true
|
||||
Reference in New Issue
Block a user