#!/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 # use cd to workaround monero-blockchain-export.log log file save in current dir? issue, haven't tested cd "$HOME/.bitmonero" || exit monero-blockchain-export --output-file "$XDG_DOWNLOAD_DIR/xmr/monero_blockchain.raw" # the old way, slower and more code #nm_device_state="$(nmcli -t --fields device,state device)" #if echo "$nm_device_state" | grep -q '^wg_ka:connected$'; then # echo ka #elif echo "$nm_device_state" | grep -q '^wg_studio:connected$'; then # echo studio #else # echo insp #fi case "$(nmcli -t --fields device,state device)" in *wg_ia:connected*) echo ia;; *wg_ka:connected*) echo ka;; *wg_studio:connected*) echo studio;; *) echo insp;; esac printf 'default: '; curl -m1 ifconfig.co printf '4: '; curl -4m1 ifconfig.co printf '6: '; curl -6m1 ifconfig.co find "$HOME/archive/music" -type f -name '*.wav' -execdir sh -c ' for i; do ffmpeg -i "$i" "$i.flac" && rm "$i" done ' sh '{}' \+