mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-05 13:15:21 +00:00
Update dwmtitus-setup.sh
This commit is contained in:
parent
022bdb7659
commit
88697517f7
|
@ -190,7 +190,108 @@ setupDisplayManager() {
|
|||
esac
|
||||
echo "Xorg installed successfully"
|
||||
echo "Setting up Display Manager"
|
||||
currentdm="none"
|
||||
for dm in gdm sddm lightdm; do
|
||||
if systemctl is-active --quiet $dm.service; then
|
||||
currentdm=$dm
|
||||
break
|
||||
fi
|
||||
done
|
||||
echo "Current display manager: $currentdm"
|
||||
if [ "$currentdm" = "none" ]; then
|
||||
DM="sddm"
|
||||
echo "No display manager found, installing $DM"
|
||||
case "$PACKAGER" in
|
||||
pacman)
|
||||
$ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm $DM
|
||||
;;
|
||||
apt)
|
||||
$ESCALATION_TOOL "$PACKAGER" install -y $DM
|
||||
;;
|
||||
dnf)
|
||||
$ESCALATION_TOOL "$PACKAGER" install -y $DM
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported package manager: $PACKAGER"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
echo "$DM installed successfully"
|
||||
systemctl enable $DM
|
||||
|
||||
# Clear the screen
|
||||
clear
|
||||
|
||||
# Prompt user for auto-login
|
||||
echo "Do you want to enable auto-login?"
|
||||
echo "Use arrow keys or j/k to navigate, Enter to select"
|
||||
options=("Yes" "No")
|
||||
selected=0
|
||||
|
||||
# Function to print menu
|
||||
print_menu() {
|
||||
for i in "${!options[@]}"; do
|
||||
if [ $i -eq $selected ]; then
|
||||
echo "> ${options[$i]}"
|
||||
else
|
||||
echo " ${options[$i]}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Handle user input
|
||||
while true; do
|
||||
print_menu
|
||||
read -rsn1 key
|
||||
case "$key" in
|
||||
$'\x1B') # ESC sequence for arrow keys
|
||||
read -rsn2 key
|
||||
case "$key" in
|
||||
'[A' | 'k') ((selected > 0)) && ((selected--));; # Up arrow or k
|
||||
'[B' | 'j') ((selected < ${#options[@]}-1)) && ((selected++));; # Down arrow or j
|
||||
esac
|
||||
;;
|
||||
'') break;; # Enter key
|
||||
esac
|
||||
clear
|
||||
done
|
||||
|
||||
if [ "${options[$selected]}" = "Yes" ]; then
|
||||
echo "Configuring SDDM for autologin"
|
||||
SDDM_CONF="/etc/sddm.conf"
|
||||
if [ ! -f "$SDDM_CONF" ]; then
|
||||
echo "[Autologin]" | sudo tee -a "$SDDM_CONF"
|
||||
echo "User=$USER" | sudo tee -a "$SDDM_CONF"
|
||||
echo "Session=dwm" | sudo tee -a "$SDDM_CONF"
|
||||
else
|
||||
sudo sed -i '/^\[Autologin\]/d' "$SDDM_CONF"
|
||||
sudo sed -i '/^User=/d' "$SDDM_CONF"
|
||||
sudo sed -i '/^Session=/d' "$SDDM_CONF"
|
||||
echo "[Autologin]" | sudo tee -a "$SDDM_CONF"
|
||||
echo "User=$USER" | sudo tee -a "$SDDM_CONF"
|
||||
echo "Session=dwm" | sudo tee -a "$SDDM_CONF"
|
||||
fi
|
||||
echo "Checking if autologin group exists"
|
||||
if ! getent group autologin > /dev/null; then
|
||||
echo "Creating autologin group"
|
||||
sudo groupadd autologin
|
||||
else
|
||||
echo "Autologin group already exists"
|
||||
fi
|
||||
echo "Adding user with UID 1000 to autologin group"
|
||||
USER_UID_1000=$(getent passwd 1000 | cut -d: -f1)
|
||||
if [ -n "$USER_UID_1000" ]; then
|
||||
sudo usermod -aG autologin "$USER_UID_1000"
|
||||
echo "User $USER_UID_1000 added to autologin group"
|
||||
else
|
||||
echo "No user with UID 1000 found - Auto login not possible"
|
||||
fi
|
||||
else
|
||||
echo "Auto-login configuration skipped"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user