Port over some preinit stuff from dsk, add xdg autostarter

This commit is contained in:
Salt 2019-06-19 07:35:31 -05:00
parent aa99bf2fef
commit c82053c53f

View File

@ -115,6 +115,15 @@ command -v mate-settings-daemon
mate-settings-daemon
command -v gnome-settings-daemon
gnome-settings-daemon
EOF
# XDG autostarter
cat << EOF > "$g_configdir/xdg-autostart"
command -v dex
dex -a
command -v fbautostart
fbautostart
command -v xdg-autostart
xdg-autostart "\${XDG_CURRENT_DESKTOP:-firestarter}"
EOF
# X compositor
cat << EOF > "$g_configdir/x-compositor"
@ -226,13 +235,13 @@ EOF
}
step_preexecute() {
# Special things that can't use simple configuration files
[ "$dryrun" == "1" ] && return 0
[ "$dryrun" = "1" ] && return 0
# dbus
if \
[ -z "$DBUS_SESSION_BUS_ADDRESS" ] && \
[ -n "$XDG_RUNTIME_DIR" ] && \
[ "$XDG_RUNTIME_DIR" == "/run/user/$(id -u)" ] && \
[ "$XDG_RUNTIME_DIR" = "/run/user/$(id -u)" ] && \
[ -S "$XDG_RUNTIME_DIR/bus" ]; then
# We already have a bus started, use it
export DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus"
@ -252,6 +261,41 @@ step_preexecute() {
fi
fi
unset hasdbus
# kcminit/Qt settings
if command -v kcminit > /dev/null 2>&1; then
log "Initializing KDE Control Module settings"
kcminit > /dev/null 2>&1
elif command -v qt5ct > /dev/null 2>&1; then
log "Integrating qt5ct"
if [ -z "$QT_QPA_PLATFORMTHEME" ]; then
export QT_QPA_PLATFORMTHEME="qt5ct"
log "Exporting QT_QPA_PLATFORMTHEME as \"$QT_QPA_PLATFORMTHEME\""
else
log "Using existing theme setting \"$QT_QPA_PLATFORMTHEME\""
fi
if [ -z "$QT_AUTO_SCREEN_SCALE_FACTOR" ]; then
export QT_AUTO_SCREEN_SCALE_FACTOR="0"
log "Exporting QT_AUTO_SCREEN_SCALE_FACTOR as $QT_AUTO_SCREEN_SCALE_FACTOR"
else
log "Using existing scale setting \"$QT_AUTO_SCREEN_SCALE_FACTOR\""
fi
fi
# xhost
if command -v xhost > /dev/null 2>&1; then
if xhost +si:localuser:"$(id -un)" > /dev/null 2>&1; then
log "Session can be accessed in other sessions by this user"
else
log "Failed to open session up via xhost"
fi
fi
# xset
if command -v xset > /dev/null 2>&1; then
log "Disabling bell"
xset -b
fi
}
step_execute() {
if ! [ -d "$g_configdir" ]; then
@ -264,6 +308,17 @@ step_execute() {
err "Failed to create log directory \"$g_logdir\"" 53
fi
fi
if [ -f "$HOME/.xsessionrc" ]; then
if [ -r "$HOME/.xsessionrc" ]; then
if ! [ "$dryrun" = "1" ]; then
source "$HOME/.xsessionrc"
else
log "Would have sourced in .xsessionrc"
fi
else
log "Could not read .xsessionrc"
fi
fi
for file in "$g_configdir"/*; do
if ! [ -f "$file" ]; then
log "No configuration files found; generating defaults"
@ -283,7 +338,7 @@ step_execute() {
[ -f "$logfile.old" ] && rm "$logfile.old"
mv "$logfile" "$logfile.old"
fi
if ! [ "$dryrun" == "1" ]; then
if ! [ "$dryrun" = "1" ]; then
bash -c "$execline" > "$logfile" &
fi
break
@ -294,7 +349,7 @@ step_execute() {
done
}
step_wait() {
[ "$dryrun" == "1" ] && exit 0
[ "$dryrun" = "1" ] && exit 0
log "Waiting for programs to exit"
wait
exit 0
@ -305,7 +360,7 @@ main() {
while getopts ":dgh" opt; do
case $opt in
d)
if ! [ "$dryrun" == "1" ]; then
if ! [ "$dryrun" = "1" ]; then
log "Performing a dry run"
dryrun=1
fi