Clean up README, add exit status table, add more error handling
This commit is contained in:
parent
4371075861
commit
510ffbdbeb
14
README.md
14
README.md
@ -28,7 +28,7 @@ By setting a dummy execution line, one can effectively prevent an entire configu
|
||||
command -v lemonbar
|
||||
~/.bin/lemonbar.sh | lemonbar
|
||||
|
||||
After all these programs have been started, the last thing firestarter does is execute `~/.firestarterrc`, if it exists.
|
||||
After all these programs have been started, firestarter executes `~/.firestarterrc` if it exists.
|
||||
|
||||
# Logging
|
||||
|
||||
@ -36,6 +36,18 @@ All STDOUT and STDERR messages from these commands are saved to a logfile in `~/
|
||||
|
||||
If you set the variable `FS_NOLOG` to a nonempty value, firestarter will not keep logs.
|
||||
|
||||
# Exit Codes
|
||||
|
||||
| code | meaning |
|
||||
| --: | --- |
|
||||
| 0 | Success |
|
||||
| 40 | Firestarter is already running |
|
||||
| 50 | Unrecognized argument |
|
||||
| 51 | Invalid option for an argument |
|
||||
| 52 | Failed to create configuration directory |
|
||||
| 53 | Failed to create logging directory (and logging is enabled) |
|
||||
| 54 | `HOME` does not exist or is unreadable |
|
||||
|
||||
## 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.
|
||||
|
15
firestarter
15
firestarter
@ -12,6 +12,7 @@ _name="firestarter"
|
||||
_configdir="${XDG_CONFIG_HOME:-$HOME/.config}/$_name"
|
||||
_logdir="${XDG_DATA_HOME:-$HOME/.local/share}/$_name/logs"
|
||||
_firestarterrc="$HOME/.firestarterrc"
|
||||
_sessionid="$(< /proc/self/sessionid)"
|
||||
|
||||
# Basic functions
|
||||
print() {
|
||||
@ -279,11 +280,18 @@ EOF
|
||||
step_check() {
|
||||
if [ -z "$_dryrun" ]; then
|
||||
for pid in $(pgrep firestarter); do
|
||||
# Skip invalid PIDs
|
||||
! [ -d "/proc/$pid" ] && continue
|
||||
# If it's not our session then who cares
|
||||
[ "$_sessionid" != "$(< "/proc/$pid/sessionid")" ] && continue
|
||||
if [ "$pid" != "$BASHPID" ]; then
|
||||
err "Firestarter is already running" 61
|
||||
err "Firestarter is already running" 40
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if ! [ -d "$HOME" ] || ! [ -r "$HOME" ]; then
|
||||
err "Inaccessible home directory: \"$HOME\"" 54
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
step_preexecute() {
|
||||
@ -422,9 +430,8 @@ step_logout() {
|
||||
log "Logging out"
|
||||
if command -v loginctl > /dev/null 2>&1; then
|
||||
# Use loginctl if possible
|
||||
local sessionid="$(< /proc/self/sessionid)"
|
||||
if [ -n "$sessionid" ]; then
|
||||
loginctl terminate-session "$sessionid"
|
||||
if [ -n "$_sessionid" ]; then
|
||||
loginctl terminate-session "$_sessionid"
|
||||
fi
|
||||
else
|
||||
# Otherwise just brute it
|
||||
|
Loading…
Reference in New Issue
Block a user