X-Git-Url: https://git.madduck.net/etc/xsession.git/blobdiff_plain/bc72e3f510c2666c84bd33fc0342313c2ec81aed..128901571e697864e8d8a504b87856c13688d5e2:/.bin/x-terminal-emulator 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 "$@"