This is a guide for installing Klipper and Octoprint on Void Linux
It is broken into 3 sections,
- Installing Klipper
- Installing Octoprint
- Installing Webcam
Each Section is broken into numbered steps. It is a lot but very dueable, it is mostly copy+paste. That said you should always try and understand what you paste into your console.
Klipper
I am assuming you have a printer.cfg
file in your home directory, your printer is connted via USB and you know kinda how to use a terminal.
I have made a new user pi
, to keep things as close to the raspberry-pi setup as I can. I recommend you do this as well.
To make a new user
### Login as root
su
# create the new user
useradd -m -G dialout,tty -s /bin/bash pi
make sure the user pi is part of the dialout and tty groups
Add this user to sudoers withvisudo
command, google if you need help with vi or install nano and runEDITOR=nano visudo
from root.
You will need python2 for this to run and python3 to set it up. As of writing this python2 in Void Linux is called python
in xbps and python3 is python3
. I think they are working on making everything python3 and there is a python3 branch that I have tested and works without Python2 but I am not sure how complete that is.
Now that the user is set up and you are logged in as pi, do the following....
- Install system dependencies
sudo xbps-install -S python python3 python3-pip python3-devel python3-setuptools git base-devel libffi-devel libyaml-devel avrdude avr-gcc avr-binutils avr-libc
- Clone Klipper Repo from github
cd ~/
git clone https://github.com/Klipper3d/klipper.git klipper
cd klipper
- Setup python-venv
python3 -m venv venv
source venv/bin/activate
- Install Dependencies
./venv/bin/python -m pip install --upgrade pip
./venv/bin/pip install -r scripts/klippy-requirements.txt
- Create runsv service(runit) direcotry and file
sudo mkdir /etc/sv/klipper
sudo touch /etc/sv/klipper/run
sudo chmod +x /etc/sv/klipper/run
- Edit the file
/etc/sv/klipper/run
#!/bin/bash
export USER=pi
export HOME=/home/pi
groups="$(id -Gn "$USER" | tr ' ' ':')"
exec chpst -u "$USER:$groups" "$HOME"/klipper/venv/bin/python "$HOME"/klipper/klippy/klippy.py "$HOME"/printer.cfg -l /tmp/klippy.log
- Enable klipper
sudo ln -srv /etc/sv/klipper /var/service
- It be a good idea to reboot too.
After this plug in your printer if is not already, make sure you have your printer.cfg in your home dir, sudo sv restart klipper
and you should be connected. I have an ender 3 with LCD enabled so I could confirm at this point that the LCD menu works. On to OctoPrint.
OctoPrint
All of the dependencies got installed in the Klipper install, so this is pretty simple.
- make the directory
cd ~
mkdir OctoPrint && cd OctoPrint
- Setup Python3 venv
python3 -m venv venv
source venv/bin/activate
- Install Octoprint
./venv/bin/pip install pip --upgrade
./venv/bin/pip install octoprint
- Create runsv service(runit) direcotry and file
sudo mkdir /etc/sv/octoprint
sudo touch /etc/sv/octoprint/run
sudo chmod +x /etc/sv/octoprint/run
- Edit the file
/etc/sv/octoprint/run
#!/bin/bash
export USER=pi
export HOME=/home/pi
groups="$(id -Gn "$USER" | tr ' ' ':')"
exec chpst -u "$USER:$groups" "$HOME"/OctoPrint/venv/bin/octoprint serve
- Enable Octoprint
sudo ln -srv /etc/sv/octoprint /var/service
Another restart might be good.
Once you open Octoprint in the browser you should install the OctoKlipper plugin.
By default the octoprint instance runs on port 5000
. So something like localhost:5000
should get you there, or the ip of the machine with void.
Webcam
- Install some things
sudo xbps-install subversion libjpeg-turbo-devel ffmpeg
cmake
- Get the repo and build it
git clone https://github.com/jacksonliam/mjpg-streamer.git
cd mjpg-streamer/mjpg-streamer-experimental
export LD_LIBRARY_PATH=.
make
- Test it
./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -w ./www"
Press Control-C to exit
You may have to add a device. in my case my laptop has a built in camera but I want to use the USB one, so I use(example)
./mjpg_streamer -i "./input_uvc.so -d /dev/video2" -o "./output_http.so -w ./www"
The `-d /dev/video2` part is different.
You can this will give you a video feed on port `8080`.
Setup Octoprint
In octoprint goto settings and webcam & timelapse section. In the "Stream URL" section put the http://ip:port/?action=stream, examplehttp://192.168.0.24:8080/?action=stream
.
If you want Timelapse enter the same http://ip:port part but with/?action=snapshot
at the end, examplehttp://192.168.0.24:8080/?action=snapshot
You should know have a video feed.Setting it up to autostart. first make the files
sudo mkdir /etc/sv/octocam
sudo touch /etc/sv/octocam/run
sudo chmod +x /etc/sv/octocam/run
-
Create a executable file that has the start command
I had trouble getting this to work any other way I tried, you need to make a file,
/home/pi/bin/octocam_run
, like so
mkdir ~/bin
touch ~/bin/octocam_run
chmod +x ~/bin/octocam_run
Next, put the following into the /home/pi/bin/octocam_run
file
#!/bin/bash
MJPGSTREAMER_HOME=/home/pi/mjpg-streamer/mjpg-streamer-experimental
camera_options="-r 640x480 -f 10"
pushd $MJPGSTREAMER_HOME
LD_LIBRARY_PATH=. ./mjpg_streamer -o "output_http.so -w ./www" -i "input_uvc.so $camera_options -d /dev/video2"
popd
-
Add content to the
/etc/sv/octocam/run
file
#!/bin/bash
export USER=pi
export HOME=/home/pi
groups="$(id -Gn "$USER" | tr ' ' ':')"
exec chpst -u "$USER:$groups" /home/pi/bin/octocam_run
- last add it to your services
sudo ln -sv /etc/sv/octocam /var/service
If you have not, maybe do a reboot.
Please let me know if I have messed anything up if there is a better way to do this. And any errors your eyes sea please.
Sources
- Klipper Install
- https://www.klipper3d.org/Installation.html
- Void Docs
-https://docs.voidlinux.org/config/services/index.html
- https://docs.voidlinux.org/config/services/user-services.html
- OcotPrint Help
- https://community.octoprint.org/t/setting-up-octoprint-on-a-raspberry-pi-running-raspbian-or-raspberry-pi-os/2337
- And the install scripts from klipper, a few man pages here and there.
Top comments (0)