2017-07-18, 15:49
upstart or systemd are very good in running programs in UI. Try the script which I have given above. The main ingredient is to set the appropriate DISPLAY env variable. What is your OS based on systemd or upstart ? @liebezeit
For xfce you can replace lighdm with display-manager
[Unit]
Description = start Kodi
Requires = display-manager.service
PartOf = display-manager.service
[Service]
User = xbmc
Group = xbmc
Environment = DISPLAY=:0.0
ExecStartPre = /bin/sleep 1
ExecStart = /usr/bin/kodi
ExecStop = /usr/bin/pkill -9 kodi.bin
Restart = on-failure
[Install]
WantedBy = multi-user.target
For xfce you can replace lighdm with display-manager
[Unit]
Description = start Kodi
Requires = display-manager.service
PartOf = display-manager.service
[Service]
User = xbmc
Group = xbmc
Environment = DISPLAY=:0.0
ExecStartPre = /bin/sleep 1
ExecStart = /usr/bin/kodi
ExecStop = /usr/bin/pkill -9 kodi.bin
Restart = on-failure
[Install]
WantedBy = multi-user.target