-
Notifications
You must be signed in to change notification settings - Fork 8
/
4-login.sh
135 lines (99 loc) · 3.44 KB
/
4-login.sh
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env sh
# /etc/zlogin and $HOME/.zlogin
# Read after zshrc, if the shell is a login shell.
# See also /etc/default/console-setup
######## This file cannot be written-to while the system is using it!
# NOTE # That means you cannot be in X.
########
# No need if booting is otherwise set up correctly:
# This is technically only usable by root, even though this works..
\setfont Uni2-VGA16.psf.gz
# This mess lets me use the console login screen as a GUI login manager.
# if [ -z "$DISPLAY" ] && [ $( \tty ) == /dev/tty1 ]; then
if [ "$TTY" = '/dev/tty1' ] ||
[ "$TTY" = '/dev/tty2' ] ||
[ "$TTY" = '/dev/pts1' ] ||
[ "$TTY" = '/dev/pts2' ]; then
#:<<'}' # Detect network connection
# FIXME? - This doesn't necessarily mean "internet connection"
{
for interface in /sys/class/net/*; do
\echo "Processing $interface"
if [ "$interface" = 'lo' ]; then
\echo 'skipping "lo" (localhost)'
\echo ' It is always there so it does not necessarily count as an outside connection.'
continue
fi
if ! _=$( \cat "$interface"/carrier ); then
\echo ' * Network connection not detected.'
else
\echo ' * Network connection detected.'
__="/tmp/$( $USER ).autostart-networking-applications"
\rm --force "$__"
if
# shellcheck disable=1117
\dialog --yesno "Network connection detected.\n\nAutostart related applications?" 0 0
then
# Make the file, the existence of which will prompt Openbox.
:> "$__"
fi
fi
done
\unset __
}
# This is a nice idea, but I think I need to chain zsh in the middle of things, unless I want to fuck around with the default shell.. perhaps `dtach` would work, but I don't know..
# echo $$ !> /tmp/zsh-launching-startx.ppid
# dtach -n /tmp/dtach.socket \startx &
# Find the TTY number
# e.g. /dev/tty2 => 2
string="$TTY"
# FIXME - make this use either format..
# I don't know why this works, even though $TTY is actually /dev/pts1
pattern='/dev/tty'
#pattern='/dev/pts'
tty_to_use=''
tty_to_use="${string##${pattern}}"
tty_to_use="${string##*${pattern}}"
#less /usr/bin/startx
# Earlier successes:
# Be really specific, so that we can setsid to exit entirely out of zsh or sh:
# As of Devuan 2.0.0 this works as root but not as a user:
# \setsid xinit /etc/X11/xinit/xinitrc -- /usr/bin/X :$( \expr "$tty_to_use" - 1 ) vt"$tty_to_use" -auth $( \tempfile --prefix='serverauth.' )
# Start X on that specific TTY
#\setsid \startx -- vt"$tty_to_use"
# xinit "$client" $clientargs -- "$server" $display $serverargs
# 2018-11-10 - Devuan 2.0.0
#
# This will open Openbox
#setsid \startx
#\logout
# 2018-12-28 - Devuan 2.0.0 before new computer
#
# This will open Openbox
#nohup setsid \startx > /dev/null
#\logout
# 2018-12-29 - Devuan 2.0.0 after new computer
#
# Launches X but doesn't switch to it:
#startx
# Launches X but doesn't switch to it:
#setsid \startx
# Launches X but doesn't switch to it:
#nohup setsid \startx > /dev/null
# 2020-03-26 success
# mktemp does not support --prefix
# shellcheck disable=2186
\xinit /etc/X11/xinit/xinitrc -- /usr/bin/X :$(( tty_to_use - 1 )) vt"$tty_to_use" -auth "$( \tempfile --prefix='serverauth.' )"
logout
:<<'}'
{
\xinit /etc/X11/xinit/xinitrc \
-- \
/usr/bin/X \
:$(( tty_to_use - 1 )) \
vt"$tty_to_use" &
\wait
# FIXME - This also logs out of every console:
\logout
}
fi # ttys 1,2