Modularization, prepare for some more thorough XDG autostart checks

This commit is contained in:
Salt 2019-06-21 21:40:43 -05:00
parent bb0482cf54
commit f5cd12c6c8

View File

@ -41,20 +41,22 @@ err() {
exit "$2" exit "$2"
fi fi
} }
startfile() { gettarget() {
# Start a program using an alternatives list # Parse a defaults file to get the target program
[ -z "$1" ] && return 1 [ -z "$1" ] && return 1
! [ -r "$1" ] && return 2 [ -r "$1" ] || return 1
if [ -x "$1" ]; then # Every odd line is the check line
# File is a script # Every even one is the exec line
"$1" & while read -r checkline; do
disown "$!" read -r execline
else if bash -c "$checkline" > /dev/null 2>&1; then
# File is a defaults file _return="$execline"
while read line; do return 0
echo "$line" else
done < "$1" continue
fi fi
done < "$1"
return 2
} }
# Steps in execution # Steps in execution
@ -261,15 +263,6 @@ command -v kwin
kwin kwin
command -v tinywm command -v tinywm
tinywm tinywm
EOF
# XDG autostarter
cat << EOF > "$_configdir/xdg-autostart"
command -v dex
dex -a
command -v fbautostart
fbautostart
command -v xdg-autostart
xdg-autostart "\${XDG_CURRENT_DESKTOP:-firestarter}"
EOF EOF
} }
step_printhelp() { step_printhelp() {
@ -411,26 +404,22 @@ step_execute() {
local filename="$(basename -- "$file")" local filename="$(basename -- "$file")"
local logfile="$_logdir/$filename" local logfile="$_logdir/$filename"
[ -n "$FS_NOLOG" ] && logfile="/dev/null" [ -n "$FS_NOLOG" ] && logfile="/dev/null"
# Every odd line is the check line if gettarget "$file"; then
# Every even one is the exec line target="$_return"
while read -r checkline; do log "Found target for \"$filename\": \"$target\""
read -r execline if ! [ "$_dryrun" = "1" ]; then
if bash -c "$checkline" > /dev/null 2>&1; then if [ -f "$logfile" ]; then
log "Found target for \"$filename\": \"$execline\"" [ -f "$logfile.old" ] && rm "$logfile.old"
if ! [ "$_dryrun" = "1" ]; then mv "$logfile" "$logfile.old"
if [ -f "$logfile" ]; then
[ -f "$logfile.old" ] && rm "$logfile.old"
mv "$logfile" "$logfile.old"
fi
bash -c "$execline" > "$logfile" 2>&1 &
fi fi
break bash -c "$target" > "$logfile" 2>&1 &
else
continue
fi fi
done < "$file" fi
done done
# And then source in a user script if it exists }
step_postexecute() {
# Wait for the WM to initialize, if one was found
# Source in a user script if it exists
if [ -r "$_firestarterrc" ] && [ -z "$_dryrun" ]; then if [ -r "$_firestarterrc" ] && [ -z "$_dryrun" ]; then
log "Sourcing .firestarterrc" log "Sourcing .firestarterrc"
"$_firestarterrc" "$_firestarterrc"
@ -487,6 +476,7 @@ main() {
step_check step_check
step_preexecute step_preexecute
step_execute step_execute
step_postexecute
step_wait step_wait
return 0 return 0
} }