Refactoring Desktop installation (#436)

* Refactor desktop

* Update

* Cleanup
This commit is contained in:
Igor
2025-02-16 22:28:53 +01:00
committed by GitHub
parent f9180c44ef
commit ea1d47d9cd
11 changed files with 578 additions and 148 deletions

View File

@@ -1,2 +0,0 @@
ENABLED=false
CONDITION="[ -f /usr/share/xsessions/xfce.desktop ]"

11
tests/gnome_desktop.conf Normal file
View File

@@ -0,0 +1,11 @@
ENABLED=true
RELEASE="bookworm:jammy:noble"
TESTNAME="Gnome"
testcase() {(
set -e
./bin/armbian-config --api module_desktop remove de=gnome
./bin/armbian-config --api module_desktop remove de=xfce
sudo apt -y autoremove
./bin/armbian-config --api module_desktop install de=gnome
)}

11
tests/xfce_desktop.conf Normal file
View File

@@ -0,0 +1,11 @@
ENABLED=true
RELEASE="bookworm:jammy:noble"
TESTNAME="XFCE"
testcase() {(
set -e
./bin/armbian-config --api module_desktop remove de=xfce
./bin/armbian-config --api module_desktop remove de=gnome
sudo apt -y autoremove
./bin/armbian-config --api module_desktop install de=xfce
)}

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

View File

@@ -0,0 +1 @@
GNOME is a modern, user-friendly desktop environment for Linux, offering a clean interface, essential apps, and customization through extensions. It prioritizes simplicity, accessibility, and efficiency.

View File

@@ -0,0 +1 @@
XFCE is a lightweight, fast, and user-friendly desktop environment for Linux, offering a classic interface, essential apps, and customization. It prioritizes performance, simplicity, and efficiency.

View File

@@ -334,100 +334,97 @@
{
"id": "Desktops",
"description": "Desktop Environments",
"status": "Disabled",
"sub": [
{
"id": "XFCE",
"description": "XFCE desktop",
"status": "Disabled",
"sub": [
{
"id": "XFCE01",
"about": "Install XFCE:\nXfce is a lightweight desktop environment for UNIX-like operating systems. It aims to be fast and low on system resources, while still being visually appealing and user friendly.",
"about": "Install XFCE:\n\nXfce is a lightweight desktop environment for UNIX-like operating systems. It aims to be fast and low on system resources, while still being visually appealing and user friendly.",
"description": "XFCE desktop Install",
"command": [
"manage_desktops 'xfce' 'install'"
"module_desktop install de=xfce"
],
"status": "Stable",
"author": "@igorpecovnik",
"condition": "[ ! -f /usr/share/xsessions/xfce.desktop ]"
"condition": "! module_desktop status de=xfce"
},
{
"id": "XFCE02",
"description": "Uninstall",
"command": [
"manage_desktops 'xfce' 'uninstall'"
"module_desktop remove de=xfce"
],
"status": "Stable",
"author": "@igorpecovnik",
"condition": "[ -f /usr/share/xsessions/xfce.desktop ]"
"condition": "module_desktop status de=xfce"
},
{
"id": "XFCE03",
"description": "Enable autologin",
"command": [
"manage_desktops 'xfce' 'auto'"
],
"module_desktop auto de=xfce"
],
"status": "Stable",
"author": "@igorpecovnik",
"condition": "[ -f /usr/share/xsessions/xfce.desktop ] && [ ! -f /etc/lightdm/lightdm.conf.d/22-armbian-autologin.conf ]"
"condition": "module_desktop status de=xfce && ! module_desktop login"
},
{
"id": "XFCE04",
"description": "Disable autologin",
"command": [
"manage_desktops 'xfce' 'manual'"
"module_desktop manual de=xfce"
],
"status": "Stable",
"author": "@igorpecovnik",
"condition": "[ -f /usr/share/xsessions/xfce.desktop ] && [ -f /etc/lightdm/lightdm.conf.d/22-armbian-autologin.conf ]"
"condition": "module_desktop status de=xfce && module_desktop login"
}
]
},
{
"id": "Gnome",
"description": "Gnome desktop",
"status": "Disabled",
"sub": [
{
"id": "GNOME01",
"description": "Gnome desktop Install",
"command": [
"manage_desktops 'gnome' 'install'"
"module_desktop 'install' 'de=gnome'"
],
"status": "Stable",
"author": "@igorpecovnik",
"condition": "[ ! -f /usr/share/xsessions/gnome.desktop ]"
"condition": "! module_desktop status de=gnome"
},
{
"id": "GNOME02",
"description": "Uninstall",
"command": [
"manage_desktops 'gnome' 'uninstall'"
"module_desktop 'remove' 'de=gnome'"
],
"status": "Stable",
"author": "@igorpecovnik",
"condition": "[ -f /usr/share/xsessions/gnome.desktop ]"
"condition": "module_desktop status de=gnome"
},
{
"id": "GNOME03",
"description": "Enable autologin",
"command": [
"manage_desktops 'gnome' 'auto'"
],
"module_desktop auto de=gnome"
],
"status": "Stable",
"author": "@igorpecovnik",
"condition": "[ -f /usr/share/xsessions/gnome.desktop ] && ! cat /etc/gdm3/custom.conf 2>/dev/null | grep AutomaticLoginEnable | grep true >/dev/null"
"condition": "module_desktop status de=gnome && ! module_desktop login"
},
{
"id": "GNOME04",
"description": "Disable autologin",
"command": [
"manage_desktops 'gnome' 'manual'"
"module_desktop manual de=gnome"
],
"status": "Stable",
"author": "@igorpecovnik",
"condition": "[ -f /usr/share/xsessions/gnome.desktop ] && cat /etc/gdm3/custom.conf 2>/dev/null | grep AutomaticLoginEnable | grep true >/dev/null"
"condition": "module_desktop status de=gnome && module_desktop login"
}
]
},

View File

@@ -1,124 +0,0 @@
module_options+=(
["manage_desktops,author"]="@igorpecovnik"
["manage_desktops,ref_link"]=""
["manage_desktops,feature"]="manage_desktops"
["manage_desktops,desc"]="Install Desktop environment"
["manage_desktops,example"]="manage_desktops xfce install"
["manage_desktops,status"]="Active"
)
#
# Install desktop
#
function manage_desktops() {
local desktop=$1
local command=$2
# get user who executed this script
if [ $SUDO_USER ]; then local user=$SUDO_USER; else local user=$(whoami); fi
case "$command" in
install)
# desktops has different default login managers
case "$desktop" in
gnome)
echo "/usr/sbin/gdm3" > /etc/X11/default-display-manager
#pkg_install gdm3
;;
kde-neon)
echo "/usr/sbin/sddm" > /etc/X11/default-display-manager
#pkg_install sddm
;;
*)
echo "/usr/sbin/lightdm" > /etc/X11/default-display-manager
#pkg_install lightdm
;;
esac
# just make sure we have everything in order
pkg_configure -a
# install desktop
pkg_install -o Dpkg::Options::="--force-confold" --install-recommends armbian-${DISTROID}-desktop-${desktop}
# add user to groups
for additionalgroup in sudo netdev audio video dialout plugdev input bluetooth systemd-journal ssh; do
usermod -aG ${additionalgroup} ${user} 2> /dev/null
done
# set up profile sync daemon on desktop systems
which psd > /dev/null 2>&1
if [[ $? -eq 0 && -z $(grep overlay-helper /etc/sudoers) ]]; then
echo "${user} ALL=(ALL) NOPASSWD: /usr/bin/psd-overlay-helper" >> /etc/sudoers
touch /home/${user}/.activate_psd
fi
# update skel
update_skel
# enable auto login
manage_desktops "$desktop" "auto"
# stop display managers in case we are switching them
srv_stop gdm3 lightdm sddm
# start new default display manager
srv_restart display-manager
;;
uninstall)
# we are uninstalling all variants until build time packages are fixed to prevent installing one over another
srv_stop display-manager
pkg_remove -o Dpkg::Options::="--force-confold" armbian-${DISTROID}-desktop-$1 \
xfce4-session gnome-session slick-greeter lightdm gdm3 sddm cinnamon-session i3-wm
# disable autologins
rm -f /etc/gdm3/custom.conf
rm -f /etc/sddm.conf.d/autologin.conf
rm -f /etc/lightdm/lightdm.conf.d/22-armbian-autologin.conf
;;
auto)
# desktops has different login managers and autologin methods
case "$desktop" in
gnome)
# gdm3 autologin
mkdir -p /etc/gdm3
cat <<- EOF > /etc/gdm3/custom.conf
[daemon]
AutomaticLoginEnable = true
AutomaticLogin = ${user}
EOF
;;
kde-neon)
# sddm autologin
cat <<- EOF > "/etc/sddm.conf.d/autologin.conf"
[Autologin]
User=${user}
EOF
;;
*)
# lightdm autologin
mkdir -p /etc/lightdm/lightdm.conf.d
cat <<- EOF > "/etc/lightdm/lightdm.conf.d/22-armbian-autologin.conf"
[Seat:*]
autologin-user=${user}
autologin-user-timeout=0
user-session=xfce
EOF
;;
esac
# restart after selection
srv_restart display-manager
;;
manual)
case "$desktop" in
gnome) rm -f /etc/gdm3/custom.conf ;;
kde-neon) rm -f /etc/sddm.conf.d/autologin.conf ;;
*) rm -f /etc/lightdm/lightdm.conf.d/22-armbian-autologin.conf ;;
esac
# restart after selection
srv_restart display-manager
;;
esac
}

View File

@@ -0,0 +1,213 @@
module_options+=(
["module_desktop,author"]="@igorpecovnik"
["module_desktop,feature"]="module_desktop"
["module_desktop,desc"]="XFCE desktop packages"
["module_desktop,example"]="install remove disable enable status auto manual login help"
["module_desktop,status"]="Active"
["module_desktop,arch"]="x86-64"
)
#
# Module install and configure desktop
#
function module_desktop() {
local title="test"
local condition=$(which "$title" 2>/dev/null)
# get user who executed this script
if [ $SUDO_USER ]; then local user=$SUDO_USER; else local user=$(whoami); fi
# read additional parameters from command line
local parameter
IFS=' ' read -r -a parameter <<< "${2}"
for feature in de; do
for selected in ${parameter[@]}; do
IFS='=' read -r -a split <<< "${selected}"
[[ ${split[0]} == $feature ]] && eval "$feature=${split[1]}"
done
done
local de="${de:-xfce}" # DE
# Convert the example string to an array
local commands
IFS=' ' read -r -a commands <<< "${module_options["module_desktop,example"]}"
# generate and install packages
module_desktop_packages "$de" "$DISTROID"
case "$1" in
"${commands[0]}")
# update package list
pkg_update
# desktops has different default login managers
case "$de" in
gnome)
echo "/usr/sbin/gdm3" > /etc/X11/default-display-manager
pkg_install ${PACKAGES}
pkg_install ${PACKAGES_UNINSTALL}
pkg_install gdm3
;;
kde-neon)
echo "/usr/sbin/sddm" > /etc/X11/default-display-manager
pkg_install ${PACKAGES}
pkg_install ${PACKAGES_UNINSTALL}
pkg_install kde-standard
;;
*)
echo "/usr/sbin/lightdm" > /etc/X11/default-display-manager
pkg_install -o Dpkg::Options::="--force-confold" ${PACKAGES}
pkg_install -o Dpkg::Options::="--force-confold" ${PACKAGES_UNINSTALL}
pkg_install -o Dpkg::Options::="--force-confold" lightdm
;;
esac
# install desktop
pkg_install -o Dpkg::Options::="--force-confold" armbian-${DISTROID}-desktop-${de}
# add user to groups
for additionalgroup in sudo netdev audio video dialout plugdev input bluetooth systemd-journal ssh; do
usermod -aG ${additionalgroup} ${user} 2> /dev/null
done
# set up profile sync daemon on desktop systems
which psd > /dev/null 2>&1
if [[ $? -eq 0 && -z $(grep overlay-helper /etc/sudoers) ]]; then
echo "${user} ALL=(ALL) NOPASSWD: /usr/bin/psd-overlay-helper" >> /etc/sudoers
touch /home/${user}/.activate_psd
fi
# update skel
update_skel
# stop display managers in case we are switching them
if srv_active gdm3; then
srv_stop gdm3
elif srv_active lightdm; then
srv_stop lightdm
elif srv_active sddm; then
srv_stop sddm
fi
# start new default display manager
srv_restart display-manager
# enable auto login
${module_options["module_desktop,feature"]} ${commands[5]}
;;
"${commands[1]}")
# disable auto login
${module_options["module_desktop,feature"]} ${commands[6]}
# remove destkop
srv_stop display-manager
pkg_remove ${PACKAGES}
pkg_remove armbian-${DISTROID}-desktop-${de}
;;
"${commands[2]}")
# disable
srv_stop display-manager
srv_disable display-manager
;;
"${commands[3]}")
# enable
srv_enable display-manager
srv_start display-manager
;;
"${commands[4]}")
# status
case "$de" in
gnome)
if srv_active gdm3; then
return 0
else
return 1
fi
;;
kde-neon)
if srv_active sddm; then
return 0
else
return 1
fi
;;
*)
if srv_active lightdm; then
return 0
else
return 1
fi
;;
esac
;;
"${commands[5]}")
# autologin methods
case "$de" in
gnome)
# gdm3 autologin
mkdir -p /etc/gdm3
cat <<- EOF > /etc/gdm3/custom.conf
[daemon]
AutomaticLoginEnable = true
AutomaticLogin = ${user}
EOF
;;
kde-neon)
# sddm autologin
mkdir -p "/etc/sddm.conf.d/"
cat <<- EOF > "/etc/sddm.conf.d/autologin.conf"
[Autologin]
User=${user}
EOF
;;
*)
# lightdm autologin
mkdir -p /etc/lightdm/lightdm.conf.d
cat <<- EOF > "/etc/lightdm/lightdm.conf.d/22-armbian-autologin.conf"
[Seat:*]
autologin-user=${user}
autologin-user-timeout=0
user-session=xfce
EOF
;;
esac
# restart after selection
srv_restart display-manager
;;
"${commands[6]}")
# manual login, disable auto-login
case "$de" in
gnome) rm -f /etc/gdm3/custom.conf ;;
kde-neon) rm -f /etc/sddm.conf.d/autologin.conf ;;
*) rm -f /etc/lightdm/lightdm.conf.d/22-armbian-autologin.conf ;;
esac
# restart after selection
srv_restart display-manager
;;
"${commands[7]}")
# status
if [[ -f /etc/gdm3/custom.conf ]] || [[ -f /etc/sddm.conf.d/autologin.conf ]] || [[ -f /etc/lightdm/lightdm.conf.d/22-armbian-autologin.conf ]]; then
return 0
else
return 1
fi
;;
"${commands[8]}")
echo -e "\nUsage: ${module_options["module_desktop,feature"]} <command>"
echo -e "Commands: ${module_options["module_desktop,example"]}"
echo "Available commands:"
echo -e "\tinstall\t- Generate packages for $title."
echo -e "\tremove\t- Generate packages for $title."
echo -e "\tdisable\t- Generate packages for $title."
echo -e "\tenable\t- Generate packages for $title."
echo -e "\tstatus\t- Generate packages for $title."
echo -e "\nAvailable switches:\n"
echo -e "\tkvmprefix\t- Name prefix (default = kvmtest)"
echo
;;
*)
${module_options["module_desktop,feature"]} ${commands[8]}
;;
esac
}

View File

@@ -0,0 +1,322 @@
module_options+=(
["module_desktop_packages,author"]="@igorpecovnik"
["module_desktop_packages,feature"]="module_desktop"
["module_desktop_packages,desc"]="Generate desktop packages list"
["module_desktop_packages,de"]="budgie cinnamon deepin enlightenment gnome i3-wm kde-plasma mate xfce xmonad"
["module_desktop_packages,release"]="bookworm noble plucky"
["module_desktop_packages,status"]="Active"
["module_desktop_packages,arch"]="x86-64"
)
#
# Module desktop packages
#
function module_desktop_packages() {
local title="test"
local condition=$(which "$title" 2>/dev/null)
# Convert the example string to an array
local de
IFS=' ' read -r -a de <<< "${module_options["module_desktop_packages,de"]}"
# Common desktop packages
local packages+=(
"anacron"
"cups"
"eject"
"printer-driver-all"
"profile-sync-daemon"
"system-config-printer"
"terminator"
"upower"
"xarchiver"
)
case "$1" in
"${de[0]}")
# budgie
;;
"${de[1]}")
# cinnamon
;;
"${de[2]}")
# deepin
;;
"${de[3]}")
# enlightenment
;;
"${de[4]}")
# gnome
local packages+=(
"apt-xapian-index"
"at-spi2-core"
"colord"
"dbus-x11"
"dconf-cli"
"dmz-cursor-theme"
"foomatic-db-compressed-ppds"
"fonts-noto-cjk"
"fonts-ubuntu"
"fonts-ubuntu-console"
"gdebi"
"gdm3"
"gnome-control-center"
"gnome-desktop3-data"
"gnome-disk-utility"
"gnome-disk-utility"
"gnome-keyring"
"gnome-menus"
"gnome-packagekit"
"gnome-screenshot"
"gnome-session"
"gnome-shell"
"gnome-shell-extension-appindicator"
"gnome-system-monitor"
"gnome-terminal"
"gvfs-backends"
"inputattach"
"libnotify-bin"
"lm-sensors"
"nautilus"
"nautilus-extension-gnome-terminal"
"pavucontrol"
"pulseaudio"
"pulseaudio-module-bluetooth"
"software-properties-gtk"
"synaptic"
"x11-apps"
"x11-session-utils"
"x11-utils"
"x11-xserver-utils"
"xdg-user-dirs"
"xdg-user-dirs-gtk"
"xfonts-base"
"xserver-xorg"
"xwayland"
"zenity"
)
;;
"${de[5]}")
# i3-wm
;;
"${de[6]}")
# kde-plasma
;;
"${de[7]}")
# mate
;;
"${de[8]}")
# xfce
local packages+=(
"anacron"
"apt-xapian-index"
"blueman"
"bluez"
"bluez-cups"
"bluez-tools"
"brltty"
"brltty-x11"
"cifs-utils"
"colord"
"cups"
"cups-bsd"
"cups-client"
"cups-filters"
"dbus-x11"
"dmz-cursor-theme"
"evince"
"evince-common"
"fontconfig"
"fontconfig-config"
"fonts-noto-cjk"
"fonts-ubuntu"
"fonts-ubuntu-console"
"foomatic-db-compressed-ppds"
"gdebi"
"ghostscript-x"
"gnome-disk-utility"
"gnome-font-viewer"
"gnome-screenshot"
"gnome-system-monitor"
"gstreamer1.0-packagekit"
"gstreamer1.0-plugins-base-apps"
"gstreamer1.0-pulseaudio"
"gtk2-engines"
"gtk2-engines-murrine"
"gtk2-engines-pixbuf"
"gvfs-backends"
"hplip"
"ayatana-indicator-printers"
"inputattach"
"inxi"
"keyutils"
"laptop-detect"
"libatk-adaptor"
"libfontconfig1"
"libfontembed1"
"libfontenc1"
"libgail-common"
"libgl1-mesa-dri"
"libgsettings-qt1"
"libgtk2.0-bin"
"libnotify-bin"
"libpam-gnome-keyring"
"libproxy1-plugin-gsettings"
"libwmf0.2-7-gtk"
"libxcursor1"
"lightdm"
"lm-sensors"
"lxtask"
"mesa-utils"
"mousepad"
"mousetweaks"
"numix-gtk-theme"
"numix-icon-theme"
"numix-icon-theme-circle"
"openprinting-ppds"
"orca"
"p7zip-full"
"pamix"
"pasystray"
"pavucontrol"
"pavumeter"
"policykit-1"
"printer-driver-all"
"profile-sync-daemon"
"pulseaudio"
"pulseaudio-module-bluetooth"
"qalculate-gtk"
"redshift"
"slick-greeter"
"smbclient"
"software-properties-gtk"
"spice-vdagent"
"synaptic"
"system-config-printer"
"system-config-printer-common"
"terminator"
"thunar-volman"
"update-inetd"
"update-manager"
"update-manager-core"
"viewnior"
"x11-apps"
"x11-utils"
"x11-xserver-utils"
"xapps-common"
"xarchiver"
"xauth"
"xbacklight"
"xcursor-themes"
"xdg-user-dirs"
"xdg-user-dirs-gtk"
"xfce4"
"xfce4-notifyd"
"xfce4-power-manager"
"xfce4-screenshooter"
"xfce4-terminal"
"xfonts-100dpi"
"xfonts-75dpi"
"xfonts-base"
"xfonts-encodings"
"xfonts-scalable"
"xfonts-utils"
"xorg-docs-core"
"xscreensaver"
"xsensors"
"xserver-xorg"
"xserver-xorg-video-fbdev"
"xwallpaper"
)
local architecture+=(
"arm64"
"amd64"
"armhf"
"riscv64"
)
local supported=(
"supported"
)
local packages_uninstall=()
local packages_remove=()
;;
"${de[9]}")
# xmonad
;;
esac
local release
IFS=' ' read -r -a release <<< "${module_options["module_desktop_packages,release"]}"
case "$2" in
"${release[0]}")
# bookworm
local packages+=(
"accountsservice"
"gnome-calculator"
"libu2f-udev"
)
local packages_remove+=(
"libfontembed1"
"update-manager"
"update-manager-core"
)
;;
"${release[1]}")
# noble
local packages+=(
"polkitd"
"pkexec"
"libu2f-udev"
)
local packages_remove+=(
"qalculate-gtk"
"hplip"
"indicator-printers"
"libfontembed1"
"policykit-1"
"printer-driver-all"
"qalculate-gtk"
)
local packages_uninstall+=(
"ubuntu-session"
)
;;
"${release[2]}")
# plucky
local packages+=(
"polkitd"
"pkexec"
"libu2f-udev"
)
local packages_remove+=(
"qalculate-gtk"
"hplip"
"indicator-printers"
"libfontembed1"
"policykit-1"
"printer-driver-all"
"qalculate-gtk"
"libfontembed1"
"pavumeter"
)
local packages_uninstall+=(
"ubuntu-session"
)
;;
esac
# Remove packages_remove from packages
filtered_packages=()
for p in "${packages[@]}"; do
# Check if $p is in packages_remove
if [[ ! " ${packages_remove[@]} " =~ " $p " ]]; then
filtered_packages+=("$p")
fi
done
packages=("${filtered_packages[@]}")
PACKAGES=${packages[@]}
PACKAGES_UNINSTALL=${packages_uninstall[@]}
SUPPORTED=${supported}
ARCHITECTURE=${architecture}
}