aboutsummaryrefslogtreecommitdiff
path: root/common/.profile
diff options
context:
space:
mode:
Diffstat (limited to 'common/.profile')
-rwxr-xr-x[-rw-r--r--]common/.profile164
1 files changed, 73 insertions, 91 deletions
diff --git a/common/.profile b/common/.profile
index b847d6c..53703b7 100644..100755
--- a/common/.profile
+++ b/common/.profile
@@ -1,102 +1,84 @@
#!/bin/bash
-
-#~/.profile
-
-# ======================================
-# Basic environment setup
-# ======================================
-
-export EDITOR="$(command -v nvim || command -v vim || echo nano)"
-
-# Load zsh env if running zsh
-if [ -n "$ZSH_VERSION" ] && [ -f "$HOME/.config/zsh/.zshenv" ]; then
- . "$HOME/.config/zsh/.zshenv"
-fi
-
-cd "$HOME" || exit 1
-
# ======================================
# Session launcher
# ======================================
-# Detect graphical DE session
-if [ -n "$DISPLAY" ]; then
- #echo "Graphical session detected ($XDG_SESSION_DESKTOP). Skipping auto TTY session launch."
- return
-fi
-
-# Only run on first virtual terminal
-if [ -z "$XDG_VTNR" ] || [ "$XDG_VTNR" -ne 1 ]; then
- return
-fi
-
-# Clean environment
-unset DISPLAY XAUTHORITY DBUS_SESSION_BUS_ADDRESS
-
-# Priority-ordered list of sessions (WM/DE)
-sessions=(
- "Hyprland"
- "bspwm"
- "sway"
- "gnome-session"
- "startplasma-x11"
- "startxfce4"
- "openbox"
- "i3"
-)
-
-# Handle saved session
-if [ -f "$HOME/.session" ]; then
- chosen_session=$(<"$HOME/.session")
- rm -f "$HOME/.session"
-fi
-
-# Start a session
start_session() {
- local s="$1"
- case "$s" in
- bspwm)
- export XDG_SESSION_TYPE="x11"
- exec startx /usr/bin/bspwm
- ;;
- Hyprland|sway)
- #exec dbus-launch --sh-syntax --exit-with-session "$s"
- exec dbus-launch --sh-syntax --exit-with-session "$s" >/dev/null 2>&1
- ;;
- gnome-session|startplasma-x11|startxfce4|openbox|i3)
- exec "$s"
- ;;
- *)
- return 1
- ;;
- esac
-}
-
-# Try saved session first
-if [ -n "$chosen_session" ]; then
- if start_session "$chosen_session"; then
- exit
- else
- echo "Saved session '$chosen_session' not found. Falling back..."
+ # Clean environment
+ unset DISPLAY XAUTHORITY DBUS_SESSION_BUS_ADDRESS
+
+ # Priority-ordered list of sessions (WM/DE)
+ sessions=(
+ "Hyprland"
+ "bspwm"
+ "sway"
+ "gnome-session"
+ "startplasma-x11"
+ "startxfce4"
+ "openbox"
+ "i3"
+ )
+
+ # Handle saved session
+ if [ -f "$HOME/.session" ]; then
+ chosen_session=$(<"$HOME/.session")
+ rm -f "$HOME/.session"
fi
-fi
-# Try default sessions in priority
-for wm in "${sessions[@]}"; do
- if command -v "$wm" >/dev/null 2>&1; then
- echo "Starting session: $wm"
- start_session "$wm"
- exit
+ launch_session() {
+ local s="$1"
+ case "$s" in
+ bspwm)
+ export XDG_SESSION_TYPE="x11"
+ exec startx /usr/bin/bspwm
+ ;;
+ Hyprland|sway)
+ exec dbus-launch --sh-syntax --exit-with-session "$s" >/dev/null 2>&1
+ ;;
+ gnome-session|startplasma-x11|startxfce4|openbox|i3)
+ exec "$s"
+ ;;
+ *)
+ return 1
+ ;;
+ esac
+ }
+
+ # Try saved session first
+ if [ -n "$chosen_session" ]; then
+ if launch_session "$chosen_session"; then
+ exit
+ else
+ echo "Saved session '$chosen_session' not found. Falling back..."
+ fi
fi
-done
-# Fallback: Check for common display managers (GDM/LightDM/SDDM)
-for dm in gdm lightdm sddm; do
- if command -v "$dm" >/dev/null 2>&1; then
- echo "Launching display manager: $dm"
- exec "$dm"
- fi
-done
+ # Try default sessions in priority
+ for wm in "${sessions[@]}"; do
+ if command -v "$wm" >/dev/null 2>&1; then
+ echo "Starting session: $wm"
+ launch_session "$wm"
+ exit
+ fi
+ done
+
+ # Fallback: Check for common display managers
+ for dm in gdm lightdm sddm; do
+ if command -v "$dm" >/dev/null 2>&1; then
+ echo "Launching display manager: $dm"
+ exec "$dm"
+ fi
+ done
+
+ echo "No suitable window manager or display manager found."
+ exit 1
+}
-echo "No suitable window manager or display manager found."
-exit 1
+# -------------------------
+# Only run session loader when:
+# - No DISPLAY (not inside an existing GUI)
+# - On first VT (tty1)
+# -------------------------
+if [ -z "$DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ]; then
+ start_session
+fi