Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display fullscreen jpeg on X Server (of Raspberry Pi) using Python 3

I am developing a software in Python that generates static jpeg files, which are written to the file system. The software ist running at startup and gets triggered by some external and internal events, generates the corresponding jpeg image and should show it in fullscreen on the connected HDMI-screen without any visible user control or menu bar.

There is no window manager (Gnome, KDE, ...) installed and running. The device is a passive one and remotely controlled.

I am currently starting a feh process in order to view an image, and kill it before the next one is shown. It works, but is not very satisfying.

Do you have any better idea how I can get my Python 3 program to display the jpeg on the X Server?

like image 400
muffel Avatar asked Nov 20 '25 22:11

muffel


2 Answers

Do you really need an X-Server? If you don't any GUI or mouse, you may be better writing the pictures into the framebuffers without X-Server. You can simply use fbi for this.

like image 80
Nudin Avatar answered Nov 23 '25 10:11

Nudin


Use feh with one of the --bg- options. This sets the background of the root X window, and then exits. So you don't have to deal with killing feh to restart it, just call the command every time you want to change the image.

feh --bg-scale image1.jpeg

This doesn't work with some desktop environments (kde, gnome, xfce, and others), but will work with lightweight window managers (evilwm, goomwwm, etc.) and will also work with no window manager.

like image 41
ComputerDruid Avatar answered Nov 23 '25 11:11

ComputerDruid



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!