Skip to content

Instantly share code, notes, and snippets.

Created February 25, 2018 23:34
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 anonymous/1ef92429001901dea095c1971c736ae5 to your computer and use it in GitHub Desktop.
Save anonymous/1ef92429001901dea095c1971c736ae5 to your computer and use it in GitHub Desktop.
#! /nix/store/jgw8hxx7wzkyhb2dr9hwsd9h2caaasdc-bash-4.4-p12/bin/bash
# Expected parameters:
# $1 = <desktop-manager>+<window-manager>
# Actual parameters (FIXME):
# SDDM is calling this script like the following:
# $1 = /nix/store/xxx-xsession (= $0)
# $2 = <desktop-manager>+<window-manager>
# SLiM is using the following parameter:
# $1 = /nix/store/xxx-xsession <desktop-manager>+<window-manager>
# LightDM keeps the double quotes:
# $1 = /nix/store/xxx-xsession "<desktop-manager>+<window-manager>"
# The fake/auto display manager doesn't use any parameters and GDM is
# broken.
# If you want to "debug" this script don't print the parameters to stdout
# or stderr because this script will be executed multiple times and the
# output won't be visible in the log when the script is executed for the
# first time (e.g. append them to a file instead)!
# All of the above cases are handled by the following hack (FIXME).
# Since this line is *very important* for *all display managers* it is
# very important to test changes to the following line with all display
# managers:
if [ "${1:0:1}" = "/" ]; then eval exec "$1" "$2" ; fi
# Now it should be safe to assume that the script was called with the
# expected parameters.
if [ -z "$_DID_SYSTEMD_CAT" ]; then
_DID_SYSTEMD_CAT=1 exec /nix/store/4lczhf3yxjrgankyky6ydiq7wvwsaax6-systemd-234/bin/systemd-cat -t xsession -- "$0" "$@"
fi
. /etc/profile
cd "$HOME"
# The first argument of this script is the session type.
sessionType="$1"
if [ "$sessionType" = default ]; then sessionType=""; fi
if test -z "$DBUS_SESSION_BUS_ADDRESS"; then
exec /nix/store/np3c63wmswr9dxvh3slbnsh99ci5jcnb-dbus-1.10.22-lib/bin/dbus-launch --exit-with-session "$0" "$sessionType"
fi
# Start PulseAudio if enabled.
/nix/store/8ny2y2gndbcn3lawwadlskir2cfmaix8-pulseaudio-10.0/bin/pulseaudio --start
# Publish access credentials in the root window.
/nix/store/8ny2y2gndbcn3lawwadlskir2cfmaix8-pulseaudio-10.0/bin/pactl load-module module-x11-publish "display=$DISPLAY"
# Tell systemd about our $DISPLAY and $XAUTHORITY.
# This is needed by the ssh-agent unit.
#
# Also tell systemd about the dbus session bus address.
# This is required by user units using the session bus.
/nix/store/4lczhf3yxjrgankyky6ydiq7wvwsaax6-systemd-234/bin/systemctl --user import-environment DISPLAY XAUTHORITY DBUS_SESSION_BUS_ADDRESS
# Load X defaults.
/nix/store/qymavwk6vk7kz85g5a33bydzc4yyymfb-xrdb-1.1.0/bin/xrdb -merge /nix/store/ywcdfpn7lbzmcw2xwhn5f1l1gi09934q-Xresources-Xft
if test -e ~/.Xresources; then
/nix/store/qymavwk6vk7kz85g5a33bydzc4yyymfb-xrdb-1.1.0/bin/xrdb -merge ~/.Xresources
elif test -e ~/.Xdefaults; then
/nix/store/qymavwk6vk7kz85g5a33bydzc4yyymfb-xrdb-1.1.0/bin/xrdb -merge ~/.Xdefaults
fi
# Speed up application start by 50-150ms according to
# http://kdemonkey.blogspot.nl/2008/04/magic-trick.html
rm -rf "$HOME/.compose-cache"
mkdir "$HOME/.compose-cache"
# Work around KDE errors when a user first logs in and
# .local/share doesn't exist yet.
mkdir -p "$HOME/.local/share"
unset _DID_SYSTEMD_CAT
# Export the config/themes for slimlock.
export SLIM_THEMESDIR=/nix/store/i7vb4x58chi4yim9cblxsli8cgh04rcg-slim-theme
source /nix/store/1ximi7apy1wdc4hgywldyr5sln39r5hk-set-environment
[[ -e $XDG_CONFIG_HOME/xorg/xmodmap ]] && xmodmap $XDG_CONFIG_HOME/xorg/xmodmap
[[ -e $XDG_CONFIG_HOME/xorg/xresources ]] && xrdb -merge $XDG_CONFIG_HOME/xorg/xresources
# Allow the user to execute commands at the beginning of the X session.
if test -f ~/.xprofile; then
source ~/.xprofile
fi
# Start systemd user services for graphical sessions
/nix/store/4lczhf3yxjrgankyky6ydiq7wvwsaax6-systemd-234/bin/systemctl --user start graphical-session.target
# Allow the user to setup a custom session type.
if test -x ~/.xsession; then
exec ~/.xsession
else
if test "$sessionType" = "custom"; then
sessionType="" # fall-thru if there is no ~/.xsession
fi
fi
# The session type is "<desktop-manager>+<window-manager>", so
# extract those (see:
# http://wiki.bash-hackers.org/syntax/pe#substring_removal).
windowManager="${sessionType##*+}"
: ${windowManager:=i3}
desktopManager="${sessionType%%+*}"
: ${desktopManager:=none}
# Start the window manager.
case "$windowManager" in
(i3)
/nix/store/bhhdqgn22nqz4knjlwh1vhk42sk7qjsh-i3-4.14.1/bin/i3 &
waitPID=$!
;;
(none)
;;
(*) echo "$0: Window manager '$windowManager' not found.";;
esac
# Start the desktop manager.
case "$desktopManager" in
(xterm)
/nix/store/k3pw7hg2x8p2pzrcgx2ws3fdpz08hz1l-xterm-330/bin/xterm -ls &
waitPID=$!
if [ -e $HOME/.background-image ]; then
/nix/store/pk5z1i9m0fzmkx9q1sfgsnbg2d0792dq-feh-2.20/bin/feh --bg-scale $HOME/.background-image
else
# Use a solid black background as fallback
/nix/store/3vbjyvl41dpnwhfp94ifw0ws8r70qcpx-xsetroot-1.1.0/bin/xsetroot -solid black
fi
;;
(none)
if [ -e $HOME/.background-image ]; then
/nix/store/pk5z1i9m0fzmkx9q1sfgsnbg2d0792dq-feh-2.20/bin/feh --bg-scale $HOME/.background-image
else
# Use a solid black background as fallback
/nix/store/3vbjyvl41dpnwhfp94ifw0ws8r70qcpx-xsetroot-1.1.0/bin/xsetroot -solid black
fi
;;
(*) echo "$0: Desktop manager '$desktopManager' not found.";;
esac
test -n "$waitPID" && wait "$waitPID"
/nix/store/4lczhf3yxjrgankyky6ydiq7wvwsaax6-systemd-234/bin/systemctl --user stop graphical-session.target
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment