forked from asb/spindle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wheezy-stage4-lxde-edu
executable file
·151 lines (141 loc) · 3.96 KB
/
wheezy-stage4-lxde-edu
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
142
143
144
145
146
147
148
149
150
151
#!/bin/sh
# Part of spindle http://asbradbury.org/projects/spindle
#
# See LICENSE file for copyright and license details
set -ex
WORKDIR=work
OUTDIR=out
CURIMG=stage4-lxde-edu.qed
. ./common
install_packages() {
ssh_in_to_qemu chroot /mnt sh -l -ex - <<EOF
apt-get update
apt-get install -y python idle python-pygame python-tk
apt-get install -y python3 idle3 python3-tk
apt-get install -y debian-reference-en dillo
apt-get install -y scratch
# Requested for raspberry filling
apt-get install -y python3-numpy
EOF
}
setup_python_game_examples() {
onvm_chroot sh -l -e <<\EOF
cd /home/pi
wget http://asbradbury.org/tmp/raspi/python_games.tar.gz
tar -xvf python_games.tar.gz
cd python_games
wget http://asbradbury.org/tmp/raspi/fix_wormy.patch
patch -p1 < fix_wormy.patch
rm fix_wormy.patch
cat <<\EOF1 > launcher.sh
#!/bin/sh
# Thanks to KenT for contributions
RET=0
SOUND=$(zenity --list --width=350 --height=250 --radiolist \
--title="Choose the Audio Output" \
--column "Select" --column="Output" TRUE "Leave as is" FALSE "Auto" FALSE "Force Headphones" FALSE "Force HDMI" )
RET=$?
echo $SOUND
if [ "$SOUND" = "Leave as is" ]; then
echo "Leave as is"
elif [ "$SOUND" = "Auto" ]; then
amixer cset numid=3 0
echo "Auto set"
elif [ "$SOUND" = "Force Headphones" ]; then
amixer cset numid=3 1
echo "Headphones set"
elif [ "$SOUND" = "Force HDMI" ]; then
amixer cset numid=3 2
echo "HDMI set"
else
echo "cancel"
fi
while [ $RET -eq 0 ]; do
GAME=$(zenity --width=350 --height=700 --list \
--title="Choose the Python game to launch" \
--text="Games by Al Sweigart. Manual at inventwithpython.com/pygame" \
--column="Script name" --column="Description" \
flippy "A game like reversi" \
fourinarow "Get four in a row" \
gemgem "A tile matching puzzle" \
inkspill "Flood the screen with pixels" \
memorypuzzle "Test your memory" \
simulate "Repeat the pattern" \
slidepuzzle "Traditional slide puzzle" \
squirrel "Eat the smaller squirrels" \
starpusher "Sokoban" \
wormy "Snake-like game" \
website "inventwithpython.com")
RET=$?
echo $RET
if [ "$RET" -eq 0 ]
then
if [ "$GAME" = "website" ]
then
sensible-browser "http://inventwithpython.com/pygame"
else
if [ "$GAME" != "" ]; then
cd /home/pi/python_games
python $GAME.py
fi
fi
fi
done
EOF1
chmod +x launcher.sh
cd ..
rm python_games.tar.gz
chown -R pi:pi python_games
mkdir -p Desktop
cd Desktop
cat <<\EOF2 > python-games.desktop
[Desktop Entry]
Name=Python Games
Comment=From http://inventwithpython.com/pygame/
Exec=/home/pi/python_games/launcher.sh
Icon=/usr/share/pixmaps/python.xpm
Terminal=false
Type=Application
Categories=Application;Games;
StartupNotify=true
EOF2
cd ..
chown -R pi:pi Desktop
EOF
}
# relies on the fact we made a Desktop directory in
# setup_python_game_examples
setup_desktop_icons() {
onvm_chroot sh -l -e <<\EOF
cd /usr/share/applications
sudo -u pi cp -a scratch.desktop midori.desktop idle.desktop idle3.desktop \
lxterminal.desktop debian-reference-common.desktop /home/pi/Desktop
cd /home/pi/Desktop
sed -i debian-reference-common.desktop -e "s/^Exec=.*/Exec=env BROWSER=dillo debian-reference/"
EOF
}
# There are 2 menu entries for both of idle3 and idle2. Fix this
hide_redundant_idle_menu_entries() {
onvm_chroot sh -l -e <<\EOF
mkdir -p /usr/local/share/applications
for ENTRY in /usr/share/applications/idle-python*.desktop; do
cp -a $ENTRY /usr/local/share/applications
printf "NoDisplay=true\n" >> "/usr/local/share/applications/$(basename $ENTRY)"
done
EOF
}
cd $WORKDIR
dotask branch_image ../$OUTDIR/stage4-lxde.qed $CURIMG
dotask run_qemu $CURIMG
dotask disable_starting_services
dotask mount_apt_cache
dotask install_packages
dotask setup_python_game_examples
dotask setup_desktop_icons
dotask hide_redundant_idle_menu_entries
dotask save_space_using_hardlink
dotask allow_starting_services
dotask fingerprint_debian
dotask update_issue
dotask shutdown_qemu
dotask finish_image