summaryrefslogtreecommitdiffstatshomepage
path: root/dot_local/bin/executable_wqr
blob: b4cc123b1d8e1e8e20040e79400f09ebd7e3b634 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env dash

if [ -z "$1" ]; then
  text=$(wl-paste)
elif [ "$1" = "-" ]; then
  read -r text
else
  text="$1"
fi

if [ "$(cat "$HOME/.config/dotfiles/role" 2>/dev/null)" = canonical ]; then
  image=$(mktemp "${XDG_RUNTIME_DIR:?}/dotfiles-qr-XXXXXX.png")
  printf '%s' "$text" | qrencode -t PNG -o "$image"
  /usr/bin/xdg-open "$image"
else
  printf '%s' "$text" | qrencode -t PNG -o - | imv -
fi