Skip to content

Commit

Permalink
Add kiosk mode stage
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalCz committed Mar 16, 2024
1 parent 29f7bb2 commit 9adc057
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 0 deletions.
2 changes: 2 additions & 0 deletions stage99-z1-kiosk/00-install-packages/00-debconf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Adobe Flash Player. Copyright 1996-2015. Adobe Systems Incorporated. All Rights Reserved.
rpi-chromium-mods rpi-chromium-mods/adobe note
10 changes: 10 additions & 0 deletions stage99-z1-kiosk/00-install-packages/00-packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
xserver-xorg xinit x11-xserver-utils
chromium-browser matchbox-window-manager xautomation unclutter
fonts-noto-color-emoji
gstreamer1.0-x gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-alsa gstreamer1.0-libav
git
chromium-browser rpi-chromium-mods libwidevinecdm0
gldriver-test
fonts-droid-fallback
fonts-liberation2
vulkan-tools mesa-vulkan-drivers
6 changes: 6 additions & 0 deletions stage99-z1-kiosk/01-setup-user/00-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash -e

on_chroot << EOF
SUDO_USER="${FIRST_USER_NAME}" raspi-config nonint do_boot_behaviour B2
SUDO_USER="${FIRST_USER_NAME}" raspi-config nonint do_overscan 1
EOF
13 changes: 13 additions & 0 deletions stage99-z1-kiosk/02-setup-kiosk/00-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash -e

install -v -o 1000 -g 1000 -d -m 755 "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/bin"
install -v -o 1000 -g 1000 -m 755 files/kiosk "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/bin"

install -v -o 1000 -g 1000 -d -m 755 "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/kiosk"
install -v -o 1000 -g 1000 -m 755 files/init.html "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/kiosk"

echo 'xinit /home/pi/kiosk -- vt$(fgconsole)' >> /home/${FIRST_USER_NAME}/.bashrc

on_chroot << EOF
chown ${FIRST_USER_NAME}:${FIRST_USER_NAME} /home/${FIRST_USER_NAME}/.bashrc
EOF
66 changes: 66 additions & 0 deletions stage99-z1-kiosk/02-setup-kiosk/files/init.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!DOCTYPE html>
<html>
<head>
<style>
body {
font-family: "Open Sans", "Arial", "Helvetica", sans-serif;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f1f1f1;
}

.loader {
display: inline-block;
width: 80px;
height: 80px;
border: 10px solid #ccc;
border-top-color: #333;
border-radius: 50%;
animation: spin 1s infinite ease-in-out;
}

@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}

.message {
text-align: center;
margin-top: 20px;
font-size: 18px;
color: #111;
}
</style>
<script>
let attempts = 0;
function checkApiUrl() {
fetch('http://localhost:9080/api/url')
.then(response => response.json())
.then(data => {
// Redirect to the URL in the response
window.location.href = data.url;
})
.catch(error => {
// Refresh the page every 10 attempts
if (attempts % 10 === 0) {
window.location.reload();
}
setTimeout(checkApiUrl, 1000); // Retry after 1 second timeout
});
}

checkApiUrl(); // Initial check
</script>
</head>
<body>
<div>
<svg alt="Scramjet" class="nav__logo-img" width="100%" height="100%" viewBox="0 0 309.059319 120" version="1.1"><title>191D4BD8-E624-4E50-AA91-EEF6B698E6D1</title><g id="Assets" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g transform="translate(-970.000000, -221.000000)" fill-rule="nonzero" id="logo"><g transform="translate(970.000000, 100.000000)"><g id="logotype" transform="translate(0.000000, 121.000000)"><path d="M91.6525067,86.1400689 L94.7294298,81.9487179 C96.7990815,83.9112132 99.4504401,85.1327976 102.795254,85.1327976 C105.82013,85.1327976 108.153081,84.071948 108.153081,82.163031 C108.153081,80.0382702 105.501722,79.3463452 102.317643,78.6054344 C97.9655568,77.5951014 92.5005741,76.2189055 92.5005741,70.2747799 C92.5005741,64.7026406 97.4358974,61.9425947 103.272866,61.9425947 C107.730578,61.9425947 111.179487,63.5882128 113.569078,65.5522388 L110.437046,69.7435897 C108.578645,68.1515499 106.192116,67.0907003 103.380023,67.0907003 C100.725603,67.0907003 98.5503253,67.9938768 98.5503253,69.8492155 C98.5503253,71.9724455 101.149636,72.6092614 104.440873,73.351703 C108.791427,74.3069269 114.204363,75.6861845 114.204363,81.5767317 C114.204363,87.2024493 109.216992,90.2793724 102.90088,90.2793724 C97.9655568,90.2793724 94.2518178,88.4225029 91.6525067,86.1400689 Z M117.602755,76.1132798 C117.602755,68.0459242 123.811711,61.9425947 132.090318,61.9425947 C137.503253,61.9425947 142.06659,64.5970149 144.508228,68.6827401 L139.360122,71.8132415 C137.928817,69.3195561 135.272866,67.673938 132.088787,67.673938 C127.314198,67.673938 123.706085,71.3356295 123.706085,76.1132798 C123.706085,80.8863375 127.314198,84.5480291 132.090318,84.5480291 C135.274397,84.5480291 137.928817,82.9039418 139.361653,80.4087256 L144.508228,83.5407577 C142.06659,87.6280138 137.503253,90.2793724 132.090318,90.2793724 C123.811711,90.2793724 117.602755,84.1775737 117.602755,76.1132798 Z M164.676617,62.1507845 L164.676617,68.2525832 L163.669346,68.2525832 C158.360505,68.2525832 155.231535,71.4902411 155.231535,76.4791427 L155.231535,89.637964 L149.287409,89.637964 L149.287409,62.5732874 L155.231535,62.5732874 L155.231535,66.5533869 C157.247608,63.7964026 160.114811,62.1507845 163.669346,62.1507845 L164.676617,62.1507845 Z M195.406047,62.5794106 L195.406047,89.6440873 L189.461921,89.6440873 L189.461921,85.7696135 C187.231535,88.5817069 183.94336,90.2793724 179.96173,90.2793724 C172.32147,90.2793724 166.643705,84.1775737 166.643705,76.1117489 C166.643705,68.0443934 172.32147,61.9425947 179.96173,61.9425947 C183.94336,61.9425947 187.231535,63.641791 189.461921,66.4538844 L189.461921,62.5794106 L195.406047,62.5794106 Z M189.461921,76.1117489 C189.461921,71.3356295 185.907386,67.6754688 181.129736,67.6754688 C176.301569,67.6754688 172.747034,71.3356295 172.747034,76.1102181 C172.747034,80.8863375 176.301569,84.5510907 181.129736,84.5510907 C185.907386,84.5510907 189.461921,80.8863375 189.461921,76.1117489 Z M245.131267,72.0780712 L245.131267,89.6440873 L239.187141,89.6440873 L239.187141,73.8277842 C239.187141,70.115576 236.854191,67.673938 233.190968,67.673938 C229.371604,67.673938 226.770762,70.1691542 226.770762,73.9349407 L226.770762,89.6440873 L220.828167,89.6440873 L220.828167,73.8277842 C220.828167,70.115576 218.490624,67.673938 214.831994,67.673938 C211.011098,67.673938 208.410256,70.1691542 208.410256,73.9349407 L208.410256,89.6440873 L202.4646,89.6440873 L202.4646,62.5794106 L208.410256,62.5794106 L208.410256,65.7634902 C210.427861,63.268274 213.292002,61.9425947 216.794489,61.9425947 C220.774589,61.9425947 223.851512,63.7489476 225.498661,66.7187141 C227.618829,63.641791 230.910065,61.9425947 234.99579,61.9425947 C241.151167,61.9425947 245.131267,65.9762725 245.131267,72.0780712 L245.131267,72.0780712 Z M291.732109,78.4982778 L269.815538,78.4982778 C270.770762,82.3742824 274.114045,84.9215461 278.518178,84.9215461 C282.074244,84.9215461 285.09912,83.2223498 286.636051,81.2047455 L290.669728,84.6536548 C287.911213,88.1040949 283.453502,90.2793724 278.358974,90.2793724 C269.761959,90.2793724 263.3938,84.1255262 263.3938,76.0045924 C263.3938,67.9938768 269.552239,61.9425947 277.670111,61.9425947 C285.789514,61.9425947 291.889782,67.9938768 291.889782,76.1637964 C291.889782,76.9092997 291.837734,77.757367 291.732109,78.4982778 L291.732109,78.4982778 Z M269.761959,73.6180635 L285.523153,73.6180635 C284.621508,69.7956372 281.489476,67.3019518 277.616533,67.3019518 C273.742059,67.3019518 270.718714,69.8492155 269.761959,73.6180635 Z M258.032912,62.5748182 L252.090318,62.5748182 L252.090318,108.260237 L258.032912,108.260237 L258.032912,62.5732874 L258.032912,62.5748182 Z M298.424799,52.6000765 L298.424799,62.576349 L293.859931,62.576349 L293.859931,67.9908152 L298.424799,67.9908152 L298.424799,89.6410256 L304.367394,89.6410256 L304.367394,67.9908152 L309.059319,67.9908152 L309.059319,62.576349 L304.367394,62.576349 L304.367394,52.6000765 L298.424799,52.6000765 Z M258.032912,52.6000765 L252.090318,52.6000765 L252.090318,58.5442021 L258.032912,58.5442021 L258.032912,52.6000765 Z" id="Shape" fill="#1066B2"></path><g id="Group-21"><polygon id="Path" fill="#1066B2" points="86.2717183 0 39.1580559 45.6609261 8.99502488 57.996173 17.4894757 74.36969 13.6762342 79.7703789 25.7435897 88.1377727"></polygon><polygon id="Path" fill="#2372BA" points="25.7435897 88.1377727 37.8124761 96.3612706 41.4879449 90.8672024 59.8178339 92.9292002 60.5265978 60.3474933 86.2717183 0.0015308075 25.7435897 88.1408343"></polygon><polygon id="Path" fill="#F5832A" points="8.15778112e-15 111.300421 19.4381936 87.1427478 13.065442 105.849215 28.1944126 92.9674703 12.7332568 120 32.9322618 94.894757 29.0455415 92.2403368 28.7332568 92.0244929 20.2005358 86.1982396 19.8438576 85.9533104 15.9984692 83.3264447 0 111.300421"></polygon></g></g></g></g></g></svg>
</div>
<div class="loader"></div>
<div class="message">System initializing...</div>
</body>
</html>
7 changes: 7 additions & 0 deletions stage99-z1-kiosk/02-setup-kiosk/files/kiosk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
xset -dpms # disable DPMS (Energy Star) features.
xset s off # disable screen saver
xset s noblank # don't blank the video device
matchbox-window-manager -use_titlebar no &
unclutter & # hide X mouse cursor unless mouse activated
chromium-browser --display=:0 --kiosk --incognito --window-position=0,0 file:///${HOME}/kiosk/init.html
4 changes: 4 additions & 0 deletions stage99-z1-kiosk/EXPORT_IMAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
IMG_SUFFIX="-sth-kiosk"
if [ "${USE_QEMU}" = "1" ]; then
export IMG_SUFFIX="${IMG_SUFFIX}-qemu"
fi
7 changes: 7 additions & 0 deletions stage99-z1-kiosk/prerun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash -e

echo "Copying previous"

if [ ! -d "${ROOTFS_DIR}" ]; then
copy_previous
fi

0 comments on commit 9adc057

Please sign in to comment.