sane-wipe: implement --verbose flag

This commit is contained in:
2025-09-22 19:11:31 +00:00
parent c14863a234
commit 7a699d2181

View File

@@ -1,16 +1,47 @@
#!/usr/bin/env nix-shell #!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash -p dconf -p libsecret -p procps -p systemdMinimal #!nix-shell -i bash -p bash -p dconf -p libsecret -p procps -p systemdMinimal
set -eu
usage() { usage() {
echo "usage: sane-wipe RESOURCE" echo "usage: sane-wipe [--verbose] RESOURCE [RESOURCE ...]"
echo "RESOURCE:" echo "RESOURCE:"
echo " browser: kill and remove cache for firefox, chromium, brave, etc" echo " browser: kill and remove cache for firefox, epiphany, chromium, brave, etc"
echo " dino: remove auth and data for Dino XMPP messenger" echo " dino: remove auth and data for Dino XMPP messenger"
echo " flare: remove auth and data for flare-signal messenger" echo " flare: remove auth and data for flare-signal messenger"
echo " fractal: remove auth and data for fractal matrix messenger" echo " fractal: remove auth and data for fractal matrix messenger"
echo " rofi: remove rofi .desktop entry cache and force it to recompute entries" echo " rofi: remove rofi .desktop entry cache and force it to recompute entries"
} }
resources=()
VERBOSE=
parseArgs() {
while [[ $# -ge 1 ]]; do
local arg=$1
shift
case "$arg" in
(browser|dino|flare|fractal|rofi)
resources+=("$arg")
;;
(--help)
usage
exit 0
;;
(--verbose)
VERBOSE=1
;;
*)
usage
exit 1
;;
esac
done
if [[ ${#resources[@]} -eq 0 ]]; then
usage
exit 1
fi
}
wipe_browser() { wipe_browser() {
# remove chromium/epiphany/firefox/librewolf artifacts # remove chromium/epiphany/firefox/librewolf artifacts
@@ -71,29 +102,15 @@ wipe_rofi() {
rm -f ~/.cache/rofi/rofi-drun-desktop.cache rm -f ~/.cache/rofi/rofi-drun-desktop.cache
} }
main() {
if [ -n "$VERBOSE" ]; then
set -x
fi
case "$1" in for r in "${resources[@]}"; do
(browser) "wipe_$r"
wipe_browser done
;; }
(dino)
wipe_dino parseArgs "$@"
;; main
(flare)
wipe_flare
;;
(fractal)
wipe_fractal
;;
(rofi)
wipe_rofi
;;
(--help)
usage
exit 0
;;
*)
usage
exit 1
;;
esac