Improved terminal selection. Added support for xterm with Fenrir if desired.

This commit is contained in:
Storm Dragon
2026-05-07 14:25:05 -04:00
parent b34d7dc2e3
commit 14b0a27c2f
2 changed files with 49 additions and 38 deletions

64
i38.sh
View File

@@ -260,6 +260,17 @@ personal_mode_exists() {
[[ -f "$customizationsPath" ]] && grep -q 'mode "personal"' "$customizationsPath"
}
terminal_command() {
local terminalPath="$1"
local terminalName="${terminalPath##*/}"
if [[ "$terminalName" == "xterm" ]]; then
printf '%s -T "I38 terminal" -e "fenrir -x"' "$terminalPath"
else
printf '%s' "$terminalPath"
fi
}
load_config() {
# Load existing configuration if available
if [[ -f "$configFile" ]]; then
@@ -300,6 +311,7 @@ webBrowser="$webBrowser"
textEditor="$textEditor"
fileBrowser="$fileBrowser"
ircClient="$ircClient"
terminalEmulator="$terminalEmulator"
# Boolean settings (0=yes, 1=no)
udiskie="$udiskie"
@@ -312,7 +324,7 @@ sounds="$sounds"
screenlockPinHash="$screenlockPinHash"
# Personal mode
personalModeEnabled="${personalModeEnabled:-1}"
personalModeEnabled="${personalModeEnabled:-0}"
personalModeKey="$personalModeKey"
# WayTray configuration (0=use I38 config, 1=keep user config)
@@ -675,6 +687,31 @@ else
# Validate and export existing preference
export ircClient
fi
# Terminal emulator
if [[ -z "$terminalEmulator" ]] || { [[ ! -x "$terminalEmulator" ]] && ! command -v "$terminalEmulator" &> /dev/null; }; then
programList=()
for i in mate-terminal lxterminal gnome-terminal terminator xfce4-terminal tilix ptyxis kgx sakura roxterm termit guake tilda qterminal konsole ; do
if command -v "$i" &> /dev/null ; then
programList+=("$i")
fi
done
if command -v xterm &> /dev/null && command -v fenrir &> /dev/null ; then
programList+=("xterm")
fi
if [[ ${#programList[@]} -eq 0 ]]; then
dialog --title "I38" --msgbox "No supported terminal emulator was found. Please install mate-terminal, lxterminal, gnome-terminal, terminator, another supported accessible terminal, or install both xterm and fenrir." -1 -1
exit 1
elif [[ ${#programList[@]} -gt 1 ]]; then
terminalEmulator="$(menulist "Terminal emulator:" "${programList[@]}")"
else
terminalEmulator="${programList[0]}"
fi
terminalEmulator="$(command -v "$terminalEmulator")"
export terminalEmulator
else
# Validate and export existing preference
export terminalEmulator
fi
# Auto mount removable media
if [[ -z "$udiskie" ]]; then
udiskie=1
@@ -768,19 +805,14 @@ if personal_mode_exists; then
fi
if [[ $personalModeExists -ne 0 ]]; then
if yesno "Would you like a Personal mode?"; then
personalModeEnabled=0
else
personalModeEnabled=1
personalModeEnabled=0
if [[ -z "$personalModeKey" ]] || [[ "$personalModeKey" == "$escapeKey" ]]; then
personalModeKey="$(select_personal_mode_key)"
fi
if [[ "$personalModeEnabled" -eq 0 ]]; then
if [[ -z "$personalModeKey" ]] || [[ "$personalModeKey" == "$escapeKey" ]]; then
personalModeKey="$(select_personal_mode_key)"
fi
if [[ -z "$personalModeKey" ]]; then
personalModeEnabled=1
fi
if [[ -z "$personalModeKey" ]]; then
personalModeEnabled=1
fi
fi
@@ -789,6 +821,8 @@ if [[ $configLoaded -eq 0 ]]; then
save_config
fi
terminalExec="$(terminal_command "$terminalEmulator")"
if [[ -d "${i3Path}" ]]; then
yesno "This will replace your existing configuration at ${i3Path}. Do you want to continue?" || exit 0
fi
@@ -886,7 +920,7 @@ bindsym XF86AudioStop exec --no-startup-id play -qV0 "| sox -np synth 0.03 sin 2
bindsym XF86AudioNext exec --no-startup-id play -qV0 "| sox -np synth 0.03 sin 2000 pad 0 .02" "| sox -np synth 0.03 sin 2000" norm 1.0 vol 0.4 & ${i3Path}/scripts/music_controler.sh next
# start a terminal
bindsym \$mod+Return exec ${i3Path}/scripts/i3-sensible-terminal.sh
bindsym \$mod+Return exec $terminalExec
# kill focused window
bindsym \$mod+F4 kill
@@ -1073,7 +1107,7 @@ mode "ratpoison" {
# Ratpoison mode keybindings help bound to F1
bindsym F1 exec ${i3Path}/scripts/i38-help-rp.sh, mode "default"
# Terminal emulator bound to c
bindsym c exec ${i3Path}/scripts/i3-sensible-terminal.sh, mode "default"
bindsym c exec $terminalExec, mode "default"
# Text editor bound to e
bindsym e exec $textEditor, mode "default"
$(if [[ ${#fileBrowser} -gt 3 ]]; then
@@ -1329,7 +1363,7 @@ while IFS= read -r line; do
elif [[ "$keybinding" =~ move.*container.*workspace ]] && [[ "$keybinding" =~ Control+Shift+F ]]; then
# Move to workspace
workspaceMove+=("$keyCombo|$lastComment")
elif [[ "$lastComment" =~ (menu|terminal|editor|browser|Run dialog) ]] || [[ "$keybinding" =~ (menu.py|sensible-terminal|run_dialog) ]]; then
elif [[ "$lastComment" =~ (menu|terminal|editor|browser|Run dialog) ]] || [[ "$keybinding" =~ (menu.py|run_dialog) ]]; then
applications+=("$keyCombo|$lastComment")
elif [[ "$lastComment" =~ (focus|window|fullscreen|scratchpad|kill|close) ]] || [[ "$keybinding" =~ (focus|kill|fullscreen|scratchpad) ]]; then
windowMgmt+=("$keyCombo|$lastComment")

View File

@@ -1,23 +0,0 @@
#!/bin/sh
#
# This code is released in public domain by Han Boetes <han@mijncomputer.nl>
#
# This script tries to exec a terminal emulator by trying some known terminal
# emulators.
#
# We welcome patches that add distribution-specific mechanisms to find the
# preferred terminal emulator. On Debian, there is the x-terminal-emulator
# symlink for example.
#
# Invariants:
# 1. $TERMINAL must come first
# 2. Distribution-specific mechanisms come next, e.g. x-terminal-emulator
# 3. The terminal emulator with best accessibility comes first.
# 4. No order is guaranteed/desired for the remaining terminal emulators.
for terminal in "$TERMINAL" x-terminal-emulator mate-terminal gnome-terminal terminator xfce4-terminal urxvt rxvt termit Eterm aterm uxterm xterm roxterm termite lxterminal terminology st qterminal lilyterm tilix terminix konsole kitty guake tilda alacritty hyper wezterm; do
if command -v "$terminal" > /dev/null 2>&1; then
exec "$terminal" "$@"
fi
done
i3-nagbar -m 'i3-sensible-terminal could not find a terminal emulator. Please install one.'