Systemd démarrage automatique d'application graphique

Bonjour à toutes et à tous,

Context

J’ai créé un service sous Linux (Debian 12) qui permet de lancer automatiquement le clavier virtuel Onboard. Le PC est un ordinateur virtualisé où un seul utilisateur s’y trouve avec les droit sudo. Le clavier démarre avec la commande onboard mais avec les message d’erreur :

WARNING Config: mousetweaks GSettings schema not found, mousetweaks integration disabled.
WARNING Onboard.XInput: Failed to create osk.Devices: not an X display
WARNING TouchInput: XInput event source failed to initialize, falling back to GTK.
WARNING Onboard.Keyboard: XInput click simulator CSFloatingSlave unavailable, falling back to CSButtonMapper.
WARNING TouchInput: XInput event source failed to initialize, falling back to GTK.

Le service est défini comme suit :

[Unit]
Description=Onboard Service
After=network.target

[Service]
User=user
Environment="DISPLAY=:0"
ExecStart=/bin/onboard
Restart=always
RestartSec=3

[Install]
WantedBy=default.target

Problème :

Le clavier virtuel onboard ne se lance pas lors de l’activation du service et lorsque que l’on fait :

journalctl -u onboard on obtient les message d’erreur :

bian-default systemd[1]: onboard.service: Failed with result ‹ exit-code ›.
debian-default systemd[1]: onboard.service: Scheduled restart job, restart counter is at 1.
debian-default systemd[1]: Stopped onboard.service - onboard Service.
debian-default systemd[1]: Started onboard.service - onboard Service.
debian-default onboard[3505]: Authorization required, but no authorization protocol specified
debian-default onboard[3505]: Authorization required, but no authorization protocol specified
debian-default onboard[3505]: Authorization required, but no authorization protocol specified
debian-default onboard[3505]: cannot open display:

PS1: L’objectif final n’est pas de démarré le logiciel automatiquement sur debian mais sur raspberry pi qui n’a pas de clavier intégré comme Debian.
PS2 : Aucune application graphique ne démarre correctement sur RPI. Je voulais donc vérifié cette fonctionnalité sur debian12.

Merci pour votre lecture.

Pour plus d’information :

user@debian-default:~$ sudo systemctl status onboard
● onboard.service - remmina Service
     Loaded: loaded (/etc/systemd/system/onboard.service; disabled; preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Thu 2024-02-22 23:05:18 CET; 2s ago
    Process: 1196 ExecStart=/bin/onboard (code=exited, status=1/FAILURE)
   Main PID: 1196 (code=exited, status=1/FAILURE)
        CPU: 109ms

févr. 22 23:05:18 debian-default systemd[1]: onboard.service: Main process exited, code=exited, status=1/FAILURE
févr. 22 23:05:18 debian-default systemd[1]: onboard.service: Failed with result 'exit-code'.

user@debian-default:/etc/systemd/system$ ls -la
total 52
drwxr-xr-x 12 root root 4096 22 févr. 22:41 .
drwxr-xr-x  5 root root 4096 22 déc.  23:33 ..
...
-rwxrwxrwx  1 root root  188 22 févr. 22:41 onboard.service
...

Autre test réalisé :

  • onboard remplacé par remmina : même erreur

Sur rpi : Le message d’erreur est :

 raspberrypi systemd[1]: /etc/systemd/system/onboard.service:1: Unknown section 'unit'. Ignoring.
 raspberrypi systemd[1]: Started onboard.service.
 raspberrypi onboard[11628]: 19:34:38.053 WARNING OnboardGtk: D-Bus session bus unavailable  Onboard will>
 raspberrypi onboard[11628]: 19:34:38.072 WARNING Config: mousetweaks GSettings schema not found, mousetw>
 raspberrypi onboard[11628]: 19:34:38.263 WARNING HardwareSensorTracker: Failed to connect to acpid, SW_T>
 raspberrypi onboard[11628]: Traceback (most recent call last):
 raspberrypi onboard[11628]:   File "/usr/bin/onboard", line 36, in <module>
 raspberrypi onboard[11628]:     ob = Onboard()
 raspberrypi onboard[11628]:   File "/usr/lib/python3/dist-packages/Onboard/OnboardGtk.py", line 148, in >
 raspberrypi onboard[11628]:     self.init()
 raspberrypi onboard[11628]:   File "/usr/lib/python3/dist-packages/Onboard/OnboardGtk.py", line 189, in >
 raspberrypi onboard[11628]:     self._init_delayed()
 raspberrypi onboard[11628]:   File "/usr/lib/python3/dist-packages/Onboard/OnboardGtk.py", line 270, in >
 raspberrypi onboard[11628]:     self.service_keyboard = ServiceOnboardKeyboard(self)
 raspberrypi onboard[11628]:   File "/usr/lib/python3/dist-packages/Onboard/OnboardGtk.py", line 854, in >
 raspberrypi onboard[11628]:     ServiceBase.__init__(self, dbus.SessionBus(), self.NAME, self.PATH)
 raspberrypi onboard[11628]:   File "/usr/lib/python3/dist-packages/dbus/_dbus.py", line 212, in __new__
 raspberrypi onboard[11628]:     return Bus.__new__(cls, Bus.TYPE_SESSION, private=private,
 raspberrypi onboard[11628]:   File "/usr/lib/python3/dist-packages/dbus/_dbus.py", line 102, in __new__
 raspberrypi onboard[11628]:     bus = BusConnection.__new__(subclass, bus_type, mainloop=mainloop)
 raspberrypi onboard[11628]:   File "/usr/lib/python3/dist-packages/dbus/bus.py", line 124, in __new__
 raspberrypi onboard[11628]:     bus = cls._new_for_bus(address_or_type, mainloop=mainloop)
 raspberrypi onboard[11628]: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.FileNotFound: Fail>
 raspberrypi systemd[1]: onboard.service: Main process exited, code=exited, status=1/FAILURE
raspberrypi systemd[1]: onboard.service: Failed with result 'exit-code'.
raspberrypi systemd[1]: onboard.service: Consumed 1.134s CPU time.
raspberrypi systemd[1]: onboard.service: Scheduled restart job, restart counter is at 1.
raspberrypi systemd[1]: Stopped onboard.service