blob: 0539a384d5c3b0fb26bcb77ff624917b2cfcd091 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
#!/bin/sh
all () {
fast
userjs
clean
refl
music
}
backup () {
# pull repos and branches from studio, one more backup for 321 backup rule
git -C "$HOME/programs/config_local_arch" checkout studio
git -C "$HOME/programs/config_local_arch" pull
git -C "$HOME/programs/config_local_arch" checkout ka
git -C "$HOME/programs/config_local_arch" pull
# push ka branch to gitlab, delete this after ditch gitlab
git -C "$HOME/programs/config_local_arch" push
(
umask 077
sudo -E git -C /root/programs/config_local_arch_secrets_ka pull
sudo -E git -C /root/programs/config_local_arch_secrets pull
)
# --files-from make -a not imply -r, so need to specify explicitly
rsync -avPRr --delete --files-from="$XDG_CONFIG_HOME/myconf/upd_rsync_files" / studio:/home/xyz/backup/master
# https://wiki.archlinux.org/title/Duplicity
# Need // for absolute path, see manpage URL FORMAT section. If not use //, will store to /home/xyz/home/xyz/...
# --files-from has a bug, this bug makes source url that is / not working while /home works, more see vq notes
duplicity --ssh-askpass --use-agent --encrypt-key 9790577D2BE328D46838117ED3F54FE03F3C68D6 --sign-key 05899270DF25BB1EEDF57BE824F769E5D08C9E9A --full-if-older-than 1Y --include-filelist "$XDG_CONFIG_HOME/myconf/upd_rsync_files" --exclude / / sftp://ka//home/xyz/backup
}
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
backup
}
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
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 -C "$HOME/.mozilla/firefox/xxxxxxxx.fly/chrome/firefox-csshacks" pull
git -C "$XDG_DOCUMENTS_DIR/notes" commit --all -m 'update'
git -C "$XDG_DOCUMENTS_DIR/notes" push
git -C "$HOME/programs/reminders" commit --all -m 'update'
git -C "$HOME/programs/reminders" push
pass git push
}
pac () {
pacpacs="$(sudo pacman --noconfirm -Syu | tee /dev/tty | grep '^Packages' | cut -d' ' -f3-)"
# Update rust toolchains before paru so paru can compile things in newest rust if needed.
rustup update
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
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|miniconda3"{printf("%s ",$2)}')
"
}
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/
# need --delay so no super out of sync mirrors
sudo reflector --verbose --save /etc/pacman.d/mirrorlist --country us --protocol https --delay 1 --latest 25 --score 25 --fastest 10
}
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 abcfjmMpr opt; do
case $opt in
a)all;;
b)backup;;
c)clean;;
f)fast;;
j)userjs;;
m)misc;;
M)music;;
p)pac;;
r)refl;;
\?)exit 1;;
esac
done
fi
[ "$log" ] && printf '%s' "$log" | tee "$XDG_DOCUMENTS_DIR/logs/upd.log"
|