Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 208 lines (164 sloc) 4.786 kB
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
1 # Keep the browser running and clean between sessions in /home/webc
2 # hendry@webconverger.com
b6b2ef0 @matthijskooijman Move functions from webc.conf to the (new) functions.sh
matthijskooijman authored
3 . "/etc/webc/functions.sh"
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
4 . "/etc/webc/webc.conf"
5
c5d8fb1 @kaihendry Fixes #93
kaihendry authored
6 if test -f /etc/X11/Xresources/x11-common
7 then
8 xrdb -merge /etc/X11/Xresources/x11-common
9 else
10 logs x11 config not found
11 fi
12
a9d0ecd @kaihendry Add Neon WM to make it show version/id on top bar
kaihendry authored
13 wm="/usr/bin/dwm.web" # default
14
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
15 if test "$(cmdline_get chrome)" = neon
16 then
686cc2c @kaihendry Hide neon id bar behind option "neonshowid"
kaihendry authored
17 cmdline_has neonshowid && wm="/usr/bin/dwm.neon" # special version to show version/id info on top bar
ada0d0a @kaihendry Added support for neon's blackbg theme
kaihendry authored
18 neon="-neon"
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
19 update_background() { xloadimage -border black -quiet -onroot -center "$1"; }
20 xsetroot -solid black
21 else
22 update_background() { xloadimage -quiet -onroot -center "$1"; }
23 xsetroot -solid white
24 fi
25
ada0d0a @kaihendry Added support for neon's blackbg theme
kaihendry authored
26 cp /home/webc/bg-orig${neon}.png /home/webc/bg.png
27
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
28 if ! has_network
29 then
ada0d0a @kaihendry Added support for neon's blackbg theme
kaihendry authored
30 update_background /etc/webc/no-net${neon}.png
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
31 while ! has_network && ! cmdline_has debug; do
32 sleep 1
33 done
34 fi
35
ada0d0a @kaihendry Added support for neon's blackbg theme
kaihendry authored
36 cmdline_has noconfig || update_background /etc/webc/configuring${neon}.png
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
37
38 # if there is a network, then I don't see why /etc/webc/id should not be there
39 while ! test -e /etc/webc/id; do
40 sleep 0.25
41 test $SECONDS -gt 30 && break
42 done
43
44 # get the $webc_id
45 . "/etc/webc/webc.conf"
46 homepage="$install_qa_url" # default homepage
47
48 mkfifo "$live_config_pipe"
49 read answer < "$live_config_pipe" # blocking till live-config is finished
50 rm -f "$live_config_pipe"
51
52 xset s on
53 xset s blank
54 xset s 600
55 xset +dpms
56
57 for x in $(cmdline)
58 do
59 case $x in
60
61 kioskresetstation=*) # For killing the browser after a number of minutes of idleness
62 exec /usr/bin/kioskresetstation ${x#kioskresetstation=} &
63 ;;
64
65 debug)
66 wm="/usr/bin/dwm.default" # dwm.default is the dwm default, not webc
67 ;;
68
69 xkb=*)
70 koptions=$( /bin/busybox httpd -d ${x#xkb=} )
71 if setxkbmap $koptions; then logs "setxkbmap OK $koptions"; else logs "setxkbmap ERR $koptions"; fi
72 ;;
73
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
74 # swarp=0,0 // move mouse pointer to top left of screen
75 swarp=*)
40d2a2f @PaulGrzeszczak Update home/webc/webc.sh
PaulGrzeszczak authored
76 koptions=$( /bin/busybox httpd -d ${x#swarp=} )
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
77 swarp $(echo $koptions | sed 's/[^0-9]/ /g')
78 ;;
79
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
80 # http://webconverger.org/touch_screen_calibration/
81 xinput=*)
fd2d664 @kaihendry xinput= API, closes #79
kaihendry authored
82 option=$( /bin/busybox httpd -d ${x#xinput=} )
4398b8b @kaihendry Fixes #110 to allow complex arguments to xinput to get executed
kaihendry authored
83 if eval xinput "$option"
fd2d664 @kaihendry xinput= API, closes #79
kaihendry authored
84 then
85 logs "OK: xinput $option"
86 else
87 logs "ERROR: xinput $option"
88 fi
89 ;;
90
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
91 # https://groups.google.com/forum/#!msg/webc-users/GlHh_SX17BM/GojceXVSazgJ
92 xrandr-all=*)
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
93 xoptions=$( /bin/busybox httpd -d ${x#xrandr-all=} )
94
fd2d664 @kaihendry xinput= API, closes #79
kaihendry authored
95 logs "xrandr-all: $xoptions"
96
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
97 xrandr | awk '$2 ~ /^connected$/ { print $1 }' | while read output
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
98 do
99 xrandr --output $output $xoptions
100 done
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
101
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
102 ;;
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
103
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
104 xrandr=*)
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
105
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
106 xoptions=$( /bin/busybox httpd -d ${x#xrandr=} )
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
107
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
108 if xrandr $xoptions
109 then
110 logs "xrandr OK $xoptions"
111 else
112 logs "xrandr ERR $xoptions"
113 fi
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
114
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
115 ;;
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
116
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
117 noblank)
118 logs "noblank"
119 xset s off
120 xset -dpms
121 ;;
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
122
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
123 numlock)
124 logs "numlock set"
125 /usr/bin/numlockx
126 ;;
cfeaa60 @kaihendry numlock API to enable numlock on by default, fixes #191
kaihendry authored
127
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
128 blank=*)
129 secondstillblank=$((${x#blank=} * 60))
130 logs "screen will blank after $secondstillblank seconds"
131 xset s $secondstillblank
132 ;;
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
133
134 esac
135 done
136
137
138 # disable bell
139 xset b 0 0
140
141 while true
142 do
143 update_background /home/webc/bg.png # bg needs to be re-rendered on rotation for example
144 $wm
145 done &
146
147 # hide the cursor by default, showcursor to override
148 cmdline | grep -qs showcursor || exec /usr/bin/unclutter &
149
150 # Stop (ab)users breaking the loop to restart the exited browser
151 trap "echo Unbreakable!" SIGINT SIGTERM
152
153 # Stuff in here gets run at every browser restart:
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
154 for x in $(cmdline); do
155 case $x in
156 homepage=*)
157 homepage="$( echo ${x#homepage=} | sed 's,%20, ,g' )"
158 ;;
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
159
160 bgurl=*)
161 bgurl="$( /bin/busybox httpd -d ${x#bgurl=} )"
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
162 # only download if newer
163 wget -N --timeout=5 "${bgurl}" -O /home/webc/bg.png.custom
164 file /home/webc/bg.png.custom | grep -qs "image data" && {
165 cp /home/webc/bg.png.custom /home/webc/bg.png # leave .custom around for wget
166 update_background /home/webc/bg.png
167 }
168 ;;
169
170 install)
171 homepage="$install_qa_url"
172 ;;
173 esac
174 done
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
175
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
176 mac=$( mac_address )
177 usbid=$( usb_serials | head -n1 )
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
178
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
179 while true
180 do
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
181
182 if test -x /opt/firefox/firefox
183 then
a9d0ecd @kaihendry Add Neon WM to make it show version/id on top bar
kaihendry authored
184
185 xsetroot -name "$webc_version $webc_id"
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
186 export webc_id="$webc_id"
a9d0ecd @kaihendry Add Neon WM to make it show version/id on top bar
kaihendry authored
187
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
188 if ! cmdline_has noclean
189 then
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
190 for d in /home/webc/{.mozilla,.adobe,.macromedia,Downloads} /tmp/webc
191 do
192 rm -rf $d
193 done
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
194 fi
fd2d664 @kaihendry xinput= API, closes #79
kaihendry authored
195
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
196 logs rhomepage: $rhomepage homepage: $homepage
197 homepage="$(echo ${rhomepage:-$homepage} | sed 's,%20, ,g')"
198 logs Launching with "${homepage}"
199 if cmdline_has instantupdate
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
200 then
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
201 export rhomepage="$(/usr/bin/webc-wsc /opt/firefox/firefox $(echo $homepage | sed "s,MACID,$mac,g" | sed "s,WEBCID,$webc_id,g" | sed "s,WEBCVERSION,$webc_version,g" | sed "s,USBID,$usbid,g" ))"
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
202 else
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
203 /opt/firefox/firefox $(echo $homepage | sed "s,MACID,$mac,g" | sed "s,WEBCID,$webc_id,g" | sed "s,WEBCVERSION,$webc_version,g" | sed "s,USBID,$usbid,g" )
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
204 fi
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
205
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
206 fi
207 done
Something went wrong with that request. Please try again.