aboutsummaryrefslogtreecommitdiffstats
path: root/gotrc-examples/commands
blob: 660588458ed727333698b320db9bec53d3361592 (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
# -*- shell-script -*-

# gates-of-tartaros – Minimal replacement for agetty with SSH support
# 
# Copyright © 2013, 2014, 2015  Mattias Andrée (m@maandree.se)
# 
# 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 test -n "${user}" && test -z "${user%%+*}"; then
		if test "${user}" = "+shutdown"; then
			shutdown -h now
		elif test "${user}" = "+reboot"; then
			reboot
		elif test "${user}" = "+time"; then
			printf '\n'
			date +'%Y-(%m)%b-%d %T, %a w%W/%V, %Z'
			read __
		elif test "${user}" = "+battery"; then
			printf '\n'
			acpi -V
			read __
		elif test "${user}" = "+backlight"; then
			if test "${LANG%UTF-8*}" = "${LANG}"; then
				export LANG="en_GB.UTF-8"
			fi
			adjbacklight
		elif test "${user}" = "+keyboard"; then
			printf 'Enter keyboard layout: (e.g. sv-latin1)\n'
			read -r layout
			if test -n "${layout}"; then
				loadkeys -C "/dev/${tty}" -- ${layout}
				if test ! $? = 0; then
					printf 'Press ENTER to continue...\n'
					read
				fi
			fi
		elif test "${user}" = "+1"; then
			printf 'Enter parameters: (e.g. tty7 TERM=linux)\n'
			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
}