diff options
-rw-r--r-- | .bash_profile | 13 | ||||
-rwxr-xr-x[-rw-r--r--] | .config/X11/xinitrc | 4 | ||||
-rw-r--r-- | .config/systemd/user/x11vnc.service | 2 | ||||
-rwxr-xr-x | .local/bin/scripts/sx | 56 |
4 files changed, 61 insertions, 14 deletions
diff --git a/.bash_profile b/.bash_profile index fa51855..65b8d02 100644 --- a/.bash_profile +++ b/.bash_profile @@ -9,15 +9,14 @@ prefixPath() { export PATH; } -# set xauthority path -export XAUTHORITY=$HOME/.config/X11/Xauthority; +# path exports +prefixPath "$HOME/.local/bin"; +prefixPath "$HOME/.local/bin/scripts"; # auto login [ "$EUID" != 0 ] && [ -z "$DISPLAY" ] && [ "$(tty)" = '/dev/tty1' ] \ && command -v nix && "$HOME"/.local/bin/scripts/nix-xorg-conf > "$HOME"/.config/X11/xorg.conf.d/00-modules.conf \ - && exec xinit "$HOME/.config/X11/xinitrc" -- :0 \ - -configdir "$HOME/.config/X11/xorg.conf.d" \ - -logfile "$HOME/.cache/xorg.log" vt1 -keeptty -auth "$XAUTHORITY"; + && exec sx; # set umask umask 0022; @@ -34,10 +33,6 @@ PS1_SSHD='$(E=$? && [ "$E" = 0 ] || echo "$E ")\[\e[0;32m\]\W\[\e[0m\] \[\e[0;32 # ssh set prompt [ -n "$SSH_CLIENT" ] && [ "$EUID" != 0 ] && export PS1="$PS1_SSHD"; -# path exports -prefixPath "$HOME/.local/bin"; -prefixPath "$HOME/.local/bin/scripts"; - # xdg exports export XDG_CACHE_HOME="$HOME/.cache" export XDG_CONFIG_HOME="$HOME/.config" diff --git a/.config/X11/xinitrc b/.config/X11/xinitrc index 163e31e..18e09b9 100644..100755 --- a/.config/X11/xinitrc +++ b/.config/X11/xinitrc @@ -18,10 +18,6 @@ xsetroot -cursor_name left_ptr; # set keypress repeat xset r rate 200 60; -# generate xauth -grep "$(hostname)" "$Xauthority" || rm -f "$Xauthority"; -xauth generate :0 . trusted; - # import systemctl environment systemctl --user import-environment; diff --git a/.config/systemd/user/x11vnc.service b/.config/systemd/user/x11vnc.service index 1500687..98e6fe7 100644 --- a/.config/systemd/user/x11vnc.service +++ b/.config/systemd/user/x11vnc.service @@ -7,7 +7,7 @@ Type=simple RestartSec=1s Restart=always SyslogIdentifier=x11vnc -ExecStart=/usr/bin/env x11vnc -display :0 -rfbport 5900 -shared -usepw -forever -nowireframe -norepeat -noxdamage -noxrecord -ncache_cr -noxfixes -auth $XAUTHORITY +ExecStart=/usr/bin/env x11vnc -display $DISPLAY -rfbport 5900 -shared -usepw -forever -nowireframe -norepeat -noxdamage -noxrecord -ncache_cr -noxfixes -auth $XAUTHORITY [Install] WantedBy=default.target diff --git a/.local/bin/scripts/sx b/.local/bin/scripts/sx new file mode 100755 index 0000000..ef954de --- /dev/null +++ b/.local/bin/scripts/sx @@ -0,0 +1,56 @@ +#!/bin/sh -- +# LICENCE: MIT +# https://github.com/Earnestly/sx + +stty=$(stty -g) +tty=$(tty) +tty=${tty#/dev/tty} + +cfgdir=${XDG_CONFIG_HOME:-$HOME/.config}/X11 +datadir=${XDG_CONFIG_HOME:-$HOME/.config}/X11 + +cleanup() { + if [ "$pid" ] && kill -0 "$pid" 2> /dev/null; then + kill "$pid" + wait "$pid" + xorg=$? + fi + + if ! stty "$stty"; then + stty sane + fi + + xauth remove :"$tty" + + if [ "$1" = exit ]; then + exit "${xorg:-0}" + fi +} + + +mkdir -p -- "$cfgdir" "$datadir" +export XAUTHORITY="${XAUTHORITY:-$datadir/Xauthority}" +touch -- "$XAUTHORITY" + +xauth add :"$tty" MIT-MAGIC-COOKIE-1 "$(od -An -N16 -tx /dev/urandom | tr -d ' ')" + +trap 'cleanup; trap - INT; kill -INT "$$"' INT +trap 'cleanup exit' EXIT HUP TERM QUIT + +# Xorg will check whether it inherited a USR1 with a disposition of SIG_IGN and +# use this state to reply back to the parent process with its own USR1. +# This is done to indicate that the server is ready to accept connections. +# Taking advantage of this feature allows launching the client directly from a +# USR1 signal trap which obviates the need to poll for server readiness. + +trap 'DISPLAY=:$tty exec "${@:-$cfgdir/xinitrc}" & wait "$!"' USR1 + +(trap '' USR1 && exec Xorg :"$tty" \ + -keeptty vt"$tty" \ + -noreset \ + -auth "$XAUTHORITY" \ + -configdir "$HOME/.config/X11/xorg.conf.d" \ + -logfile "$HOME/.cache/xorg.log" \ +) & pid=$! + +wait "$pid" |