diff --git a/README.md b/README.md index 0baadf5..8ee8ecf 100644 --- a/README.md +++ b/README.md @@ -265,10 +265,22 @@ Every tool in draphyOS was chosen with a purpose. Here's why: ~/.draphyOS/uninstall.sh ``` -This will: +The uninstaller is smart about your base system: + +**Fedora i3 Spin:** +- Keeps core i3 packages (your system needs them!) +- Only removes draphyOS additions (polybar, picom, fish, etc.) +- Strongly recommends restoring your original configs +- Falls back to `/etc/skel` defaults if no backup exists + +**Other Fedora variants (XFCE, Workstation, etc.):** +- Option to remove only draphyOS additions +- Option to fully remove all i3 packages +- Restore backup or skip + +All uninstalls: - Remove draphyOS config symlinks - Optionally revert shell to bash -- Optionally remove draphyOS packages - Optionally restore your backup configs --- @@ -292,11 +304,15 @@ This will:
-Network module missing? +Network module not showing? + +draphyOS has separate WiFi and Ethernet modules that auto-hide when disconnected. -- Your interface name may differ -- Edit `~/.config/polybar/config.ini` → `interface = YOUR_INTERFACE` -- Find yours with: `ip link show` +- Interfaces are auto-detected on each login via `~/.xprofile` +- If not working, check your interface names: `ip link show` +- Edit `~/.config/polybar/config.ini`: + - WiFi: `[module/network-wifi]` → `interface = wlan0` (or your interface) + - Ethernet: `[module/network-eth]` → `interface = eth0` (or your interface)
diff --git a/configs/i3/config b/configs/i3/config index 6764162..13b5b56 100644 --- a/configs/i3/config +++ b/configs/i3/config @@ -355,7 +355,6 @@ exec_always --no-startup-id feh --bg-fill ~/.config/wallpaper.png # Blue light filter (Thrissur, Kerala, India) exec --no-startup-id redshift -l 10.5276:76.2144 - # Polkit authentication agent exec --no-startup-id /usr/libexec/xfce-polkit diff --git a/configs/polybar/config.ini b/configs/polybar/config.ini index c295bcb..3161245 100644 --- a/configs/polybar/config.ini +++ b/configs/polybar/config.ini @@ -48,8 +48,8 @@ modules-left = i3 xwindow ; Center: date and time modules-center = calendar date -; Right: system info -modules-right = filesystem cpu memory network pulseaudio battery tray powermenu +; Right: system info (network modules auto-hide when disconnected) +modules-right = filesystem cpu memory network-wifi network-eth pulseaudio battery tray powermenu cursor-click = pointer cursor-scroll = ns-resize @@ -137,22 +137,19 @@ format-prefix = " " format-prefix-foreground = ${colors.primary} label = %percentage_used%% %used%/%total% -[module/network] +[module/network-wifi] type = internal/network -; IMPORTANT: Change this to your network interface -; Find yours with: ip link show +; WiFi interface (auto-configured by install script) interface = wlan0 interval = 3.0 -; Connected state +; Connected state - shows signal strength icon and network name format-connected = label-connected = %essid% ↓%downspeed% ↑%upspeed% label-connected-foreground = ${colors.foreground} -; Disconnected state -format-disconnected = -label-disconnected =  Disconnected -label-disconnected-foreground = ${colors.alert} +; Disconnected state - hidden (empty format shows nothing) +format-disconnected = ; WiFi signal strength icons ramp-signal-0 =  @@ -166,6 +163,25 @@ ramp-signal-foreground = ${colors.primary} click-left = nm-connection-editor click-right = nm-applet +[module/network-eth] +type = internal/network +; Ethernet interface (auto-configured by install script) +interface = eth0 +interval = 3.0 + +; Connected state - shows wired icon and label +format-connected-prefix = " " +format-connected-prefix-foreground = ${colors.primary} +label-connected = Wired ↓%downspeed% ↑%upspeed% +label-connected-foreground = ${colors.foreground} + +; Disconnected state - hidden (empty format shows nothing) +format-disconnected = + +; Click to open network settings +click-left = nm-connection-editor +click-right = nm-applet + [module/date] type = internal/date interval = 5 diff --git a/configs/xprofile b/configs/xprofile index d08d9e6..4fab112 100644 --- a/configs/xprofile +++ b/configs/xprofile @@ -14,8 +14,18 @@ export SSH_AUTH_SOCK # Export keyring to D-Bus so browsers and apps can access it dbus-update-activation-environment --systemd DISPLAY XAUTHORITY SSH_AUTH_SOCK -# Auto-detect WiFi interface for polybar (handles USB adapters changing ports) -WIFI_IFACE=$(ip link show 2>/dev/null | grep -E "^[0-9]+: wl.*state UP" | head -1 | awk -F: '{print $2}' | tr -d ' ') -if [ -n "$WIFI_IFACE" ] && [ -f ~/.config/polybar/config.ini ]; then - sed -i "s/^interface = .*/interface = $WIFI_IFACE/" ~/.config/polybar/config.ini +# Auto-detect network interfaces for polybar (handles USB adapters changing ports) +# Each module auto-hides when disconnected, so both can be configured +if [ -f ~/.config/polybar/config.ini ]; then + # Detect WiFi interface (prefer active/UP one) + WIFI_IFACE=$(ip link show 2>/dev/null | grep -E "^[0-9]+: wl" | head -1 | awk -F: '{print $2}' | tr -d ' ') + if [ -n "$WIFI_IFACE" ]; then + sed -i "/^\[module\/network-wifi\]/,/^\[module\// s/^interface = .*/interface = $WIFI_IFACE/" ~/.config/polybar/config.ini + fi + + # Detect Ethernet interface + ETH_IFACE=$(ip link show 2>/dev/null | grep -E "^[0-9]+: (enp|eth)" | head -1 | awk -F: '{print $2}' | tr -d ' ') + if [ -n "$ETH_IFACE" ]; then + sed -i "/^\[module\/network-eth\]/,/^\[module\// s/^interface = .*/interface = $ETH_IFACE/" ~/.config/polybar/config.ini + fi fi diff --git a/install.sh b/install.sh index 617865c..fb4e6a7 100755 --- a/install.sh +++ b/install.sh @@ -416,18 +416,52 @@ configure_hardware() { sed -i "s/^adapter = .*/adapter = $ADAPTER/" "$polybar_config" 2>/dev/null || true fi - # Detect network interface (WiFi preferred, fallback to Ethernet) - WIFI_IFACE=$(ip link show 2>/dev/null | grep -E "^[0-9]+: wl" | head -1 | awk -F: '{print $2}' | tr -d ' ') - ETH_IFACE=$(ip link show 2>/dev/null | grep -E "^[0-9]+: (enp|eth)" | head -1 | awk -F: '{print $2}' | tr -d ' ') + # Detect network interfaces (both WiFi and Ethernet) + # Polybar has separate modules for each - they auto-hide when disconnected + local WIFI_IFACE="" + local ETH_IFACE="" + # Detect WiFi interface (prefer active one from default route) + local DEFAULT_IFACE + DEFAULT_IFACE=$(ip route show default 2>/dev/null | awk '/default/ {print $5}' | head -1) + + if [[ "$DEFAULT_IFACE" == wl* ]]; then + WIFI_IFACE="$DEFAULT_IFACE" + else + # Fallback: find any WiFi interface + WIFI_IFACE=$(ip link show 2>/dev/null | grep -E "^[0-9]+: wl" | head -1 | awk -F: '{print $2}' | tr -d ' ') + fi + + # Detect Ethernet interface + if [[ "$DEFAULT_IFACE" != wl* ]] && [ -n "$DEFAULT_IFACE" ]; then + ETH_IFACE="$DEFAULT_IFACE" + else + # Fallback: find any Ethernet interface + ETH_IFACE=$(ip link show 2>/dev/null | grep -E "^[0-9]+: (enp|eth)" | head -1 | awk -F: '{print $2}' | tr -d ' ') + fi + + # Configure WiFi module if [ -n "$WIFI_IFACE" ]; then print_step "WiFi interface detected: $WIFI_IFACE" - sed -i "s/^interface = .*/interface = $WIFI_IFACE/" "$polybar_config" 2>/dev/null || true - elif [ -n "$ETH_IFACE" ]; then + # Update interface in network-wifi module section only + sed -i "/^\[module\/network-wifi\]/,/^\[module\// s/^interface = .*/interface = $WIFI_IFACE/" "$polybar_config" 2>/dev/null || true + echo "WIFI_IFACE=$WIFI_IFACE" >> "$MARKER_FILE" 2>/dev/null || true + else + print_step "No WiFi interface detected (module will be hidden)" + fi + + # Configure Ethernet module + if [ -n "$ETH_IFACE" ]; then print_step "Ethernet interface detected: $ETH_IFACE" - sed -i "s/^interface = .*/interface = $ETH_IFACE/" "$polybar_config" 2>/dev/null || true + # Update interface in network-eth module section only + sed -i "/^\[module\/network-eth\]/,/^\[module\// s/^interface = .*/interface = $ETH_IFACE/" "$polybar_config" 2>/dev/null || true + echo "ETH_IFACE=$ETH_IFACE" >> "$MARKER_FILE" 2>/dev/null || true else - print_warning "No network interface detected. Please set manually in polybar config." + print_step "No Ethernet interface detected (module will be hidden)" + fi + + if [ -z "$WIFI_IFACE" ] && [ -z "$ETH_IFACE" ]; then + print_warning "No network interfaces detected. Please configure polybar manually." fi print_success "Hardware configured" @@ -545,10 +579,26 @@ EOF fi } -# Create marker file +# Create marker file with system info create_marker() { echo "Installed: $(date)" > "$MARKER_FILE" echo "Version: 1.0" >> "$MARKER_FILE" + + # Detect and store base Fedora variant for smart uninstall + local variant_id="" + if [ -f /etc/os-release ]; then + variant_id=$(grep "^VARIANT_ID=" /etc/os-release 2>/dev/null | cut -d= -f2 | tr -d '"') + fi + + # Check if this is Fedora i3 Spin + if [ "$variant_id" = "i3" ] || [ -d /usr/share/backgrounds/i3 ]; then + echo "BASE_SYSTEM=fedora-i3" >> "$MARKER_FILE" + print_step "Detected: Fedora i3 Spin" + else + echo "BASE_SYSTEM=fedora-other" >> "$MARKER_FILE" + echo "BASE_VARIANT=$variant_id" >> "$MARKER_FILE" + print_step "Detected: Fedora ${variant_id:-unknown}" + fi } # Configure for VM environment (picom compatibility) diff --git a/uninstall.sh b/uninstall.sh index 87dea59..56ad80c 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -159,32 +159,105 @@ revert_shell() { fi } -# Remove installed packages (optional) +# Remove installed packages (smart detection based on base system) remove_packages() { - echo -e "Do you want to ${RED}remove draphyOS packages${NC}? (y/n)" - echo -e "${YELLOW}Warning: This will remove polybar, picom, redshift, etc.${NC}" - echo -e "${YELLOW}Core packages (i3, rofi, dunst, etc.) will be kept.${NC}" - read -r response /dev/null | cut -d= -f2) + base_variant=$(grep "^BASE_VARIANT=" "$MARKER_FILE" 2>/dev/null | cut -d= -f2) + fi - if [[ "$response" =~ ^[Yy]$ ]]; then - print_step "Removing draphyOS-specific packages..." + # draphyOS-specific packages (safe to remove on any system) + # These are additions that don't break the base system + local DRAPHYOS_PACKAGES=( + # Status bar & compositor (replaces i3status/i3bar) + polybar picom + # Shell + fish + # Utilities added by draphyOS + feh flameshot playerctl xss-lock + xdotool xclip ImageMagick + # Night light & theming + redshift geoclue2 yad qt5ct + # Icons & fonts (polybar needs these) + mint-y-icons + fontawesome-6-free-fonts fontawesome-6-brands-fonts + ) - # Only remove packages that are draphyOS additions, not core i3 spin - PACKAGES=( - polybar picom fish - feh flameshot playerctl - xss-lock xdotool xclip - redshift yad qt5ct - mint-y-icons - ImageMagick - fontawesome-6-free-fonts fontawesome-6-brands-fonts - ) + # Core i3/desktop packages (only remove on non-i3 spins if user wants full removal) + # These are needed for i3 to function, or are common desktop utilities + local CORE_I3_PACKAGES=( + # Window manager & related + i3 i3lock dunst rofi + # Display manager + lightdm lightdm-gtk-greeter + # Terminal + rxvt-unicode + # Desktop utilities + arandr lxappearance tmux powertop + # Authentication & settings + xfce-polkit gnome-keyring xfce4-settings + # Bluetooth + blueman + # Cursor theme + adwaita-cursor-theme + ) - sudo dnf remove -y "${PACKAGES[@]}" 2>/dev/null || true + if [ "$base_system" = "fedora-i3" ]; then + # Fedora i3 Spin - only remove draphyOS additions, keep core working + echo -e "${GREEN}Detected: Fedora i3 Spin${NC}" + echo -e "Only draphyOS-specific packages will be removed." + echo -e "Core i3 packages will be kept for your system to function." + echo "" + echo -e "Do you want to ${RED}remove draphyOS packages${NC}? (y/n)" + echo -e "${YELLOW}(polybar, picom, fish, redshift, etc.)${NC}" + read -r response /dev/null || true + print_success "draphyOS packages removed (core i3 packages kept)" + else + print_step "Skipping package removal" + fi else - print_step "Skipping package removal" + # Non-i3 spin (XFCE, Workstation, etc.) - offer full removal option + echo -e "${GREEN}Detected: Fedora ${base_variant:-other}${NC}" + echo "" + echo -e "Choose package removal option:" + echo -e " ${YELLOW}1)${NC} Remove only draphyOS additions (polybar, picom, fish, etc.)" + echo -e " ${YELLOW}2)${NC} Remove ALL i3-related packages (full cleanup)" + echo -e " ${YELLOW}3)${NC} Skip package removal" + echo "" + echo -n "Enter choice [1-3]: " + read -r choice /dev/null || true + print_success "draphyOS packages removed (i3 packages kept)" + ;; + 2) + echo -e "${RED}WARNING: This will remove i3 and all related packages!${NC}" + echo -e "Your system will revert to ${GREEN}${base_variant:-default}${NC} desktop." + echo -n "Are you sure? (yes/no): " + read -r confirm /dev/null || true + print_success "All i3 packages removed" + echo -e "${YELLOW}Please reboot and select your original desktop at login.${NC}" + else + print_step "Full removal cancelled" + fi + ;; + *) + print_step "Skipping package removal" + ;; + esac fi } @@ -224,17 +297,51 @@ EOF # Restore backup restore_backup() { + # Detect base system for smart restore handling + local base_system="" + if [ -f "$MARKER_FILE" ]; then + base_system=$(grep "^BASE_SYSTEM=" "$MARKER_FILE" 2>/dev/null | cut -d= -f2) + fi + # Find latest backup LATEST_BACKUP=$(ls -td "$HOME"/.config-backup-* 2>/dev/null | head -1) if [ -n "$LATEST_BACKUP" ] && [ -d "$LATEST_BACKUP" ]; then echo -e "Found backup: ${YELLOW}$LATEST_BACKUP${NC}" - echo -e "Do you want to ${GREEN}restore${NC} this backup? (y/n)" - read -r response /dev/null || true fi + else + # User declined restore + if [ "$base_system" = "fedora-i3" ]; then + print_warning "Backup not restored." + echo "" + # Offer to copy default configs from /etc/skel + copy_default_i3_configs + fi fi else print_warning "No backup found to restore" + # For i3 spin, offer to copy default configs + if [ "$base_system" = "fedora-i3" ]; then + echo "" + copy_default_i3_configs + fi + fi +} + +# Copy default i3 configs from /etc/skel (Fedora i3 Spin only) +copy_default_i3_configs() { + echo -e "${YELLOW}Your i3 needs config files to function.${NC}" + echo "" + + # Check what default configs are available + local has_skel_i3=false + local has_skel_i3status=false + + if [ -d /etc/skel/.config/i3 ]; then + has_skel_i3=true + fi + if [ -d /etc/skel/.config/i3status ] || [ -f /etc/skel/.config/i3status/config ]; then + has_skel_i3status=true + fi + + if [ "$has_skel_i3" = true ]; then + echo -e "Default Fedora i3 configs found in /etc/skel/" + echo -e "Do you want to copy default i3 configs? (y/n)" + read -r response /dev/null || true + print_step " Copied: i3 config" + fi + + # Copy i3status config if exists + if [ -d /etc/skel/.config/i3status ]; then + mkdir -p "$HOME/.config/i3status" + cp -r /etc/skel/.config/i3status/* "$HOME/.config/i3status/" 2>/dev/null || true + print_step " Copied: i3status config" + fi + + # Copy other common configs if they exist in skel + for dir in dunst rofi; do + if [ -d "/etc/skel/.config/$dir" ]; then + mkdir -p "$HOME/.config/$dir" + cp -r "/etc/skel/.config/$dir/"* "$HOME/.config/$dir/" 2>/dev/null || true + print_step " Copied: $dir config" + fi + done + + print_success "Default configs copied" + echo -e "${GREEN}Your i3 should work with default Fedora i3 Spin settings.${NC}" + else + print_warning "No configs restored. i3 may not work properly." + echo -e "You can manually copy configs with:" + echo -e " ${YELLOW}cp -r /etc/skel/.config/i3 ~/.config/${NC}" + fi + else + print_warning "Default i3 configs not found in /etc/skel/" + echo -e "You may need to create a basic i3 config manually." + echo -e "Generate one with: ${YELLOW}i3-config-wizard${NC}" fi } @@ -283,10 +473,30 @@ remove_install_dir() { main() { print_header - echo -e "${RED}This will completely remove draphyOS from your system.${NC}" + # Detect base system for smart messaging + local base_system="" + local base_variant="" + if [ -f "$MARKER_FILE" ]; then + base_system=$(grep "^BASE_SYSTEM=" "$MARKER_FILE" 2>/dev/null | cut -d= -f2) + base_variant=$(grep "^BASE_VARIANT=" "$MARKER_FILE" 2>/dev/null | cut -d= -f2) + fi + + echo -e "${RED}This will remove draphyOS from your system.${NC}" echo "" + + # Show base system info + if [ "$base_system" = "fedora-i3" ]; then + echo -e "${GREEN}Base system: Fedora i3 Spin${NC}" + echo -e "Your system will be restored to default Fedora i3 configuration." + echo "" + elif [ -n "$base_variant" ]; then + echo -e "${GREEN}Base system: Fedora ${base_variant}${NC}" + echo -e "You can choose to keep i3 or fully remove it." + echo "" + fi + echo "The following will be removed:" - echo " - All draphyOS config files" + echo " - All draphyOS config files (i3, polybar, picom, rofi, etc.)" echo " - Wallpaper and cheatsheets" echo " - LightDM customization" echo " - Battery limit service (if set)" @@ -294,10 +504,23 @@ main() { if [ -f "$MARKER_FILE" ] && grep -q "VM_MODE=true" "$MARKER_FILE" 2>/dev/null; then echo " - VM-optimized picom settings" fi + # Check for network interface configuration + if [ -f "$MARKER_FILE" ]; then + local wifi_iface eth_iface + wifi_iface=$(grep "WIFI_IFACE=" "$MARKER_FILE" 2>/dev/null | cut -d= -f2) + eth_iface=$(grep "ETH_IFACE=" "$MARKER_FILE" 2>/dev/null | cut -d= -f2) + if [ -n "$wifi_iface" ] || [ -n "$eth_iface" ]; then + echo " - Network config: ${wifi_iface:+WiFi: $wifi_iface} ${eth_iface:+Eth: $eth_iface}" + fi + fi echo "" echo "You will be asked about:" echo " - Reverting shell to bash" - echo " - Removing packages" + if [ "$base_system" = "fedora-i3" ]; then + echo " - Removing draphyOS packages (core i3 packages will be kept)" + else + echo " - Removing packages (partial or full removal)" + fi echo " - Restoring your backup" echo "" echo -e "Do you want to continue? (y/n)"