From 75ee668954833ab6ba9287ed5eb16a9957edcac2 Mon Sep 17 00:00:00 2001 From: ensa <@> Date: Sat, 4 Feb 2023 20:03:47 -0800 Subject: restructure, cleanups, greener pastures, new additions config and data are now etc and share, to better match my homedir bin: generally, shellcheck errors (where there's actually a problem) have been fixed bother now includes alternate support for libnotify as well as my notif comm-sel now loops, so spawning programs doesn't require multiple runs fcard: my flashcard script accepts a tsv's path on $1, expecting: the word on column 1 the defintion on column 2 (optional) the section on column 3 if $2 is specified, only runs through lines with that string as its section fl: added aesgcm to the url detector string, because of profanity cleaned up urlparse now outputs the urls, one per line, making it more unixy flc: a quick script. uses fl's output to do what fl once did on its own. kbsetup now lacks escape xcape magic, qmk does that for me now. lh: general cleanup. added and removed a site for the video extract section metamv: gives arguments self-describing names based off metadata. mainly just for sorting FLACs off bandcamp this might not be entirely safe. use your own discretion. notif: xnotify wasn't happy with the previous design. it was sending notifications in pieces. this new one's an absolute mess but it works well, is smaller, and faster op: changed the pdf bit to allow variants smv: file is self-explanatory applies the pipeline specified in "$1" to every file name specified after it xbg: contains a fallback if xwallpaper isn't downloaded or its path is empty. yw: just a quick and dirty line for watching things in mpv using yt-dlp. etc: X11/: xprofile now includes the latest xnotify initialization. xresources prevents a variable collision also updates new xnotify resource names and changes which program to pipe the screen to. mpd/mpd.conf just updates to path structure. yt-dlp/* too many changes to describe. should be fairly self-explanatory. ksh/: prompt.ksh: the $ is green now. hooray! lf/lfrc: removed ttmsh function. i use my server for that now. newsboat/config: external-url-viewer is now non-python. zathura/zathurarc: font is now hermit. aliasrc: exa is no more. vis is also no more. youtube-dl is dead. long live yt-dlp. shrc: locale vars changed to ones than glibc is ok with --- bin/bother | 23 +++++++++++++---------- bin/comm-sel | 13 ++++++++----- bin/fcard | 45 +++++++++++++++++++++++++++++++++++++++++++++ bin/fl | 30 ++++++++++++++++++------------ bin/flc | 4 ++++ bin/kbsetup | 2 -- bin/lh | 19 ++++++++++--------- bin/metamv | 8 ++++++++ bin/notif | 17 +++-------------- bin/op | 2 +- bin/smv | 10 ++++++++++ bin/xbg | 2 +- bin/yw | 4 ++++ 13 files changed, 125 insertions(+), 54 deletions(-) create mode 100755 bin/fcard create mode 100644 bin/flc create mode 100755 bin/metamv create mode 100755 bin/smv create mode 100755 bin/yw (limited to 'bin') diff --git a/bin/bother b/bin/bother index d3f5be9..be6de1c 100755 --- a/bin/bother +++ b/bin/bother @@ -1,24 +1,27 @@ #!/bin/sh # puts up a critical notification if $HOME/today exists, containing the contents of that file. if [ -z "$XFILE" ]; then -if [ -f $HOME/.xsession ]; then - XFILE=$HOME/.xsession -elif [ -f $HOME/.xinitrc ]; then - XFILE=$HOME/.xinitrc +if [ -f "$HOME"/.xsession ]; then + XFILE="$HOME"/.xsession +elif [ -f "$HOME"/.xinitrc ]; then + XFILE="$HOME"/.xinitrc fi fi -if grep -q "dwm" $XFILE; then +if grep -q "dwm" "$XFILE"; then WM=dwm -elif grep -q 'exec' $XFILE; then - WM=$(grep 'exec' $XFILE|cut -f 2 -d ' ' -) +elif grep -q 'exec' "$XFILE"; then + WM=$(grep 'exec' "$XFILE"|cut -f 2 -d ' ') +elif grep -q wm "$XFILE"; then + WM=$(grep wm "$XFILE"|cut -f 2 -d ' ') else - WM=$(tail -1 $XFILE) + WM=$(tail -1 "$XFILE") fi if [ -f "$HOME"/today ]; then - until pgrep $WM>/dev/null + until pgrep "$WM">/dev/null do : done sleep 0.5 - notif "DO TODAY:" "$(tr '\n' '\t'<"$HOME"/today)" + notif -s 0 "DO TODAY:" "$(tr '\n' '\t'<"$HOME"/today)" +# notify-send -t 0 "DO TODAY:" "$(cat<"$HOME"/today)" fi diff --git a/bin/comm-sel b/bin/comm-sel index 3dc1527..70c2e77 100755 --- a/bin/comm-sel +++ b/bin/comm-sel @@ -6,8 +6,11 @@ case "$TERMINAL" in urxvt) CLASS='-name';; alacritty|kitty) CLASS='--class';; esac -case "$(dmenu_path|grep -E "catgirl$|scli$"|dmenu -p "choose chat app:")" in - catgirl) catgirl-open.sh &;; - scli) $TERMINAL $CLASS comm -e scli&;; - *) return;; -esac +while + case "$(dmenu_path|(grep -E 'catgirl$|profanity$';printf 'exit\n')|dmenu -p 'choose chat app:')" in + catgirl) catgirl-open.sh &;; + profanity) "$TERMINAL" "$CLASS" comm -e profanity&;; + *) return 1;; + esac +do : +done diff --git a/bin/fcard b/bin/fcard new file mode 100755 index 0000000..e4a851d --- /dev/null +++ b/bin/fcard @@ -0,0 +1,45 @@ +#!/bin/sh +# flash card substitute +# usage: fcard dict.tsv section +# the -z code is extremely wip, don't use it + +while getopts z: opt +do + case $opt in + z) RAND="|grabbag" ;; + ?) printf '%s\n' "idiot" 1>&2 && exit 2 ;; + esac +done +shift $((OPTIND - 1)) + +rand() { + tr -cd '[:digit:]'/dev/null 2>&1 & ;; - *.png*|*.jpg*|*.jpe*|*.jpeg*|*.gif*) + streamlink -p mpv "$URL" "$STREAMQUAL" >/dev/null 2>&1 & ;; + *.png*|*.jp[eg]*|*.gif*) IMGPATH="/tmp/$(lstrip "$URL" "*/")" - curl -sL "$URL" >"$IMGPATH"&&sxiv -pqa "$IMGPATH" & ;; - *.mp3*|*.m4a*|*.flac*|*.aiff*|*.opus*|*.ogg*|*.mp3?source*|*.wav*) + curl -sL "$URL" > "$IMGPATH" && + sxiv -pqa "$IMGPATH" & ;; + *.mp3*|*.m4a*|*.flac*|*.aiff*|*.opus*|*.ogg*|*.wav*) $TERMINAL -e mpv "$URL"& ;; *.epub*|*.pdf*|*.djvu*) BOOKPATH="/tmp/$(lstrip "$URL" "*/")" @@ -86,7 +87,7 @@ case "$URL" in if [ -f "$URL" ]; then op "$URL" else - $BROWSER "$URL" >/dev/null 2>&1 & + "$BROWSER" "$URL" >/dev/null 2>&1 & fi ;; esac shift diff --git a/bin/metamv b/bin/metamv new file mode 100755 index 0000000..3a2d8ba --- /dev/null +++ b/bin/metamv @@ -0,0 +1,8 @@ +#!/bin/sh +# usage: metamv FILE ... +# e.g: metamv *.flac +for file; do + num="$(exiftool -m -p '$tracknumber$track' -- "$file")" + [ "$num" -lt 10 ] && num=0"$num" + mv -- "$file" "$num-$(exiftool -p '$artist-$title.$filetypeextension' -- "$file")" +done diff --git a/bin/notif b/bin/notif index 5e75fd8..ad1b625 100755 --- a/bin/notif +++ b/bin/notif @@ -1,7 +1,7 @@ #!/bin/sh # sends xnotify a notification unset TAG SEC -exec > ${XNOTIFY_FIFO:=$HOME_CACHE/xnotify$DISPLAY.fifo} +exec > "${XNOTIFY_FIFO:=$HOME_CACHE/xnotify.fifo}" ug_err() { echo "${1}" 1>&2 && return "${2:-1}" @@ -20,16 +20,5 @@ while getopts s:t: arg; do *) usage;; esac done -if [ -n "$SEC" ]; then - printf 'SEC:%s\t' "$SEC" - shift 2 -fi -if [ -n "$TAG" ]; then - printf 'TAG:%s\t' "$TAG" - shift 2 -fi -case "$#" in - 1) printf '%s\n' "$1";; - 2) printf '%s\t%s\n' "$1" "$2";; - *) exit;; -esac +shift $((OPTIND - 1)) +printf ${SEC+SEC:%s"\t"}${TAG+TAG:%s"\t"}${2+%s"\t"}'%s\n' $SEC $TAG "$1" "$2" diff --git a/bin/op b/bin/op index 688912b..7d426fc 100755 --- a/bin/op +++ b/bin/op @@ -12,7 +12,7 @@ echo() { } case "$FILEMIME" in #ebooks - application/epub*|application/pdf|application/postscript|image/vnd.djvu) + application/epub*|application/pdf*|application/postscript|image/vnd.djvu) ${READER:-zathura} "$FILEPATH">/dev/null 2>&1 & ;; #videos video/*) diff --git a/bin/smv b/bin/smv new file mode 100755 index 0000000..742d1d3 --- /dev/null +++ b/bin/smv @@ -0,0 +1,10 @@ +#!/bin/sh +# smv: special move +# smv pipeline file1 file2 file3 ... +# $1 is the pipeline to apply to the filenames of the files listed +CMD="$1" +shift +for file +do + mv "$file" "$(printf "$file"|sh -c "$CMD")" +done diff --git a/bin/xbg b/bin/xbg index 339ed69..a94ae67 100755 --- a/bin/xbg +++ b/bin/xbg @@ -8,4 +8,4 @@ else PICPATH=${PICPATH:="$HOME/Pictures/bg.png"} fi [ -n "$1" ]&&ln -sf "$1" "$PICPATH" -xwallpaper --zoom "$PICPATH" +xwallpaper --zoom "$PICPATH"||xsetroot -solid '#14130e' diff --git a/bin/yw b/bin/yw new file mode 100755 index 0000000..4e0337f --- /dev/null +++ b/bin/yw @@ -0,0 +1,4 @@ +#!/bin/sh +# for streaming things from yt-dlp to mpv. $1 is the url +yt-dlp -f b/bv*+ba --external-downloader curl -o - "$1" 2> $HOME_LOG/ytdl.log | mpv - > /dev/null +rm -f -- -.*.vtt -- cgit 1.4.1-2-gfad0