2019-04-25 22:54:51 +02:00
|
|
|
#!/bin/sh
|
2015-07-12 17:50:37 +02:00
|
|
|
#
|
|
|
|
# ~/.xinitrc
|
|
|
|
#
|
2021-06-11 23:32:56 +02:00
|
|
|
# Executed by startx
|
|
|
|
#
|
2019-04-28 04:05:45 +02:00
|
|
|
|
2021-06-11 23:32:56 +02:00
|
|
|
# Execute system modules, just in case
|
2016-03-31 21:40:35 +02:00
|
|
|
if [ -d /etc/X11/xinit/xinitrc.d ]; then
|
|
|
|
for f in /etc/X11/xinit/xinitrc.d/*; do
|
|
|
|
[ -x "$f" ] && . "$f"
|
|
|
|
done
|
|
|
|
unset f
|
|
|
|
fi
|
2015-07-12 17:50:37 +02:00
|
|
|
|
2021-06-11 23:32:56 +02:00
|
|
|
# Load Xresources
|
|
|
|
[ -f ~/.config/Xresources/main ] && xrdb -I"$HOME" ~/.config/Xresources/main
|
|
|
|
|
|
|
|
# Disable the bell
|
|
|
|
xset b off
|
|
|
|
|
|
|
|
# Folders to search for desktop environments (DE) in
|
|
|
|
sessions_dirs="/usr/share/xsessions"
|
|
|
|
|
|
|
|
# If we have locally installed DE try them before system ones
|
|
|
|
sessions_dir_local="$HOME/.local/share/xsessions"
|
|
|
|
if [ -d "$sessions_dir_local" ]
|
|
|
|
then
|
|
|
|
sessions_dirs="$sessions_dir_local $sessions_dirs"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If we have junest installed DE try them before all others
|
2021-12-02 10:57:09 +01:00
|
|
|
sessions_dir_junest="$HOME/.junest/usr/share/xsessions"
|
2021-06-11 23:32:56 +02:00
|
|
|
if [ -d "$sessions_dir_junest" ]
|
|
|
|
then
|
|
|
|
sessions_dirs="$sessions_dir_junest $sessions_dirs"
|
|
|
|
fi
|
|
|
|
|
|
|
|
startSession() {
|
|
|
|
session_dir="$1"
|
|
|
|
session_name="$2"
|
|
|
|
|
|
|
|
session_file="${session_dir}/${session_name}.desktop"
|
|
|
|
executable="$(grep ^Exec= "$session_file" | cut -d'=' -f2)"
|
|
|
|
# TODO Does this work with parameters?
|
|
|
|
# gnome-classic might need some
|
|
|
|
|
|
|
|
# If this is a Junest DE, we need to wrap it
|
|
|
|
if [ "$sessions_dir" = "$sessions_dir_junest" ]
|
|
|
|
then
|
|
|
|
# Some DMs enforce that to you,
|
|
|
|
# which shows warning on Junest
|
|
|
|
unset LD_PRELOAD
|
|
|
|
|
|
|
|
# The intended way:
|
|
|
|
# exec ~/.local/bin/junest "$executable" $parameters
|
|
|
|
# Too restricted to the outside (e.g. Yubikey isn't accessible)
|
|
|
|
|
|
|
|
# The custom way
|
|
|
|
exec ~/.local/bin/junest --backend-args "--dev-bind /run /run" "$executable" $parameters
|
|
|
|
|
|
|
|
# The fallback wrappers way
|
|
|
|
# export PATH="$PATH:~/.junest/usr/bin_wrappers"
|
|
|
|
# exec "$executable" $parameters
|
|
|
|
# Should work but doesn't, I forgot why
|
|
|
|
|
|
|
|
# The "I do what I want" way
|
|
|
|
#exec bwrap --bind $HOME/.junest / --bind $HOME $HOME --bind /tmp /tmp --proc /proc --dev-bind /dev /dev --dev-bind /run /run "$executable" $parameters
|
|
|
|
# Even Alacritty doesn't work here
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
exec "$executable" $parameters
|
|
|
|
}
|
|
|
|
|
|
|
|
trySession() { # session_name
|
|
|
|
session_name="$1"
|
|
|
|
for sessions_dir in $sessions_dirs
|
|
|
|
do
|
|
|
|
session_file="$sessions_dir/${session_name}.desktop"
|
|
|
|
if [ -f "$session_file" ]
|
|
|
|
then
|
|
|
|
startSession "$sessions_dir" "$session_name"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -n "$1" ]
|
|
|
|
then
|
|
|
|
trySession "$1"
|
|
|
|
else
|
|
|
|
trySession i3
|
|
|
|
trySession xfce4
|
|
|
|
trySession mate
|
|
|
|
trySession plasma
|
|
|
|
trySession gnome
|
|
|
|
trySession kde
|
|
|
|
fi
|
2015-07-12 20:59:47 +02:00
|
|
|
|
2021-06-11 23:32:56 +02:00
|
|
|
# If we found nothing by then, RIP
|
|
|
|
echo "Couldn't find a suitable DM."
|
|
|
|
exit 1
|
2019-04-28 04:05:45 +02:00
|
|
|
|