diff --git a/README.md b/README.md index afa7cc9..63f6e6c 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,18 @@ Easy-to-use **Raspberry Pi** image for booting directly into **full-screen Chrom 2. Download the [latest image](https://github.com/futurice/chilipie-kiosk/releases). 3. Decompress it. 4. Flash the image onto your SD card. We recommend [Etcher](https://etcher.io/) for this: it's delightfully easy to use, cross platform, and will verify the result automatically. If you know what you're doing, you can of course also just `sudo dd bs=1m if=chilipie-kiosk-vX.Y.Z.img of=/dev/rdisk2`. -5. *Optional*: [Setup automatic WiFi](#automatic-wifi-setup) -6. Insert the SD card to your Pi and power it up. -7. You should land in the [first-boot document](docs/first-boot.md), for further instructions & ideas. +5. *Optional*: [Set URL before boot](#set-url-before-boot) +6. *Optional*: [Setup automatic WiFi](#automatic-wifi-setup) +7. Insert the SD card to your Pi and power it up. +8. You should land in the [first-boot document](docs/first-boot.md), for further instructions & ideas. + +### Set URL before boot + +1. After flashing remount your SD card. +2. Create a *chilipie_url.txt* in your SD cards boot folder or */home/pi*. +3. Write URL in **first** line of file. + +Note: You can user `${SERIAL}` to get Pi's serial number into URL. ### Automatic WiFi setup @@ -66,6 +75,7 @@ The Pi needs a [2.5 Amp power source](https://www.raspberrypi.org/documentation/ - **I get a kernel panic on boot, or the image keeps crashing.** The Raspberry Pi is somewhat picky about about its SD cards. It's also possible the SD card has a bad sector in a critical place, and `dd` wasn't be able to tell you. Double-check that you're using [a blessed SD card](http://elinux.org/RPi_SD_cards), and try flashing the image again. - **I see a "rainbow square" or "yellow lightning" in the top right corner of the screen, and the device seems unstable.** This usually means the Pi isn't getting enough amps from your power supply. This is sometimes the case in more exotic setups (e.g. using the USB port of your display to power the Pi) or with cheap power supplies. Try another one. - **The [display control scripts](home/display-on.sh) don't turn off the display device.** Normal PC displays will usually power down when you cut off the signal, but this is not the case for many TV's. Please check if your TV has an option in its settings for enabling this, as some do. If not, you can [try your luck with HDMI CEC signals](http://raspberrypi.stackexchange.com/questions/9142/commands-for-using-cec-client), but the TV implementations of the spec are notoriously spotty. +- **The MicroSD card isn't flashing correctly, I don't see the boot partition.** This commonly happens on Windows computers and can be fixed by extracting the `chilipie*.img` file from the `tar.gz`. You will need to use an extraction tool that supports both gzip and tar archive formats, such as 7zip. Extract the contents of the `img.tar.gz` file, then extract the contents of the resulting `img.tar` file again. You should be left with an `.img` file, which you can then use with Etcher to flash your SD card. ## Acknowledgements diff --git a/docs/image-setup.sh b/docs/image-setup.sh index bb0c67f..db175cf 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -216,7 +216,7 @@ ssh "touch .hushlogin" # https://scribles.net/silent-boot-on-raspbian-stretch-in ssh "sudo perl -i -p0e 's#--autologin pi#--skip-login --noissue --login-options \"-f pi\"#g' /etc/systemd/system/getty@tty1.service.d/autologin.conf" # "perl" is more cross-platform than "sed -i" working "Installing packages" -ssh "sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install -y vim matchbox-window-manager unclutter mailutils nitrogen jq chromium-browser xserver-xorg xinit rpd-plym-splash xdotool rng-tools xinput-calibrator" +ssh "sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install -y vim matchbox-window-manager unclutter mailutils nitrogen jq chromium-browser xserver-xorg xinit rpd-plym-splash xdotool rng-tools xinput-calibrator cec-utils" # We install mailutils just so that you can check "mail" for cronjob output working "Setting home directory default content" diff --git a/home/.xsession b/home/.xsession index df4cf26..77b1a6e 100755 --- a/home/.xsession +++ b/home/.xsession @@ -26,7 +26,19 @@ if [ -f .config/chromium/Default/Preferences ]; then fi # Remove notes of previous sessions, if any -find .config/chromium/ -name "Last *" | xargs rm +find .config/chromium/ -name "Last *" -exec rm {} + + +# Get URL from file (if set) +URL="" +if [ -f /boot/chilipie_url.txt ]; then + URL="$(head -n 1 /boot/chilipie_url.txt)" +elif [ -f /home/pi/chilipie_url.txt ]; then + URL="$(head -n 1 /home/pi/chilipie_url.txt)" +fi +if [ -n "$URL" ]; then + SERIAL="$(cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2 | xargs)" # Get serial number + URL="$(echo $URL | SERIAL=$SERIAL envsubst '$SERIAL')" +fi # Start and detach Chromium # http://peter.sh/experiments/chromium-command-line-switches/ @@ -36,7 +48,7 @@ chromium-browser \ --window-position=9000,9000 \ --disable-infobars \ --check-for-update-interval=1 --simulate-critical-update \ - & + $URL & # See https://github.com/futurice/chilipie-kiosk/issues/99#issuecomment-597119842 for the need for the fishy-sounding "--check-for-update-interval=1 --simulate-critical-update" switches; TODO: remove when not needed # Hide Chromium while it's starting/loading the page diff --git a/home/cec-off.sh b/home/cec-off.sh new file mode 100755 index 0000000..1033e4f --- /dev/null +++ b/home/cec-off.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo 'standby 0' | cec-client -s > /dev/null diff --git a/home/cec-on.sh b/home/cec-on.sh new file mode 100755 index 0000000..cd4473f --- /dev/null +++ b/home/cec-on.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo 'on 0' | cec-client -s > /dev/null diff --git a/home/crontab.example b/home/crontab.example index 3ba1fcd..ea79d14 100644 --- a/home/crontab.example +++ b/home/crontab.example @@ -14,6 +14,7 @@ DISPLAY=:0.0 0 3 * * * sudo reboot # Example: Turn display on weekdays at 7 AM +# Note: You may exchange "display-on" / "display-off" with "cec-on" / "cec-off" in order to use HDMI CEC # 0 7 * * 1-5 ~/display-on.sh # Example: Turn display off weekdays at 7 PM (and after the nightly reboot) diff --git a/home/display-off.sh b/home/display-off.sh index efb1962..90cf3a2 100755 --- a/home/display-off.sh +++ b/home/display-off.sh @@ -1,3 +1,3 @@ #!/bin/bash -sudo tvservice -o > /dev/null +sudo vcgencmd display_power 0 > /dev/null diff --git a/home/display-on.sh b/home/display-on.sh index 6bdf0a6..794b064 100755 --- a/home/display-on.sh +++ b/home/display-on.sh @@ -1,3 +1,3 @@ #!/bin/bash -sudo tvservice -p > /dev/null && sudo chvt 2 && sudo chvt 1 # for whatever reason, cycling virtual terminals helps wake up the display in some cases +sudo vcgencmd display_power 1 > /dev/null