Run every terminal launch through one dispatcher with fallbacks
This commit is contained in:
@@ -10,4 +10,4 @@ source blob-restart-gum
|
||||
cmd="$*"
|
||||
presentation_script="blob-show-logo; $cmd; if (( \$? != 130 )); then blob-show-done; fi"
|
||||
|
||||
exec setsid uwsm-app -- xdg-terminal-exec --app-id=org.blob.terminal --title=Blob -e bash -c "$presentation_script"
|
||||
exec setsid uwsm-app -- blob-terminal-exec --app-id=org.blob.terminal --title=Blob -e bash -c "$presentation_script"
|
||||
|
||||
@@ -16,7 +16,7 @@ if blob-toggle-enabled screensaver-off && [[ $1 != "force" ]]; then
|
||||
fi
|
||||
|
||||
focused=$(blob-hypr-monitor-focused)
|
||||
terminal=$(xdg-terminal-exec --print-id)
|
||||
terminal=$(blob-terminal-exec --print-id)
|
||||
|
||||
case $terminal in
|
||||
*Alacritty* | *ghostty* | *foot* | *kitty*) ;;
|
||||
|
||||
@@ -3,13 +3,4 @@
|
||||
# blob:summary=Launch the default terminal
|
||||
# blob:args=[command [args...]]
|
||||
|
||||
if blob-cmd-present xdg-terminal-exec; then
|
||||
exec setsid uwsm-app -- xdg-terminal-exec "$@"
|
||||
fi
|
||||
|
||||
for terminal in foot kitty; do
|
||||
blob-cmd-present "$terminal" && exec setsid uwsm-app -- "$terminal" "$@"
|
||||
done
|
||||
|
||||
blob-notify-send "No terminal installed" "Install xdg-terminal-exec, foot or kitty."
|
||||
exit 1
|
||||
exec setsid uwsm-app -- blob-terminal-exec "$@"
|
||||
|
||||
+1
-1
@@ -10,4 +10,4 @@ else
|
||||
APP_ID="org.blob.$(basename $1)"
|
||||
fi
|
||||
|
||||
exec setsid uwsm-app -- xdg-terminal-exec --app-id=$APP_ID -e "$1" "${@:2}"
|
||||
exec setsid uwsm-app -- blob-terminal-exec --app-id=$APP_ID -e "$1" "${@:2}"
|
||||
|
||||
@@ -67,7 +67,7 @@ desktop_name="${desktop_file##*/}"
|
||||
desktop_name="${desktop_name%.desktop}"
|
||||
exec_line="$(sed -n 's/^Exec=//p' "$desktop_file" | head -1)"
|
||||
|
||||
if [[ $exec_line =~ (^|[[:space:]])(\$TERMINAL|xdg-terminal-exec)[[:space:]].*-e([[:space:]]|$) ]]; then
|
||||
if [[ $exec_line =~ (^|[[:space:]])(\$TERMINAL|xdg-terminal-exec|blob-terminal-exec)[[:space:]].*-e([[:space:]]|$) ]]; then
|
||||
BLOB_REMOVE_NOTIFY=false blob-tui-remove "$desktop_name"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
Executable
+67
@@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
|
||||
# blob:summary=Run a command in the default terminal
|
||||
# blob:args=[--print-id] [--app-id=<app-id>] [--title=<title>] [-e] <command> [args...]
|
||||
# blob:hidden=true
|
||||
|
||||
terminal=""
|
||||
for candidate in xdg-terminal-exec foot kitty; do
|
||||
if command -v "$candidate" &>/dev/null; then
|
||||
terminal=$candidate
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z $terminal ]]; then
|
||||
blob-notify-send "No terminal installed" "Install xdg-terminal-exec, foot or kitty."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $terminal == "xdg-terminal-exec" ]]; then
|
||||
exec xdg-terminal-exec "$@"
|
||||
fi
|
||||
|
||||
app_id=""
|
||||
title=""
|
||||
command_args=()
|
||||
|
||||
while (( $# > 0 )); do
|
||||
case "$1" in
|
||||
--print-id)
|
||||
printf '%s\n' "$terminal"
|
||||
exit 0
|
||||
;;
|
||||
--app-id=*)
|
||||
app_id=${1#--app-id=}
|
||||
shift
|
||||
;;
|
||||
--title=*)
|
||||
title=${1#--title=}
|
||||
shift
|
||||
;;
|
||||
-e)
|
||||
shift
|
||||
command_args+=("$@")
|
||||
break
|
||||
;;
|
||||
*)
|
||||
command_args+=("$1")
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
launch=("$terminal")
|
||||
|
||||
case "$terminal" in
|
||||
foot)
|
||||
[[ -n $app_id ]] && launch+=("--app-id=$app_id")
|
||||
;;
|
||||
kitty)
|
||||
[[ -n $app_id ]] && launch+=("--class=$app_id")
|
||||
;;
|
||||
esac
|
||||
|
||||
[[ -n $title ]] && launch+=("--title=$title")
|
||||
|
||||
exec "${launch[@]}" "${command_args[@]}"
|
||||
@@ -84,7 +84,7 @@ cat >"$DESKTOP_FILE" <<EOF
|
||||
Version=1.0
|
||||
Name=$APP_NAME
|
||||
Comment=$APP_NAME
|
||||
Exec=xdg-terminal-exec --app-id=$APP_CLASS -e $APP_EXEC
|
||||
Exec=blob-terminal-exec --app-id=$APP_CLASS -e $APP_EXEC
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Icon=$ICON_VALUE
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ DESKTOP_DIR="$HOME/.local/share/applications/"
|
||||
if (( $# == 0 )); then
|
||||
# Find all TUIs
|
||||
while IFS= read -r -d '' file; do
|
||||
if grep -qE '^Exec=.*(\$TERMINAL|xdg-terminal-exec).*-e' "$file"; then
|
||||
if grep -qE '^Exec=.*(\$TERMINAL|xdg-terminal-exec|blob-terminal-exec).*-e' "$file"; then
|
||||
TUIS+=("$(basename "${file%.desktop}")")
|
||||
fi
|
||||
done < <(find "$DESKTOP_DIR" -name '*.desktop' -print0)
|
||||
|
||||
@@ -12,7 +12,7 @@ echo "Scanning for TUIs in $APP_DIR..."
|
||||
|
||||
tui_desktop_files=()
|
||||
while IFS= read -r -d '' file; do
|
||||
if grep -q "Exec=xdg-terminal-exec --app-id=TUI\." "$file" 2>/dev/null; then
|
||||
if grep -qE "Exec=(xdg|blob)-terminal-exec --app-id=TUI\." "$file" 2>/dev/null; then
|
||||
tui_desktop_files+=("$file")
|
||||
fi
|
||||
done < <(find "$APP_DIR" -maxdepth 1 -name "*.desktop" -print0 2>/dev/null)
|
||||
|
||||
Reference in New Issue
Block a user