Files
coredesktop/system/run-in-terminal
T
david 6770150b11
shellcheck / shellcheck (push) Successful in 11s
fix the fail2ban issues and other things
2026-10-31 08:10:05 -06:00

28 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
#
# Purpose : Run a command in a new terminal window, for notifications that
# start something when clicked (system/update-check, system/email-watch).
#
# run-in-terminal <command>, e.g. run-in-terminal update
#
# bash -i reads ~/.bashrc, as if the user had typed the command themselves, and
# the window stays open to show how it went.
run=(bash -ic "$1; echo; read -rp \"Press Enter to close this window.\"")
if command -v xdg-terminal-exec &> /dev/null; then
terminal=(xdg-terminal-exec)
elif command -v kgx &> /dev/null; then
terminal=(kgx --)
elif command -v ghostty &> /dev/null; then
terminal=(ghostty -e)
elif command -v kitty &> /dev/null; then
terminal=(kitty)
else
notify-send --app-name=CoreDesktop "No terminal found" "Open a terminal and run $1."
exit 1
fi
# Run the terminal as its own unit: when the service that called this exits,
# systemd stops everything still running in it, which would close the terminal
exec systemd-run --user --quiet --collect -- "${terminal[@]}" "${run[@]}"