Revamped xsession

Now supports Junest and should be better integrated with DM
This commit is contained in:
Geoffrey Frogeye 2021-06-11 21:38:47 +02:00
parent 46abb5f07a
commit 45e32adc61
2 changed files with 76 additions and 45 deletions

View file

@ -4,8 +4,6 @@
# #
# Executed by xinit (startx) # Executed by xinit (startx)
echo ~/.xinitrc
if [ -d /etc/X11/xinit/xinitrc.d ]; then if [ -d /etc/X11/xinit/xinitrc.d ]; then
for f in /etc/X11/xinit/xinitrc.d/*; do for f in /etc/X11/xinit/xinitrc.d/*; do
[ -x "$f" ] && . "$f" [ -x "$f" ] && . "$f"

119
xsession
View file

@ -3,58 +3,91 @@
# #
# ~/.xsession # ~/.xsession
# #
# Might be sourced by DM when on custom # Sourced by display managers
# TODO Test that on a DM I guess?
# #
# Load Xresources
[ -f ~/.config/Xresources/main ] && xrdb -I"$HOME" ~/.config/Xresources/main [ -f ~/.config/Xresources/main ] && xrdb -I"$HOME" ~/.config/Xresources/main
# Disable the bell
xset b off xset b off
found=0 # Folders to search for desktop environments (DE) in
tryDM() { sessions_dirs="/usr/share/xsessions"
if [ $found -eq 0 ]; then
parameters='' # If we have locally installed DE try them before system ones
case $1 in sessions_dir_local="$HOME/.local/share/xsessions"
awesome ) executable=awesome;; if [ -d "$sessions_dir_local" ]
bspwm ) executable=bspwm;; then
catwm ) executable=catwm;; sessions_dirs="$sessions_dir_local $sessions_dirs"
cinnamon ) executable=cinnamon-session;; fi
dwm ) executable=dwm;;
enlightenment ) executable=enlightenment_start;; # If we have junest installed DE try them before all others
ede ) executable=startede;; sessions_dir_junest="$HOME/.local/share/xsessions"
fluxbox ) executable=startfluxbox;; if [ -d "$sessions_dir_junest" ]
gnome ) executable=gnome-session;; then
gnome-classic ) executable=gnome-session; parameters="--session=gnome-classic";; sessions_dirs="$sessions_dir_junest $sessions_dirs"
i3|i3wm ) executable=i3;; fi
icewm ) executable=icewm-session;;
jwm ) executable=jwm;; startSession() {
kde ) executable=startkde;; session_dir="$1"
mate ) executable=mate-session;; session_name="$2"
monster|monsterwm ) executable=monsterwm;;
notion ) executable=notion;; session_file="${session_dir}/${session_name}.desktop"
openbox ) executable=openbox-session;; executable="$(grep ^Exec= "$session_file" | cut -d'=' -f2)"
plasma ) executable=startplasma-x11;; # TODO Does this work with parameters?
unity ) executable=unity;; # gnome-classic might need some
xfce|xfce4 ) executable=startxfce4;;
xmonad ) executable=xmonad;; # If this is a Junest DE, we need to wrap it
*) executable=$1;; if [ "$sessions_dir" = "$sessions_dir_junest" ]
esac then
if command -v "$executable" # Some DMs enforce that to you,
then # which shows warning on Junest
found=1 unset LD_PRELOAD
exec "$executable" $parameters
fi # 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 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" ] if [ -n "$1" ]
then then
tryDM "$1" trySession "$1"
fi fi
tryDM i3 trySession i3
tryDM xfce4 trySession xfce4
tryDM mate trySession mate
tryDM plasma trySession plasma
tryDM gnome trySession gnome
tryDM kde trySession kde
# If we found nothing by then,
# I guess it's up to the DM to default to something