diff --git a/firestarter b/firestarter index fccea9a..094a72f 100755 --- a/firestarter +++ b/firestarter @@ -55,6 +55,22 @@ startfile() { fi } +# Traps +trap_exit() { + 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" + fi + else + # Otherwise just brute it + kill $(jobs -p) + fi + return 0 +} +trap trap_exit EXIT + # Steps in execution step_generate() { log "Creating default config setup in \"$g_configdir\"" @@ -227,7 +243,7 @@ EOF } step_printhelp() { cat << EOF -Usage: $0 [OPTION...] +Usage: $(basename -- "$0") [OPTION...] Start or generate a desktop environment configuration -h Show this help text