aboutsummaryrefslogtreecommitdiffstats
path: root/gotrc-examples/commands
blob: 0d57ecad226fd211af75be4e2db51de013c3a36b (plain) (blame)
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
# -*- shell-script -*-

# gates-of-tartaros – Minimal replacement for agetty with SSH support
# 
# Copyright © 2013, 2014, 2015  Mattias Andrée (maandree@member.fsf.org)
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


# The module allows you to launch a few programs without even logging in


login_function_commands=$login_function
login_function=_login_commands

_login_commands ()
{
    if [ ! "${user}" = "" ] && [ "${user%%+*}" = "" ]; then
	if [ "${user}" = "+shutdown" ]; then
	    shutdown -h now
	elif [ "${user}" = "+reboot" ]; then
	    reboot
	elif [ "${user}" = "+time" ]; then
	    echo
	    date +%Y-\(%m\)%b-%d\ %T,\ %a\ w%W/%V,\ %Z
	    read __
	elif [ "${user}" = "+battery" ]; then
	    echo
	    acpi -V
	    read __
	elif [ "${user}" = "+backlight" ]; then
	    if [ "${LANG%UTF-8*}" = "${LANG}" ]; then
		export LANG="en_GB.UTF-8"
	    fi
	    adjbacklight
	elif [ "${user}" = "+keyboard" ]; then
	    echo "Enter keyboard layout: (e.g. sv-latin1)"
	    read -r layout
	    if [ ! "$(echo ${layout})" = "" ]; then
	       loadkeys -C "/dev/${tty}" -- ${layout}
	       if [ ! $? = 0 ]; then
		   echo 'Press ENTER to continue...'
		   read
	       fi
	    fi
	elif [ "${user}" = "+1" ]; then
	    echo "Enter parameters: (e.g. tty7 TERM=linux)"
	    read -r params
	    setsid -- "$0" $params &
	else
	    cat <<EOF
Command is not recognised.
Recognised commands include:

+shutdown     Shutdown the computer
+reboot       Reboot the computer
+backlight    Adjust the backlight
+time         Print the current date and time
+battery      Print information relevant for your battery status
+keyboard     Select keyboard layout for the TTY (This may effect all TTY:s)
+1            Open a new gates-of-tartaros in another TTY
EOF
	    read __
	fi
    else
	$login_function_commands
    fi
}