Cleanup, wait for WM to init before firing XDG autostarts
This commit is contained in:
parent
f5cd12c6c8
commit
2a2d475641
@ -32,7 +32,7 @@ command -v lemonbar
|
|||||||
~/.bin/lemonbar.sh | lemonbar
|
~/.bin/lemonbar.sh | lemonbar
|
||||||
```
|
```
|
||||||
|
|
||||||
After all these programs have been started, firestarter executes `~/.firestarterrc` if it exists.
|
After all these programs have been started, firestarter starts XDG autostart applications and executes `~/.firestarterrc` if it exists.
|
||||||
|
|
||||||
## Logging
|
## Logging
|
||||||
|
|
||||||
@ -68,6 +68,10 @@ Firestarter, in addition to spawning the programs in the default configs, also i
|
|||||||
| 53 | Failed to create logging directory (and logging is enabled) |
|
| 53 | Failed to create logging directory (and logging is enabled) |
|
||||||
| 54 | `HOME` does not exist or is unreadable |
|
| 54 | `HOME` does not exist or is unreadable |
|
||||||
|
|
||||||
|
## Idiosyncracies
|
||||||
|
|
||||||
|
* The `wm` config file is special; if it exists and a default can be found for it, firestarter will watch the `_NET_WM_NAME` atom on the root window, waiting for it to initialize before starting XDG autostarts. This prevents applications from being started before the WM is ready to manage them. You can disable this by setting `FS_NOWAITWM`.
|
||||||
|
|
||||||
## Contribution
|
## Contribution
|
||||||
|
|
||||||
Firestarter by no means contains an exhaustive list of all possible programs. If you know of or have created a program that should be added, *please* open an issue about it. The script should be light but its choices massive.
|
Firestarter by no means contains an exhaustive list of all possible programs. If you know of or have created a program that should be added, *please* open an issue about it. The script should be light but its choices massive.
|
||||||
|
56
firestarter
56
firestarter
@ -13,6 +13,8 @@ _configdir="${XDG_CONFIG_HOME:-$HOME/.config}/$_name"
|
|||||||
_logdir="${XDG_DATA_HOME:-$HOME/.local/share}/$_name/logs"
|
_logdir="${XDG_DATA_HOME:-$HOME/.local/share}/$_name/logs"
|
||||||
_firestarterrc="$HOME/.firestarterrc"
|
_firestarterrc="$HOME/.firestarterrc"
|
||||||
_sessionid="$(< /proc/self/sessionid)"
|
_sessionid="$(< /proc/self/sessionid)"
|
||||||
|
# Dummy fd for read sleeping
|
||||||
|
exec 1023<> <(:)
|
||||||
|
|
||||||
# Basic functions
|
# Basic functions
|
||||||
print() {
|
print() {
|
||||||
@ -41,6 +43,10 @@ err() {
|
|||||||
exit "$2"
|
exit "$2"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
has() {
|
||||||
|
[ -z "$1" ] && return 1
|
||||||
|
command -v "$1" > /dev/null 2>&1
|
||||||
|
}
|
||||||
gettarget() {
|
gettarget() {
|
||||||
# Parse a defaults file to get the target program
|
# Parse a defaults file to get the target program
|
||||||
[ -z "$1" ] && return 1
|
[ -z "$1" ] && return 1
|
||||||
@ -278,6 +284,7 @@ Start or generate a desktop environment configuration
|
|||||||
Additionally, firestarter responds to the following environment variables:
|
Additionally, firestarter responds to the following environment variables:
|
||||||
|
|
||||||
FS_NOLOG If nonempty, create no log files
|
FS_NOLOG If nonempty, create no log files
|
||||||
|
FS_NOWAITWM If nonempty, skip waiting on the WM to initialize
|
||||||
|
|
||||||
Copyright (c) 2019 rehashedsalt@cock.li
|
Copyright (c) 2019 rehashedsalt@cock.li
|
||||||
Licensed under the MIT License
|
Licensed under the MIT License
|
||||||
@ -303,7 +310,7 @@ step_check() {
|
|||||||
}
|
}
|
||||||
step_preexecute() {
|
step_preexecute() {
|
||||||
# Special things that can't use simple configuration files
|
# Special things that can't use simple configuration files
|
||||||
[ "$_dryrun" = "1" ] && return 0
|
[ -n "$_dryrun" ] && return 0
|
||||||
|
|
||||||
# Exports
|
# Exports
|
||||||
export XDG_CURRENT_DESKTOP="${XDG_CURRENT_DESKTOP:-firestarter}"
|
export XDG_CURRENT_DESKTOP="${XDG_CURRENT_DESKTOP:-firestarter}"
|
||||||
@ -319,7 +326,7 @@ step_preexecute() {
|
|||||||
hasdbus=1
|
hasdbus=1
|
||||||
elif \
|
elif \
|
||||||
[ -z "$DBUS_SESSION_BUS_ADDRESS" ] && \
|
[ -z "$DBUS_SESSION_BUS_ADDRESS" ] && \
|
||||||
command -v dbus-launch > /dev/null 2>&1; then
|
has dbus-launch; then
|
||||||
# We have dbus but haven't started up a bus yet
|
# We have dbus but haven't started up a bus yet
|
||||||
eval "$(dbus-launch --exit-with-session --sh-syntax)"
|
eval "$(dbus-launch --exit-with-session --sh-syntax)"
|
||||||
hasdbus=1
|
hasdbus=1
|
||||||
@ -327,18 +334,18 @@ step_preexecute() {
|
|||||||
log "Did not start dbus; some applications may misbehave"
|
log "Did not start dbus; some applications may misbehave"
|
||||||
fi
|
fi
|
||||||
if [ -n "$hasdbus" ]; then
|
if [ -n "$hasdbus" ]; then
|
||||||
if command -v dbus-update-activation-environment > /dev/null 2>&1; then
|
if has dbus-update-activation-environment; then
|
||||||
dbus-update-activation-environment --verbose --systemd --all > /dev/null 2>&1
|
dbus-update-activation-environment --verbose --systemd --all > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
unset hasdbus
|
unset hasdbus
|
||||||
|
|
||||||
# kcminit/Qt settings
|
# kcminit/Qt settings
|
||||||
if command -v kcminit > /dev/null 2>&1; then
|
if has kcminit; then
|
||||||
log "Initializing KDE Control Module settings"
|
log "Initializing KDE Control Module settings"
|
||||||
kcminit > /dev/null 2>&1
|
kcminit > /dev/null 2>&1
|
||||||
export XDG_CURRENT_DESKTOP="KDE"
|
export XDG_CURRENT_DESKTOP="KDE"
|
||||||
elif command -v qt5ct > /dev/null 2>&1; then
|
elif has qt5ct; then
|
||||||
log "Integrating qt5ct"
|
log "Integrating qt5ct"
|
||||||
if [ -z "$QT_QPA_PLATFORMTHEME" ]; then
|
if [ -z "$QT_QPA_PLATFORMTHEME" ]; then
|
||||||
export QT_QPA_PLATFORMTHEME="qt5ct"
|
export QT_QPA_PLATFORMTHEME="qt5ct"
|
||||||
@ -355,7 +362,7 @@ step_preexecute() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# xhost
|
# xhost
|
||||||
if command -v xhost > /dev/null 2>&1; then
|
if has xhost; then
|
||||||
if xhost +si:localuser:"$(id -un)" > /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"
|
log "Session can be accessed in other sessions by this user"
|
||||||
else
|
else
|
||||||
@ -364,7 +371,7 @@ step_preexecute() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# xresources
|
# xresources
|
||||||
if [ -n "$DISPLAY" ] && command -v xrdb && [ -r "$HOME/.Xresources" ]; then
|
if [ -n "$DISPLAY" ] && has xrdb && [ -r "$HOME/.Xresources" ]; then
|
||||||
if xrdb "$HOME/.Xresources" > /dev/null 2>&1; then
|
if xrdb "$HOME/.Xresources" > /dev/null 2>&1; then
|
||||||
log "Loaded in .Xresources"
|
log "Loaded in .Xresources"
|
||||||
else
|
else
|
||||||
@ -373,7 +380,7 @@ step_preexecute() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# xset
|
# xset
|
||||||
if command -v xset > /dev/null 2>&1; then
|
if has xset; then
|
||||||
log "Disabling bell"
|
log "Disabling bell"
|
||||||
xset -b
|
xset -b
|
||||||
fi
|
fi
|
||||||
@ -407,7 +414,7 @@ step_execute() {
|
|||||||
if gettarget "$file"; then
|
if gettarget "$file"; then
|
||||||
target="$_return"
|
target="$_return"
|
||||||
log "Found target for \"$filename\": \"$target\""
|
log "Found target for \"$filename\": \"$target\""
|
||||||
if ! [ "$_dryrun" = "1" ]; then
|
if [ -z "$_dryrun" ]; then
|
||||||
if [ -f "$logfile" ]; then
|
if [ -f "$logfile" ]; then
|
||||||
[ -f "$logfile.old" ] && rm "$logfile.old"
|
[ -f "$logfile.old" ] && rm "$logfile.old"
|
||||||
mv "$logfile" "$logfile.old"
|
mv "$logfile" "$logfile.old"
|
||||||
@ -418,7 +425,30 @@ step_execute() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
step_postexecute() {
|
step_postexecute() {
|
||||||
# Wait for the WM to initialize, if one was found
|
# Wait for the WM to initialize, if one was found and we have the tools
|
||||||
|
if [ -z "$FS_NOWAITWM" ] && gettarget "$_configdir/wm" && has xprop && has grep; then
|
||||||
|
log "Waiting for WM to initialize: \"$_return\""
|
||||||
|
for (( i=0; i<10; i++ )); do
|
||||||
|
line="$(xprop -root | grep ^_NET_WM_NAME | grep -o '"\S*"$')"
|
||||||
|
if [ -n "$line" ]; then
|
||||||
|
log "WM has intiailized, _NET_WM_NAME atom reads: $line"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
read -t 1 -u 1023
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
# Start XDG autostarters, if they exist
|
||||||
|
if [ -z "$_dryrun" ]; then
|
||||||
|
if has dex; then
|
||||||
|
dex -a > /dev/null 2>&1
|
||||||
|
elif has fbautostart; then
|
||||||
|
fbautostart > /dev/null 2>&1
|
||||||
|
elif has xdg-autostart; then
|
||||||
|
xdg-autostart ${XDG_CURRENT_DESKTOP:-firestarter}
|
||||||
|
else
|
||||||
|
log "Could not find an XDG autostarter"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
# Source in a user script if it exists
|
# 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"
|
||||||
@ -426,7 +456,7 @@ step_postexecute() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
step_wait() {
|
step_wait() {
|
||||||
[ "$_dryrun" = "1" ] && exit 0
|
[ -n "$_dryrun" ] && exit 0
|
||||||
log "Waiting for programs to exit"
|
log "Waiting for programs to exit"
|
||||||
log "Send any termination signal to firestarter to log out"
|
log "Send any termination signal to firestarter to log out"
|
||||||
trap step_logout EXIT
|
trap step_logout EXIT
|
||||||
@ -435,7 +465,7 @@ step_wait() {
|
|||||||
}
|
}
|
||||||
step_logout() {
|
step_logout() {
|
||||||
log "Logging out"
|
log "Logging out"
|
||||||
if command -v loginctl > /dev/null 2>&1; then
|
if has loginctl; then
|
||||||
# Use loginctl if possible
|
# Use loginctl if possible
|
||||||
if [ -n "$_sessionid" ]; then
|
if [ -n "$_sessionid" ]; then
|
||||||
loginctl terminate-session "$_sessionid"
|
loginctl terminate-session "$_sessionid"
|
||||||
@ -452,7 +482,7 @@ main() {
|
|||||||
while getopts ":dgh" opt; do
|
while getopts ":dgh" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
d)
|
d)
|
||||||
if ! [ "$_dryrun" = "1" ]; then
|
if [ -z "$_dryrun" ]; then
|
||||||
log "Performing a dry run"
|
log "Performing a dry run"
|
||||||
_dryrun=1
|
_dryrun=1
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user