diff options
| author | EuAndreh <eu@euandre.org> | 2022-04-24 12:55:17 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2022-04-24 12:55:17 -0300 |
| commit | 5fd29a52fb19d23df65bc91e7309e9a526fc0501 (patch) | |
| tree | d56cae2004936e2d938f49d5f72b73cd31ec2396 | |
| parent | ~/.local/bin/backup: Add polished backup script (diff) | |
| download | dotfiles-5fd29a52fb19d23df65bc91e7309e9a526fc0501.tar.gz dotfiles-5fd29a52fb19d23df65bc91e7309e9a526fc0501.tar.xz | |
~/.local/bin/qr: Add script
| -rwxr-xr-x | .local/bin/qr | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/.local/bin/qr b/.local/bin/qr new file mode 100755 index 00000000..4821a46c --- /dev/null +++ b/.local/bin/qr @@ -0,0 +1,58 @@ +#!/bin/sh +set -eu + +usage() { + cat <<-'EOF' + Usage: + qr [-s PIXEL_SIZE] + qr -h + EOF +} + +help() { + cat <<-'EOF' + + Options: + -s PIXEL_SIZE size of the pixel (default 10) + -h, --help show this help message + + Read data from STDIN and present a QR image with said data. + EOF +} + +for flag in "$@"; do + case "$flag" in + --) + break + ;; + --help) + usage + help + exit + ;; + *) + ;; + esac +done + +PIXEL_SIZE=10 +while getopts 's:h' flag; do + case "$flag" in + s) + PIXEL_SIZE="$OPTARG" + ;; + h) + usage + help + exit + ;; + *) + usage >&2 + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) + + +cat | qrencode -s "$PIXEL_SIZE" -o- | feh - |
