aboutsummaryrefslogtreecommitdiff
path: root/terminal
blob: 5fbdefc84c8a609b750b413651075486ff2a02f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
#
# Terminal emulator wrapper
#

# Load geometry configuration
source ~/.geometry || exit 1

# Set default dimensions
if [ ! -z "$GEOMETRY" ]; then
  DIMENSIONS="-g $GEOMETRY"
fi

# Set title
if [ -z "$TITLE" ]; then
  if [ ! -z "$1" ]; then
    TITLE="$1"
  else
    TITLE="terminal"
  fi
fi

# Set default font
if [ ! -z "$FONT" ]; then
  F_FONT="-F $FONT"
  FN_FONT="-fn $FONT"
  f_FONT="-f $FONT"
fi

# Set shell
#
# Always use interactive mode (--login or -i) to avoid weird behavior like
# one found with vim and NERDTree.
#
#SH="bash --login -i -rcfile $HOME/.terminal"
SH="zsh -i"

# Set a custom zsh config folder if commands are specified, to speed up startup
# Drawback is that any shell spawn from the command won't have any customization.
#if [ ! -z "$1" ]; then
#  mkdir -p ~/.custom/terminal
#  export ZDOTDIR="~/.custom/terminal"
#fi

# Dispatch
if [ "$TERM" == "stterm" ]; then
  if [ ! -z "$1" ]; then
    # Vanilla st
    #stterm $f_FONT -T $TITLE -e $SH -c "$*"

    # Patched st from https://github.com/LukeSmithxyz/st with .Xresources support
    stterm -T $TITLE -e $SH -c "$*"
  else
    # Vanilla st
    #stterm $f_FONT -T $TITLE -e $SH

    # Patched st from https://github.com/LukeSmithxyz/st with .Xresources support
    stterm -T $TITLE -e $SH
  fi
elif [ "$TERM" == "rxvt" ]; then
  if [ ! -z "$1" ]; then
    # Background color should be set at ~/.Xresources
    #rxvt-unicode -bg black +sb -fg white $FN_FONT $DIMENSIONS -title $TITLE \
    rxvt-unicode +sb -fg white $FN_FONT $DIMENSIONS -title $TITLE -e $SH -c "$*"
  else
    # Background color should be set at ~/.Xresources
    #rxvt-unicode -bg black +sb -fg white $FN_FONT $DIMENSIONS -title $TITLE \
    rxvt-unicode +sb -fg white $FN_FONT $DIMENSIONS -title $TITLE -e $SH
  fi
elif [ "$TERM" == "Eterm" ]; then
  if [ ! -z "$1" ]; then
    Eterm  --background-pixmap 0 --scrollbar 0 +sb -b black -f white $F_FONT --borderless no \
           --buttonbar 0 $DIMENSIONS -n$TITLE -e $SH -c "$*"
  else
    Eterm  --background-pixmap 0 --scrollbar 0 +sb -b black -f white $F_FONT --borderless no \
           --buttonbar 0 $DIMENSIONS -n$TITLE -e $SH
  fi
elif [ "$TERM" == "xterm" ]; then
  if [ ! -z "$1" ]; then
    xterm -u8 $FN_FONT -geometry $GEOMETRY -title $TITLE -e $SH "$*"
  else
    xterm -u8 $FN_FONT -geometry $GEOMETRY -title $TITLE -e $SH
  fi
elif [ "$TERM" == "alacritty" ]; then
  # Run alacritty with LIBGL_ALWAYS_SOFTWARE to avoid glitches during startup
  # or when switching windows and workspaces.
  #
  # Problem description:
  # https://forum.endeavouros.com/t/weird-glitches-when-switching-workspaces-and-launching-windows/32862
  # https://github.com/alacritty/alacritty/issues/6680
  #
  # Solution, sincel alacritty uses OpenGL:
  # https://docs.mesa3d.org/envvars.html#envvar-LIBGL_ALWAYS_SOFTWARE
  # https://superuser.com/questions/106056/force-software-based-opengl-rendering-on-ubuntu
  #
  if [ ! -z "$1" ]; then
    LIBGL_ALWAYS_SOFTWARE=1 alacritty -e $SH -c "$*"
  else
    LIBGL_ALWAYS_SOFTWARE=1 alacritty
  fi
fi