-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto
30 lines (27 loc) · 903 Bytes
/
auto
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
if shellm-ndef; then
shellm-define "auto_ui"
## \brief Provides auto_ui function
## \desc The auto_ui function takes two arguments, the first one is the
## command to be executed if in a command-line environment
## (like xterm, linux, screen), and the second one is the command to
## be executed in a graphical environment (assumed if not command-line).
##
## This function finds its usefulness when writing a script that has to
## be runable on both command-line and graphical environment, without
## separating the code in two parts.
## \brief Executes one of two commands depending on the environment
## (graphical or command-line like).
## \param $1 Command-line command
## \param $2 Graphical command
## \return Return code of the executed command
auto_ui() {
case $TERM in
xterm*|rxvt*|linux*|screen*)
eval "$1"
return $? ;;
*)
eval "$2"
return $? ;;
esac
}
fi # __UI_AUTO_SH