Last active
August 5, 2024 18:21
-
-
Save eznix86/dc28e81267de79e6e9f164cb2b26cae9 to your computer and use it in GitHub Desktop.
This is the inverse of setup-desktop in Alpine Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# copy and paste to /sbin/remove-desktop | |
#!/bin/sh | |
PREFIX= | |
: ${LIBDIR=$PREFIX/lib} | |
. "$LIBDIR/libalpine.sh" | |
usage() { | |
cat <<-__EOF__ | |
usage: remove-desktop [-h] [gnome|plasma|xfce|mate|sway] | |
Remove a standard desktop | |
options: | |
-h Show this help | |
__EOF__ | |
exit $1 | |
} | |
while getopts "h" opt; do | |
case $opt in | |
h) usage 0;; | |
'?') usage "1" >&2;; | |
esac | |
done | |
shift $(($OPTIND - 1)) | |
if [ $# -gt 1 ]; then | |
usage "1" >&2 | |
fi | |
de="$1" | |
valid_desktops="xfce gnome plasma mate sway none" | |
if [ $# -eq 1 ] && ! isin "$de" $valid_desktops; then | |
echo "$de is not a valid desktop" >&2 | |
usage "1" >&2 | |
fi | |
shift | |
while ! isin "$de" $valid_desktops; do | |
ask "Which desktop environment? ('gnome', 'plasma', 'xfce', 'mate', 'sway' or 'none')" none | |
de="$resp" | |
done | |
case "$de" in | |
none) | |
exit 0 | |
;; | |
mate) | |
apk del mate-desktop-environment ${BROWSER:-firefox} \ | |
consolekit2 \ | |
gvfs \ | |
lightdm \ | |
lightdm-gtk-greeter \ | |
polkit \ | |
dbus \ | |
dbus-x11 \ | |
font-dejavu \ | |
"$@" | |
rc-update del dbus | |
rc-update del lightdm | |
;; | |
xfce) | |
apk del xfce4 ${BROWSER:-firefox} \ | |
consolekit2 \ | |
gvfs \ | |
lightdm \ | |
lightdm-gtk-greeter \ | |
polkit \ | |
xfce4-terminal \ | |
"$@" | |
rc-update del lightdm | |
;; | |
gnome) | |
apk del ${BROWSER:-firefox} "$@" | |
apk del $(apk info --quiet --depends gnome gnome-apps-core) | |
rc-update del gdm | |
rc-update del elogind | |
;; | |
plasma) | |
apk del ${BROWSER:-firefox} \ | |
ark \ | |
bluedevil \ | |
breeze \ | |
breeze-gtk \ | |
dbus \ | |
discover \ | |
drkonqi \ | |
font-noto \ | |
gwenview \ | |
kate \ | |
kde-cli-tools \ | |
kde-gtk-config \ | |
kde-icons \ | |
kdeplasma-addons \ | |
kgamma \ | |
kinfocenter \ | |
kio-fuse \ | |
kmenuedit \ | |
konsole \ | |
kscreen \ | |
ksshaskpass \ | |
kwallet-pam \ | |
kwayland-integration \ | |
pinentry-qt \ | |
pipewire-alsa \ | |
pipewire-pulse \ | |
plasma-browser-integration \ | |
plasma-desktop \ | |
plasma-disks \ | |
plasma-nm \ | |
plasma-pa \ | |
plasma-systemmonitor \ | |
plasma-vault \ | |
plasma-welcome \ | |
plasma-workspace-wallpapers \ | |
polkit-elogind \ | |
polkit-kde-agent-1 \ | |
powerdevil \ | |
print-manager \ | |
sddm-breeze \ | |
sddm-kcm \ | |
spectacle \ | |
systemsettings \ | |
udisks2 \ | |
xdg-desktop-portal-kde \ | |
xdg-user-dirs \ | |
"$@" | |
rc-update del dbus | |
rc-update del sddm | |
;; | |
sway) | |
apk del ${BROWSER:-firefox} \ | |
dmenu \ | |
font-dejavu \ | |
foot \ | |
grim \ | |
i3status \ | |
sway \ | |
swayidle \ | |
swaylockd \ | |
util-linux-login \ | |
wl-clipboard \ | |
wmenu \ | |
xwayland \ | |
"$@" | |
;; | |
*) | |
usage "1" >&2 | |
;; | |
esac | |
users=$(awk -F: '{if ($3<65000 && $3 >= 1000) print $1}' "$ROOT"/etc/passwd 2>/dev/null) | |
if [ -z "$users" ]; then | |
echo "WARNING: You need to create a user account. Please run: setup-user" >&2 | |
echo "" >&2 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment