dotfiles/.local/bin/clipboard-to-qr.sh

20 lines
419 B
Bash
Raw Normal View History

2022-03-31 17:15:31 +02:00
#! /bin/bash
if [ "$XDG_SESSION_TYPE" = "wayland" ];
then
CLIPBOARD_STRING=$(wl-paste)
elif [ "$XDG_SESSION_TYPE" = "x11" ];
then
CLIPBOARD_STRING=$(xclip -s c -o)
else
echo "This script needs *either* wayland *or* X11 running." >&2
exit 1
fi
if [ "$1" = "-console" ];
then
qrencode -8 -l M -t ANSI256UTF8 "$CLIPBOARD_STRING"
else
qrencode -d 96 -8 -l M -o - "$CLIPBOARD_STRING" | feh -ZF --force-aliasing -
fi