]> git.madduck.net Git - etc/xsession.git/blob - .bin/x-terminal-emulator

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

e72642e0073ddabacf984eaa1dda2f9637890792
[etc/xsession.git] / .bin / x-terminal-emulator
1 #!/bin/sh
2 set -eu
3
4 real_xterm() {
5   local OLDIFS
6   OLDIFS="$IFS"
7   IFS=:
8   local SELF
9   SELF="$(realpath $0)"
10   local CMD
11   CMD="${SELF##*/}"
12   for p in $PATH; do
13     IFS="$OLDIFS"
14     case "$SELF" in $p/*) continue ;; esac
15     if [ -x "$p/$CMD" ]; then
16       echo "$p/$CMD"
17       return 0
18     fi
19   done
20   return 127
21 }
22
23 xterm=$(real_xterm)
24
25 kitty_args() {
26   # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1103770
27   local arg rest=0
28   local args="--single-instance --wait-for-single-instance-window-close"
29   for arg in "$@"; do
30     if [ $rest = 0 ]; then
31       case "$arg" in
32       -help | --help)
33         echo $arg
34         break
35         ;;
36       -name | -hold | -title) arg="-$arg" ;;
37       -cd) arg="-d" ;;
38       -e | --) rest=1 ;;
39       esac
40     fi
41     args="$args $arg"
42   done
43   echo $args
44 }
45
46 case "$(readlink -f $xterm)" in
47 */kitty) set -- $(kitty_args "$@") ;;
48 esac
49
50 exec $xterm "$@"