-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.sh
executable file
·141 lines (117 loc) · 3.86 KB
/
install.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
136
137
138
139
140
141
#!/bin/bash
main () {
intro
get_wunderground_key
rotate_monitor
improve_color
font_antialiasing
prevent_monitor_sleep
install_chromium
autostart_chromium
copy_screen_script
modify_cron
show_complete
}
intro() {
echo "================================================="
echo $'\e[32mDaylight Kiosk Installation\e[39m'
}
get_wunderground_key () {
echo
read -p $'\e[33mWhat\'s your Wunderground API Key? \e[39m' -r WUNDER_KEY
}
rotate_monitor() {
echo
read -p $'\e[33mRotate the monitor? \e[2m(\e[0m0\e[2m=No, 1=90°, 2=180°, 3=270°)\e[0m \e[39m' -r REPLY
if [ -z $REPLY ]
then
REPLY="N"
fi
if [[ ! $REPLY =~ ^[Nn]$ ]]
then
echo "Updating monitor config..."
sudo bash -c "echo 'display_rotate=$REPLY' >> /boot/config.txt"
fi
}
improve_color() {
echo
read -p $'\e[33mImprove color settings? \e[2m(\e[0mY\e[2m/n)\e[0m \e[39m' -r REPLY
if [[ ! $REPLY =~ ^[Nn]$ ]]
then
echo "Modifying color configuration..."
sudo bash -c "echo 'framebuffer_depth=32' >> /boot/config.txt"
sudo bash -c "echo 'framebuffer_ignore_alpha=1' >> /boot/config.txt"
fi
}
font_antialiasing() {
echo
read -p $'\e[33mTurn on font antialiasing? \e[2m(\e[0mY\e[2m/n)\e[0m \e[39m' -r REPLY
if [[ ! $REPLY =~ ^[Nn]$ ]]
then
echo "Copying antialias files..."
mkdir ~/.config/fontconfig
cp ./src/fonts.xml ~/.config/fontconfig/.fonts.conf
fi
}
prevent_monitor_sleep() {
echo
read -p $'\e[33mPrevent monitor from sleeping? \e[2m(\e[0mY\e[2m/n)\e[0m \e[39m' -r REPLY
if [[ ! $REPLY =~ ^[Nn]$ ]]
then
echo "Modifying files..."
touch ~/.xinitrc
echo "@xset s noblank" >> ~/.xinitrc
echo "@xset s off" >> ~/.xinitrc
echo "@xset -dpms" >> ~/.xinitrc
echo "@xset s 0 0" >> ~/.config/lxsession/LXDE-pi/autostart
echo "@xset s noblank" >> ~/.config/lxsession/LXDE-pi/autostart
echo "@xset s noexpose" >> ~/.config/lxsession/LXDE-pi/autostart
echo "@xset dpms 0 0 0" >> ~/.config/lxsession/LXDE-pi/autostart
sudo sed -i 's/@xscreensaver/#@xscreensaver/' /etc/xdg/lxsession/LXDE/autostart
sudo bash -c "echo 'xserver-command=X -s 0 dpms' >> /etc/lightdm/lightdm.conf"
fi
}
install_chromium() {
echo
echo "Installing chromium..."
sudo apt-get update
wget -qO - http://bintray.com/user/downloadSubjectPublicKey?username=bintray | sudo apt-key add -
echo "deb http://dl.bintray.com/kusti8/chromium-rpi jessie main" | sudo tee -a /etc/apt/sources.list
sudo apt-get install chromium-browser x11-xserver-utils unclutter
}
autostart_chromium() {
echo
echo "Setting Chromium to autostart..."
STARTUP_URL="http://daylight.danmconrad.com?token=$WUNDER_KEY"
echo "@chromium-browser --kiosk --start-maximized --incognito --disable-infobars $STARTUP_URL" >> ~/.config/lxsession/LXDE-pi/autostart
echo "@unclutter -idle 0.1 -root" >> ~/.config/lxsession/LXDE-pi/autostart
}
copy_screen_script() {
echo
read -p $'\e[33mDoes your TV support CEC? If so, make sure to install the \ncec-client the instructions here https://github.com/Pulse-Eight/libcec/ \e[2m(\e[0mY\e[2m/n)\e[0m \e[39m' -r REPLY
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "Copying CEC script..."
sudo cp ./src/screen-cec.sh /usr/local/sbin/screen
else
echo "Copying TV script..."
sudo cp ./src/screen-tv.sh /usr/local/sbin/screen
fi
sudo chmod 755 /usr/local/sbin/screen
}
modify_cron() {
echo
echo "Modifying power schedule... (on at 6am, off at 11am)"
sudo crontab -l > root-cron
echo "0 6 * * * /usr/local/sbin/screen on 2> /usr/local/sbin/screen.err.log" >> root-cron
echo "0 11 * * * /usr/local/sbin/screen off 2> /usr/local/sbin/screen.err.log" >> root-cron
echo "" >> root-cron
sudo crontab root-cron
rm root-cron
sudo service cron restart
sudo update-rc.d cron defaults
}
show_complete() {
echo $'\n\n\e[32mAll done! You can restart your PI by typing "sudo reboot -h now"\e[39m\n\n'
}
main