0

for a little project I have build a Python UI which should autostart on a Raspberry PI4 that has a DSI touch display connected to it. I'm currently running Raspbian on it but that can be changed if needed.

But I'm not able to get this to work. I found an old post about this problem (How to boot into own python script (GUI) only?) but the solutions don't work for me.

Since "nodm" is deprecated, I installed the newer "lightdm-autologin-greeter" Then I created an .xsession-file with the following content:

#!/usr/bin/env bash
exec openbox-session &
while true; do
  python3 /home/xxx/ui.py
done

and yeah.. No Python UI on my DSI screen. When I log in via RDP, the UI gets shown in the RDP-session instead.. I understood that RDP creates a new Xsession instead of using the existing one so now I'm wondering, why my UI won't start to the DSI screen.

I'm completely new to Xsessions and how Linux handles this so it might be a simple problem. Hope someone can help me out

Grogak
  • 1
  • 1

1 Answers1

0

I don't know if this will help you. I took an old python script and modified it a little and ran some test on my RP 3 in a 7" touch screen and it seem to be what you are asking. I added a first line in $HOME/.profile that has a full path to my /home/pi/bin/dsphost.py. This puts a window on the display as a button which happens before anything else on the screen. Touching the button or mouse click on the button allows the screen to initialize. There are some side effects as the first line in $HOME/.profile needs to be committed out.

#!/usr/bin/env python
# Program name is dsphost.py.

import tkinter as tk

fp = open('/etc/hostname', 'r') hn = fp.read().strip() fp.close()

fp = open('/etc/os-release', 'r') os = ((fp.readline().strip().split())[-1])[1:-2].capitalize() fp.close()

fp = open('/etc/debian_version', 'r') ver = fp.read().strip() fp.close()

data = hn + " " + os + " " + ver

def click(): with open('/home/pi/.profile', 'r+') as fp: fp.seek(0) line = fp.read() fp.seek(0) fp.write('#' + line) exit()

mywindow = tk.Tk() mywindow.geometry("+0+36") tk.Button(text = data, font=("Roboto 14"), command = click).pack() mywindow.overrideredirect(1) mywindow.mainloop()

bstipe
  • 534
  • 3
  • 5