Skip to content
Newer
Older
100644 235 lines (182 sloc) 5.06 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
d412bda @kaihendry synclient & amixer API
kaihendry authored
117 synclient=*)
118
119 xoptions=$( /bin/busybox httpd -d ${x#synclient=} )
120
121 if synclient $xoptions
122 then
123 logs "synclient OK $xoptions"
124 else
125 logs "synclient ERR $xoptions"
126 fi
127
128 ;;
129
130
131 amixer=*)
132
133 xoptions=$( /bin/busybox httpd -d ${x#amixer=} )
134
135 if amixer $xoptions
136 then
137 logs "amixer OK $xoptions"
138 else
139 logs "amixer ERR $xoptions"
140 fi
141
142 ;;
143
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
144 noblank)
145 logs "noblank"
146 xset s off
147 xset -dpms
148 ;;
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
149
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
150 numlock)
151 logs "numlock set"
152 /usr/bin/numlockx
153 ;;
cfeaa60 @kaihendry numlock API to enable numlock on by default, fixes #191
kaihendry authored
154
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
155 blank=*)
156 secondstillblank=$((${x#blank=} * 60))
157 logs "screen will blank after $secondstillblank seconds"
158 xset s $secondstillblank
159 ;;
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
160
161 esac
162 done
163
164
165 # disable bell
166 xset b 0 0
167
168 while true
169 do
170 update_background /home/webc/bg.png # bg needs to be re-rendered on rotation for example
171 $wm
172 done &
173
174 # hide the cursor by default, showcursor to override
175 cmdline | grep -qs showcursor || exec /usr/bin/unclutter &
176
177 # Stop (ab)users breaking the loop to restart the exited browser
178 trap "echo Unbreakable!" SIGINT SIGTERM
179
180 # Stuff in here gets run at every browser restart:
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
181 for x in $(cmdline); do
182 case $x in
183 homepage=*)
184 homepage="$( echo ${x#homepage=} | sed 's,%20, ,g' )"
185 ;;
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
186
187 bgurl=*)
188 bgurl="$( /bin/busybox httpd -d ${x#bgurl=} )"
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
189 # only download if newer
190 wget -N --timeout=5 "${bgurl}" -O /home/webc/bg.png.custom
191 file /home/webc/bg.png.custom | grep -qs "image data" && {
192 cp /home/webc/bg.png.custom /home/webc/bg.png # leave .custom around for wget
193 update_background /home/webc/bg.png
194 }
195 ;;
196
197 install)
198 homepage="$install_qa_url"
199 ;;
200 esac
201 done
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
202
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
203 mac=$( mac_address )
204 usbid=$( usb_serials | head -n1 )
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
205
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
206 while true
207 do
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
208
209 if test -x /opt/firefox/firefox
210 then
a9d0ecd @kaihendry Add Neon WM to make it show version/id on top bar
kaihendry authored
211
212 xsetroot -name "$webc_version $webc_id"
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
213 export webc_id="$webc_id"
a9d0ecd @kaihendry Add Neon WM to make it show version/id on top bar
kaihendry authored
214
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
215 if ! cmdline_has noclean
216 then
f44290e @kaihendry Clean out additional cruft that has somehow made its way into the ~we…
kaihendry authored
217 for d in /home/webc/{.mozilla,.cache,.config,Desktop,.gstreamer*,.adobe,.macromedia,Downloads} /tmp/webc
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
218 do
219 rm -rf $d
220 done
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
221 fi
fd2d664 @kaihendry xinput= API, closes #79
kaihendry authored
222
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
223 logs rhomepage: $rhomepage homepage: $homepage
224 homepage="$(echo ${rhomepage:-$homepage} | sed 's,%20, ,g')"
225 logs Launching with "${homepage}"
226 if cmdline_has instantupdate
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
227 then
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
228 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
229 else
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
230 /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
231 fi
52851cf @kaihendry Implement "instantupdate" with https://github.com/webconverger/wsc
kaihendry authored
232
2efa477 @kaihendry Re-organisation due to noexec limitation on /home
kaihendry authored
233 fi
234 done
Something went wrong with that request. Please try again.