fixing install of chadwm

This commit is contained in:
2026-05-13 23:35:12 +02:00
parent 201687c0e1
commit bbdbacefdb
+37 -34
View File
@@ -69,8 +69,8 @@ detect_de() {
} }
detect_display_manager() { detect_display_manager() {
if [ -f /etc/X11/default-display-manager ]; then if [ -f /etc/systemd/system/display-manager.service ]; then
basename "$(cat /etc/X11/default-display-manager)" basename "$(readlink /etc/systemd/system/display-manager.service)"
else else
echo "" echo ""
fi fi
@@ -86,58 +86,61 @@ enable_graphical_target() {
########################## ##########################
say_yellow "Starting Chadwm setup..." say_yellow "Starting Chadwm setup..."
CURRENT_DE="$(detect_de)" # 1. FIX: Identify the correct user correctly
CURRENT_DM="$(detect_display_manager)" # If running via sudo, we want the actual user, not root.
USER=$(whoami) ACTUAL_USER=${SUDO_USER:-$(whoami)}
if [[ -z "$CURRENT_DE" ]]; then # 2. LOGIC FIX:
say_cyan -e "No Desktop Environment detected. Installing Chadwm (light setup with SDDM)..." # 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 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 sudo make install
# 2. Ensure the target directory actually exists # 3. Ensure the target directory actually exists
TARGET_DIR="/usr/share/xsessions" TARGET_DIR="/usr/share/xsessions"
TARGET_FILE="$TARGET_DIR/chadwm.desktop" TARGET_FILE="$TARGET_DIR/chadwm.desktop"
if [ ! -d "$TARGET_DIR" ]; then
sudo mkdir -p "$TARGET_DIR" sudo mkdir -p "$TARGET_DIR"
fi
# 3. Create the .desktop file # 4. Create the .desktop file
# Use the ACTUAL_USER variable here
cat <<EOF | sudo tee $TARGET_FILE > /dev/null cat <<EOF | sudo tee $TARGET_FILE > /dev/null
[Desktop Entry] [Desktop Entry]
Name=chadwm Name=chadwm
Comment=dwm made beautiful Comment=dwm made beautiful
Exec=/home/$USER/.config/chadwm/scripts/run.sh Exec=$CHAD_DIR/scripts/run.sh
Type=Application Type=Application
EOF EOF
sudo chmod 644 $TARGET_FILE sudo chmod 644 $TARGET_FILE
say_green "Chadwm with SDDM installed successfully."
say_green -e "Chadwm with SDDM installed successfully. You can reboot now to start Chadwm."
else else
say_cyan -e "Detected existing Desktop Environment: $CURRENT_DE" say_cyan "Chadwm binary already detected. Skipping build."
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
fi fi
# End of script # 5. Handle Display Manager replacement separately
say_green -e "Chadwm / SDDM setup completed." 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."