Files
nix/hosts/common/configs/user/gui/clipbook/copy.sh
Nikolaos Karaolidis c907cdeca6 Add clipbook
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
2025-02-13 13:41:03 +00:00

24 lines
443 B
Bash
Executable File

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