fixing install of chadwm
This commit is contained in:
+38
-35
@@ -69,8 +69,8 @@ detect_de() {
|
||||
}
|
||||
|
||||
detect_display_manager() {
|
||||
if [ -f /etc/X11/default-display-manager ]; then
|
||||
basename "$(cat /etc/X11/default-display-manager)"
|
||||
if [ -f /etc/systemd/system/display-manager.service ]; then
|
||||
basename "$(readlink /etc/systemd/system/display-manager.service)"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
@@ -86,58 +86,61 @@ enable_graphical_target() {
|
||||
##########################
|
||||
say_yellow "Starting Chadwm setup..."
|
||||
|
||||
CURRENT_DE="$(detect_de)"
|
||||
CURRENT_DM="$(detect_display_manager)"
|
||||
USER=$(whoami)
|
||||
# 1. FIX: Identify the correct user correctly
|
||||
# If running via sudo, we want the actual user, not root.
|
||||
ACTUAL_USER=${SUDO_USER:-$(whoami)}
|
||||
|
||||
if [[ -z "$CURRENT_DE" ]]; then
|
||||
say_cyan -e "No Desktop Environment detected. Installing Chadwm (light setup with SDDM)..."
|
||||
# 2. LOGIC FIX:
|
||||
# If you want Chadwm to install even if XFCE is present,
|
||||
# we should check if Chadwm is already installed instead of checking for a DE.
|
||||
if [ ! -f "/usr/local/bin/chadwm" ]; then
|
||||
say_cyan "Installing Chadwm..."
|
||||
|
||||
install_packages sddm picom feh acpi rofi dash imlib2 xsetroot
|
||||
install_packages sddm picom feh acpi rofi dash imlib2 xsetroot git base-devel
|
||||
enable_graphical_target
|
||||
|
||||
git clone https://github.com/siduck/chadwm --depth 1 "/home/$USER/.config/chadwm"
|
||||
# Use absolute path to avoid home directory confusion
|
||||
USER_HOME="/home/$ACTUAL_USER"
|
||||
CHAD_DIR="$USER_HOME/.config/chadwm"
|
||||
|
||||
cd "/home/$REAL_USER/.config/chadwm/chadwm"
|
||||
# Clone as the actual user so permissions are correct
|
||||
if [ ! -d "$CHAD_DIR" ]; then
|
||||
sudo -u "$ACTUAL_USER" git clone https://github.com/siduck/chadwm --depth 1 "$CHAD_DIR"
|
||||
fi
|
||||
|
||||
# Move to the source directory and build
|
||||
cd "$CHAD_DIR/chadwm"
|
||||
sudo make install
|
||||
|
||||
# 2. Ensure the target directory actually exists
|
||||
# 3. Ensure the target directory actually exists
|
||||
TARGET_DIR="/usr/share/xsessions"
|
||||
TARGET_FILE="$TARGET_DIR/chadwm.desktop"
|
||||
|
||||
if [ ! -d "$TARGET_DIR" ]; then
|
||||
sudo mkdir -p "$TARGET_DIR"
|
||||
fi
|
||||
sudo mkdir -p "$TARGET_DIR"
|
||||
|
||||
# 3. Create the .desktop file
|
||||
# 4. Create the .desktop file
|
||||
# Use the ACTUAL_USER variable here
|
||||
cat <<EOF | sudo tee $TARGET_FILE > /dev/null
|
||||
[Desktop Entry]
|
||||
Name=chadwm
|
||||
Comment=dwm made beautiful
|
||||
Exec=/home/$USER/.config/chadwm/scripts/run.sh
|
||||
Exec=$CHAD_DIR/scripts/run.sh
|
||||
Type=Application
|
||||
EOF
|
||||
|
||||
sudo chmod 644 $TARGET_FILE
|
||||
|
||||
say_green -e "Chadwm with SDDM installed successfully. You can reboot now to start Chadwm."
|
||||
say_green "Chadwm with SDDM installed successfully."
|
||||
else
|
||||
say_cyan -e "Detected existing Desktop Environment: $CURRENT_DE"
|
||||
|
||||
if [[ "$CURRENT_DM" == "lightdm" ]]; then
|
||||
say_yellow -e "LightDM is currently active. Replacing with SDDM..."
|
||||
|
||||
sudo systemctl disable lightdm
|
||||
sudo apt purge -y lightdm lightdm-gtk-greeter
|
||||
|
||||
install_packages sddm
|
||||
enable_graphical_target
|
||||
|
||||
say_green -e "LightDM removed and replaced with SDDM."
|
||||
else
|
||||
say_cyan -e "Current display manager: ${CURRENT_DM:-none}. Leaving unchanged."
|
||||
fi
|
||||
say_cyan "Chadwm binary already detected. Skipping build."
|
||||
fi
|
||||
|
||||
# End of script
|
||||
say_green -e "Chadwm / SDDM setup completed."
|
||||
# 5. Handle Display Manager replacement separately
|
||||
CURRENT_DM="$(detect_display_manager)"
|
||||
if [[ "$CURRENT_DM" == "lightdm.service" ]]; then
|
||||
say_yellow "LightDM is active. Switching to SDDM..."
|
||||
sudo systemctl disable lightdm
|
||||
sudo pacman -Rs --noconfirm lightdm lightdm-gtk-greeter || true
|
||||
sudo systemctl enable sddm
|
||||
fi
|
||||
|
||||
say_green "Chadwm / SDDM setup completed."
|
||||
Reference in New Issue
Block a user