hide desktop & permissiones

This commit is contained in:
2025-09-25 16:48:44 +02:00
parent e0898c2349
commit 8de07d073d
7 changed files with 493 additions and 20 deletions

View File

@@ -81,7 +81,31 @@ class VideoPlayer:
"vlc_options": [
"--fullscreen",
"--no-video-title-show",
"--no-audio-display"
"--no-audio-display",
"--always-on-top",
"--video-on-top",
"--no-embedded-video",
"--no-video-deco",
"--no-qt-fs-controller",
"--no-qt-system-tray",
"--no-qt-notification",
"--no-qt-privacy-ask",
"--no-qt-updates-notif",
"--no-qt-error-dialogs",
"--no-qt-fs-controller",
"--no-qt-video-autosize",
"--no-qt-name-in-title",
"--no-qt-minimal-view",
"--no-qt-bgcone",
"--no-qt-pause-minimized",
"--no-qt-continue",
"--no-qt-recentplay",
"--no-qt-start-minimized",
"--no-qt-system-tray",
"--no-qt-notification",
"--no-qt-privacy-ask",
"--no-qt-updates-notif",
"--no-qt-error-dialogs"
],
"ir_codes": {
"0": "channel_0",
@@ -133,10 +157,22 @@ class VideoPlayer:
self.vlc_instance = vlc.Instance(vlc_options)
self.vlc_player = self.vlc_instance.media_player_new()
# Set fullscreen if specified
# Set fullscreen and always on top
if '--fullscreen' in vlc_options:
self.vlc_player.set_fullscreen(True)
# Force video to stay on top
self.vlc_player.set_xwindow(0) # Use root window
# Set video to always be on top
try:
import subprocess
# Use wmctrl to ensure VLC stays on top
subprocess.run(['wmctrl', '-r', 'VLC media player', '-b', 'add,above'],
capture_output=True, timeout=5)
except:
pass # wmctrl might not be available
self.logger.info("VLC player initialized successfully")
return True
except Exception as e:
@@ -519,14 +555,19 @@ class VideoPlayer:
if not self.start(startup_mode, channel_number, video_index):
return
# Ensure we always have a video playing
self.ensure_video_playing()
try:
while self.running:
# Check if VLC is still running
if self.vlc_player and not self.vlc_player.is_playing():
# If no video is playing and we have a current channel, restart it
if self.current_channel:
self.logger.info("Video stopped, restarting current channel")
self.play_channel(self.current_channel)
# If no video is playing, restart the current channel or play a default one
self.logger.info("Video stopped, ensuring video is playing")
self.ensure_video_playing()
# Keep VLC on top
self.keep_vlc_on_top()
time.sleep(1)
@@ -537,6 +578,30 @@ class VideoPlayer:
finally:
self.cleanup()
def ensure_video_playing(self):
"""Ensure a video is always playing"""
if not self.vlc_player or not self.vlc_player.is_playing():
if self.current_channel and self.current_channel in self.channels:
self.logger.info(f"Restarting current channel {self.current_channel}")
self.play_channel(self.current_channel)
elif self.channels:
# Play the first available channel
first_channel = min(self.channels.keys())
self.logger.info(f"No current channel, playing first available channel {first_channel}")
self.play_channel(first_channel)
else:
self.logger.error("No channels available to play")
def keep_vlc_on_top(self):
"""Keep VLC window on top"""
try:
import subprocess
# Use wmctrl to keep VLC on top
subprocess.run(['wmctrl', '-r', 'VLC media player', '-b', 'add,above'],
capture_output=True, timeout=2)
except:
pass # wmctrl might not be available or VLC window might not exist yet
def cleanup(self):
"""Cleanup resources"""
self.logger.info("Cleaning up...")
@@ -639,10 +704,18 @@ def main():
"""Main entry point"""
args = parse_arguments()
# Check if running as root (needed for GPIO access)
if os.geteuid() != 0:
print("This script must be run as root for GPIO access")
print("Use: sudo python3 video_player.py")
# Check if user is in gpio group (needed for GPIO access)
import grp
try:
gpio_group = grp.getgrnam('gpio')
current_groups = os.getgroups()
if gpio_group.gr_gid not in current_groups:
print("This script requires GPIO access. Please add your user to the gpio group:")
print("sudo usermod -a -G gpio $USER")
print("Then log out and log back in, or run: newgrp gpio")
sys.exit(1)
except KeyError:
print("GPIO group not found. Please ensure your system has GPIO support.")
sys.exit(1)
# Check if another instance is running