#!/bin/sh # SPDX-License-Identifier: MIT # enne2-cpufreq — disinstallazione. # ./uninstall.sh rimuove widget (utente) e backend (sudo) # ./uninstall.sh --widget solo il plasmoide # ./uninstall.sh --backend solo helper/polkit/stato (root) # I task configurati (~/.config/enne2-cpufreq) NON vengono cancellati. set -u PKG_DIR=$(cd "$(dirname "$0")" && pwd) ID=org.enne2.cpufreq LIBDIR=/usr/local/libexec/enne2-cpufreq POLICY_DST=/usr/share/polkit-1/actions/org.enne2.cpufreq.set.policy RULE_DST=/etc/polkit-1/rules.d/50-org.enne2.cpufreq.rules STATEDIR=/var/lib/enne2-cpufreq MODE=all for arg in "$@"; do case "$arg" in --widget) MODE=widget ;; --backend) MODE=backend ;; --all) MODE=all ;; -h|--help) sed -n 's/^# \{0,1\}//p' "$0" | sed -n '1,10p'; exit 0 ;; *) printf 'opzione sconosciuta: %s\n' "$arg" >&2; exit 2 ;; esac done remove_widget() { if kpackagetool6 --type Plasma/Applet --show "$ID" >/dev/null 2>&1; then printf 'Rimuovo il plasmoide %s…\n' "$ID" kpackagetool6 --type Plasma/Applet --remove "$ID" || return 1 else printf 'Plasmoide %s non installato.\n' "$ID" fi [ -L "$HOME/.local/bin/enne2-cpufreq-task" ] && rm -f "$HOME/.local/bin/enne2-cpufreq-task" return 0 } remove_backend() { [ "$(id -u)" -eq 0 ] || { printf 'ERRORE: richiede root.\n' >&2; return 1; } # ripristina lo stato hardware prima di togliere l'helper if [ -x "$LIBDIR/cpufreq-helper" ]; then "$LIBDIR/cpufreq-helper" task-end --all >/dev/null 2>&1 fi rm -f "$POLICY_DST" "$RULE_DST" rm -rf "$LIBDIR" rm -rf "$STATEDIR" systemctl try-reload-or-restart polkit >/dev/null 2>&1 || true printf 'Backend rimosso.\n' return 0 } case "$MODE" in widget) remove_widget ;; backend) remove_backend ;; all) remove_widget if [ "$(id -u)" -eq 0 ]; then remove_backend else sudo "$0" --backend fi ;; esac