Skip to content

Instantly share code, notes, and snippets.

@vodik
Last active November 23, 2021 20:54
Show Gist options
  • Save vodik/9442735 to your computer and use it in GitHub Desktop.
Save vodik/9442735 to your computer and use it in GitHub Desktop.
startx alternative
#!/bin/bash
# startx
# Alternative, simpler startx which makes use of the XDG specification
# - assumes dbus is already running
[[ -n "$DISPLAY" ]] && exit 0
[[ -z "$XDG_VTNR" ]] && exit 1
XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache}
XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-/run/user/$UID}
unset SESSION_MANAGER
export DISPLAY=:"$XDG_VTNR"
export XAUTHORITY="$XDG_RUNTIME_DIR/X11-$DISPLAY-authority"
touch $XAUTHORITY
xauth -qf "$XAUTHORITY" add "$DISPLAY" . "$(mcookie)"
xinitrc="$XDG_CONFIG_HOME"/xinitrc
log="$XDG_CACHE_HOME/xsession-$DISPLAY.log"
serveropts=(
"$DISPLAY"
vt"$XDG_VTNR"
-noreset
-nolisten tcp
-auth "$XAUTHORITY"
)
exec systemd-run --user --scope --unit="xinit-${DISPLAY}.scope" \
xinit "$xinitrc" "$@" -- /usr/bin/X "${serveropts[@]}" 3>$log
@vodik
Copy link
Author

vodik commented Mar 9, 2014

xinit-:1.scope - /usr/bin/xinit /home/simon/.config/xinitrc -- /usr/bin/X :1 vt1 -noreset -nolisten tcp -auth /run/user/1000/X11-:1-authority
   Loaded: loaded (/home/simon/.config/systemd/user/xinit-:1.scope; static)
  Drop-In: /home/simon/etc/systemd/user/xinit-:1.scope.d
           └─90-Description.conf, 90-SendSIGHUP.conf
   Active: active (running) since Sat 2014-03-08 23:09:57 EST; 37s ago
   CGroup: /user.slice/user-1000.slice/user@1000.service/xinit-:1.scope
           ├─673 /usr/bin/xinit /home/simon/.config/xinitrc -- /usr/bin/X :1 vt1 -noreset -nolisten tcp -auth /run/user/1000/X11-:1-authority
           ├─677 /usr/bin/X :1 vt1 -noreset -nolisten tcp -auth /run/user/1000/X11-:1-authority
           ├─684 /home/simon/.xmonad/xmonad-x86_64-linux
           ├─686 dzen2 -y -16 -h 16 -fn -*-envy code r-medium-r-normal-*-12-*-*-*-*-*-*-* -fg #ffffff -bg #000000 -ta l -e 'onstart lower'
           ├─688 dunst
           ├─692 compton -cGb --backend glx
           ├─693 termite
           ├─724 gnome-pty-helper
           ├─727 /bin/zsh
           ├─748 tmux attach -t irc
           ├─752 tmux new -ds irc weechat
           ├─753 weechat
           ├─786 aurora
           ├─787 termite -r scratchpad
           ├─789 gnome-pty-helper
           ├─794 /bin/zsh
           └─943 systemctl --user status xinit-:1.scope

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment