v1pi: Raspberry Pi Image with Octoprint and CNC.js (and wifi hotspot)

Nice, but I think these instructions are a bit outdated.

Here is my approach:

Upgrade you pi with:

sudo apt update && sudo apt upgrade && sudo apt dist-upgrade -y

Install packages:

sudo apt-get install --no-install-recommends xserver-xorg -y
sudo apt-get install --no-install-recommends xinit -y
sudo apt-get install raspberrypi-ui-mods -y
sudo apt-get install chromium-browser -y
sudo apt-get install unclutter -y

Use raspi-config to set boot into Desktop with autologin

sudo raspi-config
3 Boot options
B1 Desktop / CLI
B4 Desktop Autologin

disable screensaver

sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

for Raspberry Pi 3 and lower add

@xset s off 
@xset -dpms

for Raspberry Pi 4 add

@xset s off
@xset dpms 0 0 0

create the folder autostart in .config

mkdir /home/pi/.config/autostart

create a file kiosk.desktop

nano /home/pi/.config/autostart/kiosk.desktop

add

[Desktop Entry]
Type=Application
Name=Kiosk
Exec=/home/pi/kiosk.sh
X-GNOME-Autostart-enabled=true

Create kiosk script:

nano /home/pi/kiosk.sh

#!/bin/bash
 
# Run this script in display 0 - the monitor
export DISPLAY=:0

# Hide the mouse from the display
unclutter &
 
# If Chrome crashes (usually due to rebooting), clear the crash flag so we don't have the annoying warning bar
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' /home/pi/.config/chromium/Default/Preferences
sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' /home/pi/.config/chromium/Default/Preferences
 
# Run Chromium and open tabs
/usr/bin/chromium-browser --kiosk http:localhost:8000/pendant &
 
# Start the kiosk loop. This keystroke changes the Chromium tab
# To have just anti-idle, use this line instead:
# xdotool keydown ctrl; xdotool keyup ctrl;
# Otherwise, the ctrl+Tab is designed to switch tabs in Chrome
# #
while (true)
do
xdotool keydown ctrl+Tab; xdotool keyup ctrl+Tab;
sleep 15
done

Download tinyweb (check latest version on Releases · cncjs/cncjs-pendant-tinyweb · GitHub)

wget https://github.com/cncjs/cncjs-pendant-tinyweb/archive/v1.2.4.zip

Unzip and move

unzip v1.2.4.zip

sudo mv /home/pi/cncjs-pendant-tinyweb-1.2.4 /home/tinyweb

Change startscript for CNCJS

sudo nano /etc/default/cncjs

change

DAEMON_ARGS="--host=$HOST --port=$PORT" 

to

DAEMON_ARGS="--host=$HOST --port=$PORT -m /pendant:/home/tinyweb/src"

Reboot your PI

Using a 320 px wide screen?
Since Chromium can’t get narrower than 350 or so pix, you need to alter the css for tinyweb

nano /home/tinyweb/src/css/theme.css

Add:

body {
    margin-right: 20px;
}

Hope this helps someone :wink:

4 Likes