-
Notifications
You must be signed in to change notification settings - Fork 17
/
chromium.xinit
94 lines (81 loc) · 3.28 KB
/
chromium.xinit
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
#!/bin/sh
# DEFAULT VARIABLES
# DO NOT EDIT THESE!!
# EDIT THESE VARIABLES IN '/etc/default/touchui'
TOUCHUI_ARGS=""
TOUCHUI_DEBUG=""
TOUCHUI_EXTRA='echo "TouchUI: screensaver enabled"'
TOUCHUI_PORT="8888"
TOUCHUI_URL="http://localhost:$TOUCHUI_PORT/"
TOUCHUI_EXECUTE="matchbox-window-manager & unclutter -idle 0.1 &"
TOUCUI_SERVER_TYPE="IPv4"
CHROME_BIN="chromium-browser"
AUTODETECT_PORT=true
CONFIG_DIR=/run/touchui-chromium/
# Uncomment the next variable to generate a full log under ~/.config/chromium/chrome_debug.log
# or to enable the remote deugger, forward port by haproxy or by tunnel
#TOUCHUI_DEBUG="--remote-debugging-port=9222 --enable-logging --v=100"
# Load octoprint settings for getting $PORT
[ -r /etc/default/octoprint ] && . /etc/default/octoprint
# Load touchui settings for getting $TOUCHUI_USER and $FORCE_TOUCH
[ -r /etc/default/touchui ] && . /etc/default/touchui
mkdir -p $CONFIG_DIR
chown -R $TOUCHUI_USER:$TOUCHUI_USER $CONFIG_DIR
# Remove restore last session after crash in Chrome
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' $CONFIG_DIR/Default/Preferences
sed -i 's/"exit_type":"Crashed"/"exit_type":"None"/' $CONFIG_DIR/Default/Preferences
# And another one for not minified Preferences (Chrome legacy)
sed -i 's/"exited_cleanly": false/"exited_cleanly": true/' $CONFIG_DIR/Default/Preferences
sed -i 's/"exit_type": "Crashed"/"exit_type": "None"/' $CONFIG_DIR/Default/Preferences
# Check if OctoPi is used
OCTOPI_FILE="/etc/octopi_version"
OCTOPI=""
if [ "$AUTODETECT_PORT" = true ]
then
if [ -f "$OCTOPI_FILE" ]
then
echo "TouchUI: OctoPi detected"
PORT="80"
fi
fi
# Check if $FORCE_TOUCH is set to true
# This variable is set inside /etc/default/touchui
if [ "$FORCE_TOUCH" = true ]
then
echo "TouchUI: touch events enabled (forced)"
TOUCHUI_ARGS="$TOUCHUI_ARGS --touch-events=enabled"
else
# Force Chrome to render with touch events
# Bugfix #46
TOUCHUI_DEVICE=$(xinput --list --long | grep XITouchClass)
if [ -z "$TOUCHUI_DEVICE" ]
then
echo "TouchUI: touch events automatically detected"
else
echo "TouchUI: touch events enabled"
TOUCHUI_ARGS="$TOUCHUI_ARGS --touch-events=enabled"
fi
fi
# Check if we need to disable the screensaver
if [ "$DISABLE_SCREENSAVER" = true ]
then
echo "TouchUI: screensaver disabled"
TOUCHUI_EXTRA="xset s off & xset -dpms & xset s noblank"
fi
TOUCHUI_DIR="/home/$TOUCHUI_USER/$TOUCHUI_DIR"
CHROME_VERSION=$(dpkg -s chromium-browser | grep "Version: " | sed -e 's/Version: //g')
CHROME_ARGS=" --no-first-run --kiosk $TOUCHUI_ARGS $TOUCHUI_DEBUG
--dns-prefetch-disable --disable-sync-preferences --disk-cache-size=1 --disk-cache-dir=/dev/null
--disable-java --disable-plugins --disable-extensions --disable-infobars
--user-agent='TouchUI (X11, Chrome $CHROME_VERSION$OCTOPI) (P:$PORT)'
--start-maximized --window-position=0,0 --user-data-dir=$CONFIG_DIR
$TOUCHUI_URL"
[ -r $TOUCHUI_DIR/calibration.sh ] && . $TOUCHUI_DIR/calibration.sh
# Start local web server to host the startup page to avoid CORS problems using local files
python $TOUCHUI_DIR/helpers/server.py \
--dir $TOUCHUI_DIR/bootloader/ \
--port $TOUCHUI_PORT &
# Start window manager, unclutter to remove cursor and start chromium as specific user
eval $TOUCHUI_EXTRA &
eval $TOUCHUI_EXECUTE &
su $TOUCHUI_USER -c "$CHROME_BIN $(echo $CHROME_ARGS|tr -d '\n')"