From: martin f. krafft Date: Wed, 23 Apr 2025 13:53:26 +0000 (+0200) Subject: add x-terminal-emulator wrapper to handle new xterms X-Git-Url: https://git.madduck.net/etc/xsession.git/commitdiff_plain/128901571e697864e8d8a504b87856c13688d5e2 add x-terminal-emulator wrapper to handle new xterms --- diff --git a/.bin/x-terminal-emulator b/.bin/x-terminal-emulator new file mode 100755 index 0000000..e72642e --- /dev/null +++ b/.bin/x-terminal-emulator @@ -0,0 +1,50 @@ +#!/bin/sh +set -eu + +real_xterm() { + local OLDIFS + OLDIFS="$IFS" + IFS=: + local SELF + SELF="$(realpath $0)" + local CMD + CMD="${SELF##*/}" + for p in $PATH; do + IFS="$OLDIFS" + case "$SELF" in $p/*) continue ;; esac + if [ -x "$p/$CMD" ]; then + echo "$p/$CMD" + return 0 + fi + done + return 127 +} + +xterm=$(real_xterm) + +kitty_args() { + # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1103770 + local arg rest=0 + local args="--single-instance --wait-for-single-instance-window-close" + for arg in "$@"; do + if [ $rest = 0 ]; then + case "$arg" in + -help | --help) + echo $arg + break + ;; + -name | -hold | -title) arg="-$arg" ;; + -cd) arg="-d" ;; + -e | --) rest=1 ;; + esac + fi + args="$args $arg" + done + echo $args +} + +case "$(readlink -f $xterm)" in +*/kitty) set -- $(kitty_args "$@") ;; +esac + +exec $xterm "$@" diff --git a/.gitignore.d/xsession b/.gitignore.d/xsession index 36fe0fe..4fc63b7 100644 --- a/.gitignore.d/xsession +++ b/.gitignore.d/xsession @@ -1,5 +1,6 @@ * !/.bin/xconfig +!/.bin/x-terminal-emulator !/.config/autorandr/.gitignore !/.config/autorandr/postswitch !/.config/vcsh/hooks-available/xsession.update