diff options
author | ensa <@> | 2023-02-04 20:03:47 -0800 |
---|---|---|
committer | ensa <@> | 2023-02-04 20:52:52 -0800 |
commit | 75ee668954833ab6ba9287ed5eb16a9957edcac2 (patch) | |
tree | 07d9f88939ab0fd93d93c6f4ddbbc7b548a812f0 /bin | |
parent | ebae3707b36e9a83014ef08271d75bd9826bb999 (diff) | |
download | cfg-75ee668954833ab6ba9287ed5eb16a9957edcac2.tar.gz |
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
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/bother | 23 | ||||
-rwxr-xr-x | bin/comm-sel | 13 | ||||
-rwxr-xr-x | bin/fcard | 45 | ||||
-rwxr-xr-x | bin/fl | 30 | ||||
-rw-r--r-- | bin/flc | 4 | ||||
-rwxr-xr-x | bin/kbsetup | 2 | ||||
-rwxr-xr-x | bin/lh | 19 | ||||
-rwxr-xr-x | bin/metamv | 8 | ||||
-rwxr-xr-x | bin/notif | 17 | ||||
-rwxr-xr-x | bin/op | 2 | ||||
-rwxr-xr-x | bin/smv | 10 | ||||
-rwxr-xr-x | bin/xbg | 2 | ||||
-rwxr-xr-x | bin/yw | 4 |
13 files changed, 125 insertions, 54 deletions
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/urandom|fold -w 4|head -1 +} +grabbag() { +# digit urandom % number applicable lines + size="$(wc -l)" + oldlist="$(cat)" + newlist="" + a=0 + while a="$size"; do + z="$(($(rand)%a))" + newlist="$(cut -d ' ' -f "$z"<<EOF +$oldlist +EOF +) " + oldlist="$(cut -d ' ' -f "-$((z-1)),$((z+1))-" <<EOF +$oldlist +EOF +)" +# add z to space-delim'd list +# remove from input list + a=$((a-1)) + done + printf '%s\n' "$newlist" +} +for num in $(eval 'grep -n "${2:-.}"\$ "$1"|cut -d : -f 1'"$RAND"); do + sed -n "$num"P "$1" | cut -f 1 | tr '\n' '\t' + read -r _ + sed -n "$num"P "$1" | cut -f 2 | sed '/^$/D' + printf '\n' +done diff --git a/bin/fl b/bin/fl index bd98a63..cc8924a 100755 --- a/bin/fl +++ b/bin/fl @@ -5,28 +5,34 @@ # from pure-sh-bible, strips from the start of a string lstrip() { - printf '%s\n' "${1##$2}" + printf '%s\n' "${1##"$2"}" } -# put url-finding regex in a variable so no lines go over 80 chars -re_urls='((https?://|www\.)[[:alnum:].]*:?[[:alnum:]./@$&%?$#=_-]*)' +# url-finding regex +re_urls='(((https?|aesgcm)://|www\.)[[:alnum:].]*:?[[:alnum:]./@$&%?$#=_-]*)' # finds links, puts them in a list # sort -u prevents duplicates, but also sorts the links urlparse() { - lstrip "$(cat)" "*\│" | + input="$(if [ -n "$1" ]; then printf '%s\n' "$*"; else cat; fi)" + lstrip "$input" "*\│" | grep -Eo "$re_urls" | sort -u | sed 's|^www.|http://www\.|g' } -if [ -n "$1" ]; then - urls=$(echo "$@"|urlparse) -else - urls=$(urlparse) -fi + +set -- $(urlparse "$@") # wipe IFS so dmenu handles being sent the links properly IFS= -# send any found links to dmenu so one can be chosen to be sent to the clipboard -[ -n "$urls" ] && - echo $urls | dmenu -i -p 'copy which url?' -l 10 | xclip -r -sel c \ No newline at end of file +# send any found links to select so one can be chosen to be sent to the clipboard +#select url; +#do +# printf '%s' "$url" +#done +for url; do + printf '%s\n' "$url" +done + +#[ -n "$urls" ] && +# echo $urls | dmenu -i -p 'copy which url?' -l 10 | xclip -r -sel c diff --git a/bin/flc b/bin/flc new file mode 100644 index 0000000..718d3ef --- /dev/null +++ b/bin/flc @@ -0,0 +1,4 @@ +#!/bin/sh +fl "$@"| +dmenu -i -p 'copy which url?' -l 10| +xsel -ib diff --git a/bin/kbsetup b/bin/kbsetup index df100ff..5dcbfdb 100755 --- a/bin/kbsetup +++ b/bin/kbsetup @@ -1,6 +1,4 @@ #!/bin/sh setxkbmap -option caps:shift -layout us -variant dvp -xmodmap $HOME_ETC/betteresc -xcape -e 'Hyper_L=Escape' xcape -e 'Control_L=Control_L|b' xset r rate 300 50 diff --git a/bin/lh b/bin/lh index 71bc747..07be403 100755 --- a/bin/lh +++ b/bin/lh @@ -53,27 +53,28 @@ findredir() { while [ $# -ne 0 ] do # handle redirects. tr removes control characters, so the case statement below works as expected. -URL=$(echo "$1"|findredir|tail -1|tr -d '[:cntrl:]') +URL="$(echo "$1"|findredir|tail -1|tr -d '[:cntrl:]')" # if there were no redirects, just set URL to the first argument [ -z "$URL" ] && URL="$1" case "$URL" in gemini://*|gopher://*) - $TERMINAL -e bombadillo "$URL" ;; + "$TERMINAL" -e bombadillo "$URL" ;; *.mov*|*.mkv*|*.webm*|*.mp4*) mpv --no-terminal "$URL" & ;; - *invidio.us/watch*|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*hooktube.com*|*bitchute.com*|*twitch.tv/videos/*|*twitch.tv/*/v/*) - mpv --no-terminal --ytdl "$URL" & ;; + *invidio.us/watch*|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*bitchute.com*|*twitch.tv/videos/*|*twitch.tv/*/v/*|*clips.twitch.tv*|*streamable.com*) + yw "$URL" & ;; *twitch.tv/*) STREAMQUAL="$(split "$(streamlink "$URL"|grep 'Available streams')" ", "|\ grep -E "[0-9]"|\ dmenu -p "choose stream quality for $URL")" - streamlink -p mpv $URL $STREAMQUAL >/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 |