Modularization, prepare for some more thorough XDG autostart checks
This commit is contained in:
parent
bb0482cf54
commit
f5cd12c6c8
54
firestarter
54
firestarter
@ -41,20 +41,22 @@ err() {
|
||||
exit "$2"
|
||||
fi
|
||||
}
|
||||
startfile() {
|
||||
# Start a program using an alternatives list
|
||||
gettarget() {
|
||||
# Parse a defaults file to get the target program
|
||||
[ -z "$1" ] && return 1
|
||||
! [ -r "$1" ] && return 2
|
||||
if [ -x "$1" ]; then
|
||||
# File is a script
|
||||
"$1" &
|
||||
disown "$!"
|
||||
[ -r "$1" ] || return 1
|
||||
# Every odd line is the check line
|
||||
# Every even one is the exec line
|
||||
while read -r checkline; do
|
||||
read -r execline
|
||||
if bash -c "$checkline" > /dev/null 2>&1; then
|
||||
_return="$execline"
|
||||
return 0
|
||||
else
|
||||
# File is a defaults file
|
||||
while read line; do
|
||||
echo "$line"
|
||||
done < "$1"
|
||||
continue
|
||||
fi
|
||||
done < "$1"
|
||||
return 2
|
||||
}
|
||||
|
||||
# Steps in execution
|
||||
@ -261,15 +263,6 @@ command -v kwin
|
||||
kwin
|
||||
command -v 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
|
||||
}
|
||||
step_printhelp() {
|
||||
@ -411,26 +404,22 @@ step_execute() {
|
||||
local filename="$(basename -- "$file")"
|
||||
local logfile="$_logdir/$filename"
|
||||
[ -n "$FS_NOLOG" ] && logfile="/dev/null"
|
||||
# Every odd line is the check line
|
||||
# Every even one is the exec line
|
||||
while read -r checkline; do
|
||||
read -r execline
|
||||
if bash -c "$checkline" > /dev/null 2>&1; then
|
||||
log "Found target for \"$filename\": \"$execline\""
|
||||
if gettarget "$file"; then
|
||||
target="$_return"
|
||||
log "Found target for \"$filename\": \"$target\""
|
||||
if ! [ "$_dryrun" = "1" ]; then
|
||||
if [ -f "$logfile" ]; then
|
||||
[ -f "$logfile.old" ] && rm "$logfile.old"
|
||||
mv "$logfile" "$logfile.old"
|
||||
fi
|
||||
bash -c "$execline" > "$logfile" 2>&1 &
|
||||
bash -c "$target" > "$logfile" 2>&1 &
|
||||
fi
|
||||
break
|
||||
else
|
||||
continue
|
||||
fi
|
||||
done < "$file"
|
||||
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
|
||||
log "Sourcing .firestarterrc"
|
||||
"$_firestarterrc"
|
||||
@ -487,6 +476,7 @@ main() {
|
||||
step_check
|
||||
step_preexecute
|
||||
step_execute
|
||||
step_postexecute
|
||||
step_wait
|
||||
return 0
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user