Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8041

Troubleshooting • python script does not launch MPV in fullscreen when started by a desktop file on boot

$
0
0
I making a kiosk, it should play a video when pushing a button.
I'm using the MPV python library (using libmpv2) and lgpio. To use MPV I have to use a venv as well.
I have Raspberry OS Bookworm 64bit 2025-05-13 with Wayland on a rpi 3B+

for the autostart I made a desktop file in ~/.config/autostart

Code:

[Desktop Entry]Type=ApplicationExec=lxterminal -e bash /home/pi/start.sh
the bash script is loading the venv and starting the python script :

Code:

#!/bin/bashcd /home/pi/videoactivate() {. /home/pi/video/venv/bin/activate}activatewhich pythonpython video.py

the python script looks like this :

Code:

import mpvfrom signal import pauseimport RPi.GPIO as GPIOGPIO.setmode(GPIO.BOARD)GPIO.setup(8, GPIO.IN, pull_up_down=GPIO.PUD_UP)def my_callback():    print("Play!")    player.time_pos = 0GPIO.add_event_detect(8, GPIO.FALLING, callback=my_callback, bouncetime=300)player = mpv.MPV()player.fullscreen = Trueplayer.loop = Trueplayer.play('video.mp4')player.wait_for_playback()
if I launch the python script manually, it works, the video is in full screen.
if I launch the bash script manually, it works, the video is in full screen.
if I let the autostart do it when rebooting, the video first appears fullscreen for half a second then place itself in a window on the top left corner of the screen.

What should I do to keep the video fullscreen using the autostart ?

Statistics: Posted by krs — Sun Aug 31, 2025 3:54 pm



Viewing all articles
Browse latest Browse all 8041

Trending Articles