#!/bin/sh # misc code snippets for cmd in pacdiff 'tree -a'; do alias ${cmd%% *}="sudo -E $cmd" done if [ -e "$XDG_PICTURES_DIR/wallpapers/wallpaper" ]; then display -window root "$XDG_PICTURES_DIR/wallpapers/wallpaper" & else shufwall & fi # ~/.config/nsxiv/exec/key-handler case "$1" in "l") linkwall ;; "w") tr '\n' '\0' | xargs -0 shufwall ;; esac linkwall() { tr '\n' '\0' | xargs -0 realpath | sort | uniq | while read -r file; do walldir="$XDG_PICTURES_DIR/wallpapers/" name=$(basename "$file") if [ ! -e "$walldir$name" ]; then convwall "$file" "$walldir$name" || ln -s "$file" "$walldir" else notify-send 'error' "$name exist" fi done } for cmd in czkawka_gui firefox freecad gimp krita mpv qmmp songrec zathura; do alias $cmd="o $cmd" done pidof -q monerod || alacritty -e monerod f () { while read -r site; do curl -sm5 "$site" | grep -iq "creative common\|cc-by\|cc-0\|gnu free documentation license\|gfdl\|unlicense\|wtfpl" && echo "$site" done } f < ~/downloads/blogs > ~/downloads/cc_blogs f < ~/downloads/news > ~/downloads/cc_news # parallel seems mess up rsync second argument's dir name's spaces, cause incorrect dir name. Bug? I choose to use xargs instead # maybe I should use parallel's --transfer or --transferfile options? #{ ssh-add -l || ssh-add;} && parallel -v -j2 -- rsync -vP {} '/home/xyz/a b' << EOF { ssh-add -l || ssh-add;} && xargs -P2 -I {} rsync -vP '{}' '/home/xyz/a b' << EOF ka:/home/xyz/a b/c d ka:/home/xyz/a b/c d EOF