Files
nix/hosts/common/configs/user/gui/clipbook/copy.sh
Nikolaos Karaolidis 2888bb8b72 Add treefmt
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
2025-02-16 18:53:11 +00:00

26 lines
468 B
Bash
Executable File

# shellcheck shell=bash
list() {
echo -en "\0keep-selection\x1ftrue\n"
jq -r 'keys[]' "$BOOKMARKS"
}
handle() {
key="$1"
data=$(jq -r --arg key "$key" '.[$key]' "$BOOKMARKS")
type=$(echo "$data" | jq -r '.type')
content=$(echo "$data" | jq -r '.content')
if [[ "$type" == "file" ]]; then
wl-copy < "$content"
elif [[ "$type" == "text" ]]; then
echo -n "$content" | wl-copy
fi
}
case ${ROFI_RETV} in
0) list ;;
1) handle "$@" ;;
esac