#!/bin/sh all () { fast userjs clean qb refl music usb xmr } clean () { nsxiv -c # my ways # -exec can't replace -execdir here find "$XDG_CACHE_HOME/nsxiv/" -depth -type d -empty -execdir rmdir -- '{}' \+ # -exec can replace -execdir here #find "$XDG_CACHE_HOME/nsxiv/" -depth -type d -execdir rmdir --ignore-fail-on-non-empty -- '{}' \+ # nsxiv man page way #find "$XDG_CACHE_HOME/nsxiv/" -depth -type d -empty ! -name '.' -exec rmdir -- '{}' \; cd "$HOME/.mozilla/firefox/xxxxxxxx.fly/prefsjs_backups" || exit # https://stackoverflow.com/a/34862475/9008720 ls -t | tail -n +11 | tr '\n' '\0' | xargs -0 rm -- # https://unix.stackexchange.com/questions/92095/reset-atq-list-to-zero sudo systemctl stop atd echo 0 | sudo tee /var/spool/atd/.SEQ > /dev/null sudo systemctl start atd rm -rf "$XDG_VIDEOS_DIR/recordings/tmp/" paru -aSc --noconfirm } # basic daily stuff fast () { pac misc } userjs () { kill $(pidof "$BROWSER") # change working dir for cleaner cd "$HOME/.mozilla/firefox/xxxxxxxx.fly" || exit arkenfox-cleaner -s arkenfox-updater -s } misc () { "$EDITOR" +PlugClean! +PlugUpdate +qa tldr --update sudo hardcode-fixer sudo units_cur awk '!a[$0]++' "$XDG_DATA_HOME/sdcv_history" | sponge "$XDG_DATA_HOME/sdcv_history" # temperory solution before find a way of using git submodule or subtree with `cfg -l` git --git-dir=/home/xyz/.mozilla/firefox/xxxxxxxx.fly/chrome/firefox-csshacks/.git/ --work-tree=/home/xyz/.mozilla/firefox/xxxxxxxx.fly/chrome/firefox-csshacks/ pull rustup update } pac () { pacpacs="$(sudo pacman --noconfirm -Syu | tee /dev/tty | grep '^Packages' | cut -d' ' -f3-)" aurpacs="$(paru --noconfirm -aSu --ignore libredwg-git | tee /dev/tty | grep '^Aur' | cut -d' ' -f3-)" # part steal from aur comment # sometimes "ERROR: Failure while downloading": https://github.com/neovim/neovim/issues/15709 # echo 1, printf 1 and yes 1 all works? not sure why # aur neovim-nightly-bin has some issue on 12/26/2021? switch to community repo neovim temporary #rm -rf ~/.cache/paru/clone/neovim-nightly-bin/ && echo 1 | PARU_PAGER=cat paru --rebuild --redownload neovim-nightly-bin sudo pacman -Fy pacman -Qqme > "$XDG_CONFIG_HOME/myconf/pacman_Qqme" pacman -Qqne > "$XDG_CONFIG_HOME/myconf/pacman_Qqne" systemctl list-unit-files --state=enabled > "$XDG_CONFIG_HOME/myconf/sye" systemctl --user list-unit-files --state=enabled > "$XDG_CONFIG_HOME/myconf/syue" # pacdiff default use pacman database, so no need `sudo -E` for find, but will be a little bit slower log="$log updated pacman packages: $pacpacs updated aur packages: $aurpacs pacdiff: $(pacdiff -o | tr '\n' ' ') checkrebuild: $(checkrebuild | awk '$2!="zoom"{printf("%s ",$2)}') " } qb () { rm -r -- "$HOME/programs/qbittorrent_search_plugins/" curlqb "$HOME/programs/qbittorrent_search_plugins/" } refl () { # why not use http: # https://www.reddit.com/r/archlinux/comments/kx149z/should_i_use_http_mirrors/ # https://www.reddit.com/r/archlinux/comments/ej4k4d/is_it_safe_to_use_not_secured_http_pacman_mirrors/ # rsync may need to change XferCommand in /etc/pacman.conf # https://www.reddit.com/r/archlinux/comments/mynw6e/rsync_mirrors_with_pacman/ sudo reflector --verbose --save /etc/pacman.d/mirrorlist --country us --protocol https --score 30 --latest 30 --fastest 10 } usb () { cfg -l push usb cfg -s push git --git-dir="$XDG_DOCUMENTS_DIR/notes/.git/" --work-tree="$XDG_DOCUMENTS_DIR/notes/" push usb git --git-dir="$HOME/programs/reminders/.git/" --work-tree="$HOME/programs/reminders/" push usb #rsync -navPR --delete ~/archive ~/documents ~/downloads ~/music ~/pictures ~/programs ~/test ~/videos ~/.local/share/stardict/dic ~/.local/share/qBittorrent ~/.local/share/sdcv_history ~/.cache/nsxiv ~/.config/qBittorrent ~/.bitmonero/wallets ~/.password-store /run/media/xyz/bd0 # --files-from make -a not imply -r, so need to specify explicitly rsync -avPRr --delete --files-from="$XDG_CONFIG_HOME/myconf/upd_rsync_files" / /run/media/xyz/bd0 # not sure if useful or not sync } xmr () { # 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 /run/media/xyz/bd0/archive/monero/blockchain.raw # not sure if useful or not sync } music () { yt-dlp -f 'bestaudio[ext=opus]/bestaudio' --match-filter 'license=cc-by' --match-filter 'title~=(?i)cc-by' -P "$XDG_MUSIC_DIR/cc_by/scott_buckley" https://soundcloud.com/scottbuckley/tracks } if [ $# -eq 0 ]; then fast else while getopts acfjmMpqrux opt; do case $opt in a)all;; c)clean;; f)fast;; j)userjs;; m)misc;; M)music;; p)pac;; q)qb;; r)refl;; u)usb;; x)xmr;; \?)exit 1;; esac done fi [ "$log" ] && printf '%s' "$log" | tee "$XDG_DOCUMENTS_DIR/logs/upd.log"