From 0a5d62909bbffb54e604c3d85a886c2d5a545f11 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Tue, 3 Oct 2023 13:03:05 +0200 Subject: [PATCH] sh: Switch timg qr function to use viu Since we switched to viu, we should also have qr make use of it. Renamed the function to qrurl to make its purpose clearer (sending a simple file location/string/url via qr code) and to distinguish it from programs like qrcp which actually start a server and send a file through qr. --- sh/.config/sh/alias.d/timg.sh | 32 -------------------------------- sh/.config/sh/alias.d/viu.sh | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 32 deletions(-) delete mode 100644 sh/.config/sh/alias.d/timg.sh create mode 100644 sh/.config/sh/alias.d/viu.sh diff --git a/sh/.config/sh/alias.d/timg.sh b/sh/.config/sh/alias.d/timg.sh deleted file mode 100644 index fb0d7e0..0000000 --- a/sh/.config/sh/alias.d/timg.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env sh -# Add simple 'image ls' for a directory using timg -# -# Prints a thumbnail gallery right in the terminal. -# WILL stutter when you go crazy in a hundred/thousand -# picture folder. - -if exist timg; then - il() { - images=$(find . -maxdepth 1 -type f -exec file --mime-type {} \+ | awk -F: '{if ($2 ~/image\//) print $1}') - if [ -z "$images" ]; then { - echo no images found. - return - }; fi - echo "$images" | timg --grid=4x3 --upscale=i --center --title --frames=1 -f - - } - IL() { - images=$(find . -type f -exec file --mime-type {} \+ | awk -F: '{if ($2 ~/image\//) print $1}') - if [ -z "$images" ]; then { - echo no images found. - return - }; fi - echo "$images" | timg --grid=4x3 --upscale=i --center --title --frames=1 -f - - } - qr() { - # if we are in a pipe, read from stdin and set fct arguments to it - if [ ! -t 0 ]; then - set -- "$(cat /dev/stdin)" - fi - qrencode -s1 -m2 "$@" -o- | timg --upscale=i - - } -fi diff --git a/sh/.config/sh/alias.d/viu.sh b/sh/.config/sh/alias.d/viu.sh new file mode 100644 index 0000000..639224a --- /dev/null +++ b/sh/.config/sh/alias.d/viu.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env sh +# A nice little qc url creator. +# Takes whatever is passed and makes it qr-code readable +# + +if exist viu; then + qrurl() { + # if we are in a pipe, read from stdin and set fct arguments to it + if [ ! -t 0 ]; then + set -- "$(cat /dev/stdin)" + fi + qrencode -s1 -m2 "$@" -o- | viu --upscale=i - + } +fi