mirror of
https://github.com/Snigdha-OS/snigdhaos-system-config.git
synced 2025-09-21 12:04:57 +02:00
🐞 fix(_127): error code 127
This commit is contained in:
@@ -61,20 +61,20 @@ echo "$1" >> "$codefile"
|
|||||||
chmod +x "$initfile"
|
chmod +x "$initfile"
|
||||||
|
|
||||||
# Command to run in the terminal emulator
|
# Command to run in the terminal emulator
|
||||||
cmd="\"$initfile\""
|
cmd="$initfile"
|
||||||
|
|
||||||
# Define a dictionary of supported terminal emulators
|
# Define a dictionary of supported terminal emulators
|
||||||
declare -A terminals=(
|
declare -A terminals=(
|
||||||
["alacritty"]="alacritty -e $cmd || LIBGL_ALWAYS_SOFTWARE=1 alacritty -e $cmd"
|
["alacritty"]="alacritty -e bash -c \"$cmd\" || LIBGL_ALWAYS_SOFTWARE=1 alacritty -e bash -c \"$cmd\""
|
||||||
["konsole"]="konsole -e $cmd"
|
["konsole"]="konsole --noclose -e bash -c \"$cmd\""
|
||||||
["kgx"]="kgx -- $cmd"
|
["kgx"]="kgx -- bash -c \"$cmd\""
|
||||||
["gnome-terminal"]="gnome-terminal --wait -- $cmd"
|
["gnome-terminal"]="gnome-terminal --wait -- bash -c \"$cmd\""
|
||||||
["xfce4-terminal"]="xfce4-terminal --disable-server --command '$cmd'"
|
["xfce4-terminal"]="xfce4-terminal --disable-server --command bash -c \"$cmd\""
|
||||||
["qterminal"]="qterminal -e $cmd"
|
["qterminal"]="qterminal -e bash -c \"$cmd\""
|
||||||
["lxterminal"]="lxterminal -e $cmd"
|
["lxterminal"]="lxterminal -e bash -c \"$cmd\""
|
||||||
["mate-terminal"]="mate-terminal --disable-factory -e $cmd"
|
["mate-terminal"]="mate-terminal --disable-factory -e bash -c \"$cmd\""
|
||||||
["xterm"]="xterm -e $cmd"
|
["xterm"]="xterm -e bash -c \"$cmd\""
|
||||||
["foot"]="foot -T launch-terminal -e $cmd"
|
["foot"]="foot -T launch-terminal -e bash -c \"$cmd\""
|
||||||
)
|
)
|
||||||
|
|
||||||
# Define an ordered list of terminals to try
|
# Define an ordered list of terminals to try
|
||||||
@@ -84,6 +84,7 @@ declare -a term_order=(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Select the terminal based on the desktop environment
|
# Select the terminal based on the desktop environment
|
||||||
|
terminal=""
|
||||||
case "$XDG_CURRENT_DESKTOP" in
|
case "$XDG_CURRENT_DESKTOP" in
|
||||||
KDE) terminal="konsole" ;;
|
KDE) terminal="konsole" ;;
|
||||||
GNOME)
|
GNOME)
|
||||||
@@ -108,11 +109,15 @@ esac
|
|||||||
|
|
||||||
# If no terminal emulator is found, notify and exit
|
# If no terminal emulator is found, notify and exit
|
||||||
if [ -z "$terminal" ]; then
|
if [ -z "$terminal" ]; then
|
||||||
notify-send -t 15000 --app-name=Snigdha\ OS "No terminal installed" \
|
notify-send -t 15000 --app-name="Snigdha OS" "No terminal installed" \
|
||||||
"No supported terminal emulator is installed. Please install a terminal emulator like Alacritty."
|
"No supported terminal emulator is installed. Please install a terminal emulator like Alacritty."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Debugging information
|
||||||
|
echo "Selected terminal: $terminal"
|
||||||
|
echo "Command to execute: ${terminals[$terminal]}"
|
||||||
|
|
||||||
# Special handling for kgx to ensure proper behavior
|
# Special handling for kgx to ensure proper behavior
|
||||||
if [ "$terminal" = "kgx" ]; then
|
if [ "$terminal" = "kgx" ]; then
|
||||||
sed -i '2i sleep 0.1' "$initfile"
|
sed -i '2i sleep 0.1' "$initfile"
|
||||||
@@ -120,6 +125,7 @@ if [ "$terminal" = "kgx" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Run the terminal emulator with the command
|
# Run the terminal emulator with the command
|
||||||
|
exitcode=0
|
||||||
eval "${terminals[$terminal]}" || exitcode=$?
|
eval "${terminals[$terminal]}" || exitcode=$?
|
||||||
|
|
||||||
# Clean up temporary files
|
# Clean up temporary files
|
||||||
@@ -128,8 +134,10 @@ if [ "$codefile" != "$initfile" ]; then
|
|||||||
rm "$codefile"
|
rm "$codefile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Exit gracefully if no terminal error occurred, otherwise propagate the error
|
# Exit handling
|
||||||
if [ -n "${exitcode-}" ] && [ "$exitcode" != 130 ]; then
|
if [ "$exitcode" -eq 0 ]; then
|
||||||
|
echo "Terminal executed the command successfully."
|
||||||
|
elif [ "$exitcode" -ne 130 ]; then
|
||||||
echo "Error: Terminal launch failed with exit code $exitcode"
|
echo "Error: Terminal launch failed with exit code $exitcode"
|
||||||
exit 2
|
exit "$exitcode"
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user