Maslow Home Maslow Community Garden Newsletter

Raspberry Pi with KDE Window Manager, Wayland ver

Raspberry Pi running in KDE Window Manager, wayland version

This is a solution, I came up with for running GroundControl or kivy python apps inside an X11 window manager while using a mouse or touchpad. If you are using a touchscreen then running KivyPie is probably the safe choice or running kivypie with the trapped cursor mod that was discussed and uploaded by Kingley in this earlier forum thread.

[Disclaimer] As of this writing I have not yet received my Maslow kit, and I have only been able to perform limited testing on a Raspberry Pi 3b with a bluetooth keyboard and touchpad (Logitech K400R).
Also, be warned you will need to enable the [experimental] GL driver in raspi-config and that the current ‘KDE Window manager wayland version’ being used is considered a [PREVIEW] release.

Disclaimer aside, I have been able to run GroundContol in a windowed environment without any screen lag or the missing cursor problem, as encountered when using KivyPie without a touchscreen.

Raspbian Stretch Lite install

Download Raspbian Lite https://www.raspberrypi.org/downloads/raspbian/
Follow instructions per your OS, to install it on an SD card.

I found this guide very useful for installing various desktop environments in the Raspbian Lite distro.
Raspberry Pi Forums

Boot up your raspberry pi 3 and run the following commands, if you need to setup wifi you can do so with choosing network options in sudo raspi-config

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

Reboot and start raspi-config again. Make the appropriate setting changes for your locale. Choose option 7. Advanced Options and then select A7. GL Driver. You will be given 3 options:

  • G1 (Full KMS)
  • G2 (Fake KMS)
  • G3 Legacy

For this build I choose G1 (Full Kernel Module support). Save and exit out, you will be asked to reboot again.

xserver, kwin-wayland installation

The following commands will pull in and install a large number of packages and may take some time depending on your internet connection, so be patient.

sudo apt-get install --no-install-recommends xserver-xorg
sudo apt-get install --no-install-recommends xinit
sudo apt-get install kwin-wayland konsole kate

After all the packages are installed, you should be able to start the KDE window manager by running:

startx

This will start the KDE Plasma Window Manager running Qt5 libs. Plasma is a full desktop environment, with lots of eye candy.
Unfortuantly, it also uses a lot of resources, probably not what you want for a CNC controller.

Instead, we will run KDE WM without the Plasma desktop environment. With the following command in the shell.

kwin_wayland --xwayland --exit-with-session=konsole

The screen should turn black with a mouse pointer in the center of the screen followed by konsole app.
The --exit-with-session= option lets us gracefully return to a command prompt when closed, otherwise you will have to open another tty and kill the process. The key thing is that running this way only uses 124 Megs of RAM.

As a test you should be able to run glxgears from inside konsole and see achieve a frame rate of 60 fps.

Install Kivy manually

Install the following packages with apt-get and python pip.
[Note] The pip installs here may be newer versions of whats is in the ‘requirements_linux.txt’ and which uses kivy version 1.9.1. the latest stable version is 1.10.0 and we will be compiling the latest developer branch from git based off 1.10.

sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev pkg-config libgl1-mesa-dev libgles2-mesa-dev python-setuptools libgstreamer1.0-dev git-core xclip
sudo apt-get install gstreamer1.0-plugins-{bad,base,good,ugly}
sudo apt-get install gstreamer1.0-{omx,alsa} python-dev libmtdev-dev
sudo apt-get install python-pip libffi-dev
sudo apt install libsdl1.2-dev

sudo pip install -U Cython==0.27.3
sudo pip install pyserial
sudo pip install appdirs
sudo pip install packaging
sudo pip install pyparsing
sudo pip install requests
sudo pip install six
sudo pip install pywayland
sudo apt-get install python-pygame

Download the latest branch of Kivy from Git Hub.

git clone https://github.com/kivy/kivy

cd kivy

Build kivy in place, per the instructions on kivy.org :Note we are adding the USE_WAYLAND flag when running make.

USE_WAYLAND=1 USE_X11=1 make

Compiling kivy can take some time. I did not time it personally, but walked away for 10 or 15 minutes and when I came back it had completed.
Run the following commands to add your kivy development folder path to your .profile.

echo "export PYTHONPATH=$(pwd):\$PYTHONPATH" >> ~/.profile
source ~/.profile

Test kivy with one of the example apps.

cd kivy/examples/demo/pictures

python main.py

If everything is installed properly you should be able to interact with the Pictures app using your mouse or touchpad.

Install and run GroundControl

From your home directory download or clone the GroundControl program.

git clone https://github.com/MaslowCNC/GroundControl.git

Add yourself to the dialout group to allow access to the serial port.

sudo usermod -a -G input,dialout pi

Now start the KDE Window manager.

kwin_wayland --xwayland --exit-with-session=konsole

From inside the konsole terminal app:

cd GroundControl

python main.py

The GroundControl program appears full screen and you should be able to interact with it using your mouse and keyboard. You should also be able to resize the window it runs in!

Install Arduino

Install the Java runtime engine required to run the Arduino IDE.

sudo apt-get install default-jre default-jre-headless

Download the latest arduino IDE from https://www.arduino.cc/
extract the files into your home directory.

tar -xvf arduino-1.8.5-linuxarm.tar.xz

cd arduino-1.8.5

I prefer a portable installation, so instead of running install.sh, I create a folder under the root arduino directory named portable.

mkdir portable

Launch the KDE window manager and konsole terminal app and run the Arduino IDE.

kwin_wayland --xwayland --exit-with-session=konsole

cd arduino-1.8.5

./arduino

This should start the Arduino IDE in small window.

I welcome any feedback, and let me know if you are able to duplicate this or improve upon it.

6 Likes

Great work!

I opted for Ubuntu Mate on the RPI3 and it has been rock solid. I have left it running for weeks without a lock up. Do you own any Arduinos?

Thank you

Thanks, and yes I have an old Arduino Uno board and was able to connect and upload the ‘Blink’ sketch as a simple test. I also have read you informative posts on your experiences with Raspberry Pi and was considering Ubuntu Mate for the OS install.

Just out of curiosity are you enabling the GL drivers in raspi-config or tried running GC with kivy environmental options, for example:. KIVY_WINDOW=sdl2 python main.py or tied to compile with any USE flags?

Thanks

I didn’t enable the GL drivers. I just followed the steps published for Kivy install on Ubuntu. All vanilla on the Kivy side. Good on the Uno, that is where I was going, would you be able to the the IDE to talk to hardware. It sounds like you are up and running well. It seems like KiviPie is hit or miss. I’m glad you got it working. I appreciate your posting you observations.

I do have a stretch install on the GL drivers enabled not related to the Maslow. I have an identical Pi without the GL drivers enabled and the one with is running much slower for me. They are running Wordpress, a Voip server, a python updload server, and SSH.

Let’s keep sharing notes.

Thank you

1 Like

Fantastic! I like that you started with the Lite image and built from there. I always feel dirty starting with a full install then piling on, leaving behind things I don’t need.

Thanks, Well, my goal was to be able to use GroundControl on an Rpi 3 with a regular keyboard and mouse in a stable, low memory footprint , with GL graphics. So, far I’m very pleased with the results, I have a responsive cursor and menus appear to work as they should when interacting with GC, and I never edited .kivy/config.ini

It seems like a bit of bloat to pull in all the dependencies for KDE plasma, my file system is at 3.5 Gigs now, but with a 32G SD card, it’s the least of my worry.

BTW, when I posted this I did not use the USE_X11 flag. So, I may do a recompile, so it can work via remote X11. should be as easy as doing:

cd kivy
make clean
USE_WAYLAND=1 USE_X11=1 make

Watch the code scroll by, or do a 7-minute workout and come back test some more. :slight_smile:

3 Likes

Optional - Running GroundControl inside the LXQt Desktop environment

Good news, if you feel more comfortable in a Desktop environment or just like the option to view PDFs, browse the web, etc, in your shop, there is a light WM named LXQt that can run a nested Wayland compositor with out all the resource requirements of running the KDE Plasma desktop.

sudo apt-get install lxqt-core

After LXQt is installed you should now be able launch the desktop from the shell by typing startxfrom the shell prompt. This should start up the LXQt desktop.

Run a nested Wayland Compositor Window inside X11

Once inside the LXQt desktop launch konsole or another terminal emulator.

export $(dbus-launch)
kwin_wayland --xwayland &

This will start up a nested Wayland compositor with a black screen.
If you wan to run a KDE app with wayland support, you can run something like this from a terminal:
kate --platform wayland &
It should start the application inside the compositor window.

If you want to run an X11 app or GroundControl in the Wayland window, then we need to add a Display variable in front of the executable program, since we are now running two window environments, the Desktop is :0 and the wayland is :1. From the LXQt desktop launch another ‘Konsole’ or a terminal window and type this to start up GroundControl.

cd GroundControl
DISPLAY=:1 python main.py

GroundControl should start up inside the nested wayland window.


Although this is a neat trick, I still plan on running GroundControl when I am cutting from the compositor launched from the shell as detailed in my first post.

Here are a few programs, I have added to my current desktop.
Install Google Chromium with Raspberry Pi modifications
sudo apt-get install rpi-chromium-mods
Install PDF viewer
sudo apt-get install evince

I welcome any feedback, and let me know if you are able to duplicate this or improve upon it.

3 Likes

Complete noob in linux, i’m just trying to follow the commands. I tried typing this into the terminal in the desktop enviroment (i assume that’s Plasma) But this one gives me an error:
“No backend specified through command line argument, trying auto resolution
FATAL ERROR: could not find backend”

Looks like you may not have xwayland installed, install it and try again.

apt-get install xwayland

Also, I am running it from a shell prompt, not a desktop, but it works either way.

I found this developers blog post very helpful.

Another option is to install weston, it is available in Stretch and is a small download, I like the small footprint and the fact it has a launcher built in.

1 Like

ok, never mind, i was just blindly following orders. I did the startx, and then entered it in the terminal in plasma. it works when i just enter it in the terminal/shell/the screen you see when you boot the system.

@Dag83

Thanks for the feedback, I’m glad to hear you got it to work. Currently this is my plan A to run GroundControl in a Xwayland window on rpi 3b, with either KDE or the Weston wayland compositor. I also like Weston because it has a nice launcher and can take screenshots or screencasts from Keyboard shortcuts.

I am starting to build my frame and am eagerly awaiting the arrival of my kit. I put together some of my forumn posts into my own github site. Since I can’t actually test on a working Maslow yet, I did not think it wise to add it to the Maslow wiki at this time. If it works as planned or other folks can test it, we can copy it to the Maslow official wiki.

4 Likes