commit 1cb57b543cd8d5e76f8aa257065d8f9a5c74c47b parent be366dae1f51b21cfd1a19b0dd9e262abd258db7 Author: Matthew Carlson <matt@mcarlson.xyz> Date: Thu, 29 Jul 2021 12:07:18 -0400 pin script and ytfzf alias Diffstat:
M | .config/sh/aliasrc | | | 11 | ++++++----- |
A | .local/bin/pin.sh | | | 41 | +++++++++++++++++++++++++++++++++++++++++ |
2 files changed, 47 insertions(+), 5 deletions(-)
diff --git a/.config/sh/aliasrc b/.config/sh/aliasrc @@ -66,8 +66,9 @@ alias dots='/usr/bin/git --git-dir=${HOME}/.dots/ --work-tree=${HOME}' # youtube alias \ - yt="youtube-dl -i -o \"${DOWNLOADS_DIR}/%(uploader)s/%(title)s.%(ext)s\" --add-metadata" \ - yta='yt -f bestaudio/best -x' \ - ytp="youtube-dl -i -o \"${DOWNLOADS_DIR}/%(uploader)s/%(playlist_index)s-%(title)s.%(ext)s\" --add-metadata" \ - ytpa='ytp -f bestaudio/best -x' \ - ytall='yt -cw -f best' + yt="youtube-dl -i -o \"${DOWNLOADS_DIR}/%(uploader)s/%(title)s.%(ext)s\" --add-metadata" \ + yta='yt -f bestaudio/best -x' \ + ytp="youtube-dl -i -o \"${DOWNLOADS_DIR}/%(uploader)s/%(playlist_index)s-%(title)s.%(ext)s\" --add-metadata" \ + ytpa='ytp -f bestaudio/best -x' \ + ytall='yt -cw -f best' \ + ytw='ytfzf' diff --git a/.local/bin/pin.sh b/.local/bin/pin.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# +# pin + +get_pin() { + prompt='Pin' + + # get pin using dmenu and check + if pin="$(dmenu -c -p "${prompt}" -P 2>/dev/null)"; then + [ -n "${pin}" ] && printf '%s\n' "D ${pin}" + printf 'OK\n' + # operation cancelled + else printf 'ERR 99\n' + fi +} + +main() { + # export display + if [ -z "${DISPLAY}" ]; then + DISPLAY=':1' + export DISPLAY + fi + + # start msg + printf 'OK Pleased to meet you\n' + + # ipc + while read -r line; do + # cmds and data needed to interface with pinentry + cmd="$(printf '%s\n' "${line}" | cut -d ' ' -f 1)" + data="$(printf '%s\n' "${line}" | cut -d' ' -f 2-)" + + case "${cmd}" in + # GETPIN is command pinentry uses for GNUPG pass + GETPIN) get_pin ;; + *) printf 'OK\n' ;; + esac + done +} + +main "${@}"