Run Klipper/OctoPrint In Void Linux
This is a guide for installing Klipper and Octoprint on Void Linux
I posted this on dev.to but i normally post here so IDK where is best
It is broken down into 3 sections…
1. Installing __Klipper__
2. Installing __Octoprint__
3. 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.
I am assuming you have a `printer.cfg` file in your home directory, your printer is connected 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
# 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 with `visudo` command, google if you need help with vi or install nano and run `EDITOR=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….
1. 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
2. Clone Klipper Repo from github
cd ~/git clone https://github.com/Klipper3d/klipper.git klippercd klipper
3. Setup python-venv
python3 -m venv venvsource venv/bin/activate
4. Install Dependencies
./venv/bin/python -m pip install — upgrade pip
./venv/bin/pip install -r scripts/klippy-requirements.txt
5. Create runsv service(runit) direcotry and file
sudo mkdir /etc/sv/klippersudo touch /etc/sv/klipper/runsudo chmod +x /etc/sv/klipper/run
6. Edit the file `/etc/sv/klipper/run`
#!/bin/bashexport USER=piexport HOME=/home/pigroups=”$(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
7. Enable klipper
sudo ln -srv /etc/sv/klipper /var/service
8. 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.
All of the dependencies got installed in the Klipper install, so this is pretty simple.
1. make the directory
cd ~mkdir OctoPrint && cd OctoPrint
2. Setup Python3 venv
python3 -m venv venvsource venv/bin/activate
3. Install Octoprint
./venv/bin/pip install pip — upgrade./venv/bin/pip install octoprint
4. Create runsv service(runit) direcotry and file
sudo mkdir /etc/sv/octoprintsudo touch /etc/sv/octoprint/runsudo chmod +x /etc/sv/octoprint/run
5. Edit the file `/etc/sv/octoprint/run`
#!/bin/bashexport USER=piexport HOME=/home/pigroups=”$(id -Gn “$USER” | tr ‘ ‘ ‘:’)”exec chpst -u “$USER:$groups” “$HOME”/OctoPrint/venv/bin/octoprint serve
6. 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.
1. Install some things
sudo xbps-install subversion libjpeg-turbo-devel ffmpegcmake
2. __Get the repo and build it__
git clone https://github.com/jacksonliam/mjpg-streamer.gitcd mjpg-streamer/mjpg-streamer-experimentalexport LD_LIBRARY_PATH=.make
3. __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. And you may need to change that. I just kept trying until feed had video.
You can this will give you a video feed on port `8080`.
4. __Setup Octoprint__
In octoprint goto settings and webcam & timelapse section. In the “Stream URL” section put the http://ip:port/?action=stream, example `http://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, example `http://192.168.0.24:8080/?action=snapshot`
You should know have a video feed.
5. __Setting it up to autostart. first make the files__
sudo mkdir /etc/sv/octocamsudo touch /etc/sv/octocam/runsudo chmod +x /etc/sv/octocam/run
6. __Create a executable file that has the start commad__
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 ~/bintouch ~/bin/octocam_runchmod +x ~/bin/octocam_run
__Next, put the following into the `/home/pi/bin/octocam_run` file__
#!/bin/bashMJPGSTREAMER_HOME=/home/pi/mjpg-streamer/mjpg-streamer-experimentalcamera_options=”-r 640x480 -f 10"pushd $MJPGSTREAMER_HOMELD_LIBRARY_PATH=. ./mjpg_streamer -o “output_http.so -w ./www” -i “input_uvc.so $camera_options -d /dev/video2”popd
7. **Add content to the `/etc/sv/octocam/run` file**
#!/bin/bashexport USER=piexport HOME=/home/pigroups=”$(id -Gn “$USER” | tr ‘ ‘ ‘:’)”exec chpst -u “$USER:$groups” /home/pi/bin/octocam_run
8. **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.
- Klipper Install
- Void Docs
- OcotPrint Help
- And the install scripts from klipper, a few man pages here and there.