Skip to content

Instantly share code, notes, and snippets.

@mk-fg
Created September 6, 2019 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mk-fg/58f700c0a11616a54add0c6381d223a7 to your computer and use it in GitHub Desktop.
Save mk-fg/58f700c0a11616a54add0c6381d223a7 to your computer and use it in GitHub Desktop.
[Unit]
Conflicts=getty@tty%i.service
After=systemd-user-sessions.service
[Service]
User=gui
PAMName=login
TTYPath=/dev/tty%I
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes
UtmpIdentifier=tty%I
UtmpMode=user
Environment=XDG_VTNR=%I
Environment=XDG_SESSION_CLASS=user
Environment=XDG_SESSION_TYPE=x11
Environment=XDG_SESSION_DESKTOP=i3
ExecStart=/home/gui/.xinitrc
[Install]
WantedBy=graphical.target
total 8.0K
drwxr-xr-x 2 fraggod fraggod 4.0K Mar 4 2019 .
drwxr-xr-x 4 fraggod fraggod 4.0K Mar 4 2019 ..
lrwxrwxrwx 1 fraggod fraggod 18 Sep 10 2018 compton.service -> ../compton.service
lrwxrwxrwx 1 fraggod fraggod 13 Sep 9 2018 i3.service -> ../i3.service
lrwxrwxrwx 1 fraggod fraggod 19 Sep 11 2018 switcher.service -> ../switcher.service
lrwxrwxrwx 1 fraggod fraggod 17 Mar 4 2019 x11vnc.service -> ../x11vnc.service
lrwxrwxrwx 1 fraggod fraggod 14 Sep 9 2018 xorg.target -> ../xorg.target
total 8.0K
drwxr-xr-x 2 fraggod fraggod 4.0K Sep 9 2018 .
drwxr-xr-x 4 fraggod fraggod 4.0K Mar 4 2019 ..
lrwxrwxrwx 1 fraggod fraggod 15 Sep 9 2018 xorg.service -> ../xorg.service
lrwxrwxrwx 1 fraggod fraggod 26 Sep 9 2018 xorg-start-wait.service -> ../xorg-start-wait.service
[Unit]
Description=X session
#!/bin/bash
env_pids=()
exit_cleanup() {
systemctl --user --no-block exit &
disown # to avoid lockups in case of systemd/dbus fails
for pid in "${env_pids[@]}"; do kill "$pid" 2>/dev/null; done
}
trap exit_cleanup TERM INT
source /etc/profile
export DISPLAY=:1 # hardcoded in systemd units
systemctl --user import-environment
systemctl --user start startx.target
# X screensaver/dpms "always on" settings
xset s off s noblank dpms force on -dpms
sleep infinity &
env_pids+=( $! )
wait
exit 0
# This unit waits for Xorg to to avoid race conditions
# when starting everything that relies on Xorg server running.
# Needed because Xorg socket activation does not work
# since 1.18+: https://bugs.freedesktop.org/show_bug.cgi?id=93072
[Unit]
PartOf=xorg.target
[Service]
Type=oneshot
ExecStart=/usr/bin/mkdir -pm1777 /tmp/.X11-unix
ExecStart=/bin/bash -c "\
trap 'pkill -g 0' EXIT; trap 'exit' TERM; \
inotifywait -qq -e create /tmp/.X11-unix/ & \
[[ -e /tmp/.X11-unix/X1 ]] || wait"
[Unit]
PartOf=xorg.target
[Service]
SyslogIdentifier=%p
SuccessExitStatus=0 1
ExecStart=/usr/bin/X :1 -nolisten tcp -verbose 0 vt${XDG_VTNR}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment