aboutsummaryrefslogtreecommitdiffstats
path: root/bin/xvt
blob: ad1ca1bc4036b8e7a5eb7658b6ca1ad898968e86 (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
#!/bin/sh
#---------------------------------------------------------------
# Project         : MandrivaLinux
# Module          : bin
# File            : xvt
# Version         : $Id: xvt 266850 2010-03-15 16:54:17Z fcrozat $
# Author          : Frederic Lepied
# Created On      : Tue Aug 31 16:26:54 2004
# Purpose         : launch a terminal emulator
#---------------------------------------------------------------

# allowed parameters, that must be handled by all terminals:
#   -geometry <geometry>
#   -T <title>
#   -e <program>

strip_terminal_var() {
if [[ -n "$TERMINAL" ]]; then
  if [[ `basename "$TERMINAL"` == "xvt" ]]; then
    unset TERMINAL
  fi
fi
}

strip_terminal_var
if [[ -z "$TERMINAL" ]]; then
 
    # using GNOME
    if [[ -n "$GNOME_DESKTOP_SESSION_ID" ]]; then
	TERMINAL=`gconftool -g /desktop/gnome/applications/terminal/exec`
    fi

    #using KDE
    if [[ -n "$KDE_FULL_SESSION" ]]; then
	TERMINAL=`kreadconfig --file kdeglobals --group General --key TerminalApplication --default "konsole"`
    fi

    if [[ -n "$_LXSESSION_PID" ]]; then
    	[[ -z "$TERMINAL" ]] && TERMINAL=`which lxterminal 2> /dev/null`
    fi

    #using Xfce
    if [[  x"$XDG_CURRENT_DESKTOP" = x"XFCE" ]]; then
        [[ -z "$TERMINAL" ]] && TERMINAL=`sed -n -e 's,^TerminalEmulator=\(.*\),\1,p' $HOME/.config/xfce4/helpers.rc 2> /dev/null`
    fi

   strip_terminal_var 
   
    [[ -z "$TERMINAL" ]] && TERMINAL=`which aterm 2> /dev/null`
    [[ -z "$TERMINAL" ]] && TERMINAL=`which Eterm 2> /dev/null`
    [[ -z "$TERMINAL" ]] && TERMINAL=`which gnome-terminal 2> /dev/null`
    [[ -z "$TERMINAL" ]] && TERMINAL=`which konsole 2> /dev/null`
    [[ -z "$TERMINAL" ]] && TERMINAL=`which kterm 2> /dev/null`
    [[ -z "$TERMINAL" ]] && TERMINAL=`which lxterminal 2> /dev/null`
    [[ -z "$TERMINAL" ]] && TERMINAL=`which multi-gnome-terminal 2> /dev/null`
    [[ -z "$TERMINAL" ]] && TERMINAL=`which multixterm 2> /dev/null`
    [[ -z "$TERMINAL" ]] && TERMINAL=`which rxvt 2> /dev/null`
    [[ -z "$TERMINAL" ]] && TERMINAL=`which terminal 2> /dev/null`
    [[ -z "$TERMINAL" ]] && TERMINAL=`which terminator 2> /dev/null`
    [[ -z "$TERMINAL" ]] && TERMINAL=`which xfce4-terminal 2> /dev/null`
    [[ -z "$TERMINAL" ]] && TERMINAL=`which xterm 2> /dev/null`

fi

if [[ -n "$TERMINAL" ]]; then 
  # keep the same behaviour between all terminals
  if [[ "`basename ${TERMINAL%% *}`" = "konsole" ]]; then
    TERMINAL="$TERMINAL --nofork"
  fi

  exec $TERMINAL "$@"
else
  echo "no terminal emulator detected"
fi

# xvt ends here