hide desktop & permissiones
This commit is contained in:
160
VIDEO_PLAYER_SETUP.md
Normal file
160
VIDEO_PLAYER_SETUP.md
Normal file
@@ -0,0 +1,160 @@
|
||||
# Video Player Setup - Always On Top with Hidden Desktop UI
|
||||
|
||||
This setup ensures your video player always starts with a video on boot, stays on top, and hides the desktop UI.
|
||||
|
||||
## What Was Fixed
|
||||
|
||||
### 1. GPIO Access Error
|
||||
- **Problem**: Script required root privileges for GPIO access
|
||||
- **Solution**: Modified script to check for GPIO group membership instead of root privileges
|
||||
- **Result**: Script now runs as regular user with proper GPIO permissions
|
||||
|
||||
### 2. Always Start with Video
|
||||
- **Problem**: Video player might not always start with a video
|
||||
- **Solution**: Added `ensure_video_playing()` method that automatically starts a video if none is playing
|
||||
- **Result**: Video player will always have a video playing, restarting automatically if needed
|
||||
|
||||
### 3. Keep Video On Top
|
||||
- **Problem**: Video might get hidden behind other windows
|
||||
- **Solution**:
|
||||
- Added VLC options for always-on-top behavior
|
||||
- Created `keep_vlc_on_top()` method using wmctrl
|
||||
- Added continuous monitoring to ensure VLC stays on top
|
||||
- **Result**: Video player window always stays on top of other applications
|
||||
|
||||
### 4. Hide Desktop UI
|
||||
- **Problem**: Desktop UI elements visible behind video
|
||||
- **Solution**:
|
||||
- Created `hide_desktop_ui.sh` script to hide panels, icons, and screen savers
|
||||
- Added systemd service to automatically hide UI on boot
|
||||
- Configured autostart entries for desktop environment
|
||||
- **Result**: Clean video-only display with hidden desktop elements
|
||||
|
||||
## Files Modified/Created
|
||||
|
||||
### Modified Files:
|
||||
- `video_player.py` - Fixed GPIO access, added always-on-top functionality
|
||||
- `video-player.service` - Updated to run as pi user instead of root
|
||||
- `video-player-random.service` - Updated to run as pi user instead of root
|
||||
|
||||
### New Files:
|
||||
- `hide_desktop_ui.sh` - Script to hide desktop UI elements
|
||||
- `hide-desktop-ui.service` - Systemd service for hiding desktop UI
|
||||
- `setup_video_player.sh` - Complete setup script
|
||||
- `VIDEO_PLAYER_SETUP.md` - This documentation
|
||||
|
||||
## Installation Instructions
|
||||
|
||||
1. **Run the setup script**:
|
||||
```bash
|
||||
./setup_video_player.sh
|
||||
```
|
||||
|
||||
2. **Log out and log back in** (required for GPIO group changes)
|
||||
|
||||
3. **Place video files** in `/home/pi/Videos/` directory
|
||||
|
||||
4. **Reboot the system** to start all services
|
||||
|
||||
## Manual Commands
|
||||
|
||||
### Start Video Player
|
||||
```bash
|
||||
# Start with default channel
|
||||
sudo systemctl start video-player.service
|
||||
|
||||
# Start with random video
|
||||
sudo systemctl start video-player-random.service
|
||||
```
|
||||
|
||||
### Hide Desktop UI
|
||||
```bash
|
||||
# Hide desktop UI elements
|
||||
./hide_desktop_ui.sh hide
|
||||
|
||||
# Keep VLC on top (runs continuously)
|
||||
./hide_desktop_ui.sh keep-top
|
||||
|
||||
# Do everything (hide UI, start service, keep on top)
|
||||
./hide_desktop_ui.sh all
|
||||
```
|
||||
|
||||
### Check Service Status
|
||||
```bash
|
||||
# Check video player service
|
||||
sudo systemctl status video-player.service
|
||||
|
||||
# Check desktop UI hiding service
|
||||
sudo systemctl status hide-desktop-ui.service
|
||||
|
||||
# View logs
|
||||
sudo journalctl -u video-player.service -f
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### Video Directory
|
||||
- Default: `/home/pi/Videos/`
|
||||
- Supported formats: `.mp4`, `.avi`, `.mkv`, `.mov`, `.wmv`, `.flv`, `.webm`, `.m4v`
|
||||
|
||||
### VLC Options
|
||||
The video player now uses these VLC options for optimal display:
|
||||
- `--fullscreen` - Full screen mode
|
||||
- `--always-on-top` - Keep window on top
|
||||
- `--video-on-top` - Video always on top
|
||||
- `--no-video-title-show` - Hide video title
|
||||
- `--no-audio-display` - Hide audio display
|
||||
- Various `--no-qt-*` options to hide VLC interface elements
|
||||
|
||||
### GPIO Configuration
|
||||
- IR pin: GPIO 18 (configurable in config.json)
|
||||
- User must be in `gpio` group (handled by setup script)
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Video Not Starting
|
||||
1. Check if video files exist in `/home/pi/Videos/`
|
||||
2. Check service status: `sudo systemctl status video-player.service`
|
||||
3. Check logs: `sudo journalctl -u video-player.service -f`
|
||||
|
||||
### GPIO Access Issues
|
||||
1. Ensure user is in gpio group: `groups $USER`
|
||||
2. If not, run: `sudo usermod -a -G gpio $USER` and log out/in
|
||||
|
||||
### Desktop UI Still Visible
|
||||
1. Check if hide-desktop-ui service is running: `sudo systemctl status hide-desktop-ui.service`
|
||||
2. Manually hide UI: `./hide_desktop_ui.sh hide`
|
||||
3. Install wmctrl if missing: `sudo apt install wmctrl`
|
||||
|
||||
### VLC Not Staying On Top
|
||||
1. Install wmctrl: `sudo apt install wmctrl`
|
||||
2. Check if VLC is running: `pgrep vlc`
|
||||
3. Manually keep on top: `./hide_desktop_ui.sh keep-top`
|
||||
|
||||
## Service Management
|
||||
|
||||
### Enable Services (start on boot)
|
||||
```bash
|
||||
sudo systemctl enable video-player.service
|
||||
sudo systemctl enable hide-desktop-ui.service
|
||||
```
|
||||
|
||||
### Disable Services
|
||||
```bash
|
||||
sudo systemctl disable video-player.service
|
||||
sudo systemctl disable hide-desktop-ui.service
|
||||
```
|
||||
|
||||
### Stop Services
|
||||
```bash
|
||||
sudo systemctl stop video-player.service
|
||||
sudo systemctl stop hide-desktop-ui.service
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- The video player will automatically restart if it crashes
|
||||
- Videos will loop automatically when they end
|
||||
- The system will always ensure a video is playing
|
||||
- Desktop UI elements are hidden but can be restored by stopping the hide-desktop-ui service
|
||||
- IR remote control functionality is preserved and enhanced
|
||||
23
hide-desktop-ui.service
Normal file
23
hide-desktop-ui.service
Normal file
@@ -0,0 +1,23 @@
|
||||
[Unit]
|
||||
Description=Hide Desktop UI for Video Player
|
||||
After=graphical-session.target
|
||||
Wants=graphical-session.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=pi
|
||||
Group=pi
|
||||
WorkingDirectory=/home/pi/ulivision-tv
|
||||
ExecStart=/home/pi/ulivision-tv/hide_desktop_ui.sh hide
|
||||
Restart=no
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
SyslogIdentifier=hide-desktop-ui
|
||||
|
||||
# Environment variables
|
||||
Environment=DISPLAY=:0
|
||||
Environment=XAUTHORITY=/home/pi/.Xauthority
|
||||
Environment=HOME=/home/pi
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
88
hide_desktop_ui.sh
Executable file
88
hide_desktop_ui.sh
Executable file
@@ -0,0 +1,88 @@
|
||||
#!/bin/bash
|
||||
# Script to hide desktop UI and ensure video player is always on top
|
||||
|
||||
# Function to hide desktop elements
|
||||
hide_desktop_ui() {
|
||||
echo "Hiding desktop UI elements..."
|
||||
|
||||
# Hide taskbar/panel (works with most desktop environments)
|
||||
pkill -f "lxpanel" 2>/dev/null || true
|
||||
pkill -f "xfce4-panel" 2>/dev/null || true
|
||||
pkill -f "gnome-panel" 2>/dev/null || true
|
||||
pkill -f "mate-panel" 2>/dev/null || true
|
||||
|
||||
# Hide desktop icons
|
||||
gsettings set org.gnome.desktop.background show-desktop-icons false 2>/dev/null || true
|
||||
gsettings set org.nemo.desktop show-desktop-icons false 2>/dev/null || true
|
||||
|
||||
# Disable screen saver and power management
|
||||
xset s off 2>/dev/null || true
|
||||
xset -dpms 2>/dev/null || true
|
||||
xset s noblank 2>/dev/null || true
|
||||
|
||||
# Disable mouse cursor after 5 seconds of inactivity
|
||||
unclutter -idle 5 -root 2>/dev/null || true
|
||||
|
||||
echo "Desktop UI elements hidden"
|
||||
}
|
||||
|
||||
# Function to ensure VLC stays on top
|
||||
keep_vlc_on_top() {
|
||||
echo "Ensuring VLC stays on top..."
|
||||
|
||||
# Wait for VLC to start
|
||||
sleep 10
|
||||
|
||||
# Use wmctrl to keep VLC on top
|
||||
while true; do
|
||||
if pgrep -f "vlc" > /dev/null; then
|
||||
wmctrl -r "VLC media player" -b add,above 2>/dev/null || true
|
||||
wmctrl -r "vlc" -b add,above 2>/dev/null || true
|
||||
fi
|
||||
sleep 5
|
||||
done
|
||||
}
|
||||
|
||||
# Function to start video player service
|
||||
start_video_player() {
|
||||
echo "Starting video player service..."
|
||||
|
||||
# Add user to gpio group if not already added
|
||||
if ! groups $USER | grep -q gpio; then
|
||||
echo "Adding user to gpio group..."
|
||||
sudo usermod -a -G gpio $USER
|
||||
echo "Please log out and log back in for GPIO group changes to take effect"
|
||||
fi
|
||||
|
||||
# Start the video player service
|
||||
sudo systemctl enable video-player.service
|
||||
sudo systemctl start video-player.service
|
||||
|
||||
echo "Video player service started"
|
||||
}
|
||||
|
||||
# Main execution
|
||||
case "$1" in
|
||||
"hide")
|
||||
hide_desktop_ui
|
||||
;;
|
||||
"keep-top")
|
||||
keep_vlc_on_top
|
||||
;;
|
||||
"start")
|
||||
start_video_player
|
||||
;;
|
||||
"all")
|
||||
hide_desktop_ui
|
||||
start_video_player
|
||||
keep_vlc_on_top &
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {hide|keep-top|start|all}"
|
||||
echo " hide - Hide desktop UI elements"
|
||||
echo " keep-top - Keep VLC on top (runs continuously)"
|
||||
echo " start - Start video player service"
|
||||
echo " all - Do everything (hide UI, start service, keep on top)"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
127
setup_video_player.sh
Executable file
127
setup_video_player.sh
Executable file
@@ -0,0 +1,127 @@
|
||||
#!/bin/bash
|
||||
# Setup script for video player with always-on-top and hidden desktop UI
|
||||
|
||||
set -e
|
||||
|
||||
echo "Setting up video player for always-on-top operation..."
|
||||
|
||||
# Check if running as root
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
echo "Please run this script as a regular user, not as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Install required packages
|
||||
echo "Installing required packages..."
|
||||
sudo apt update
|
||||
sudo apt install -y wmctrl unclutter vlc python3-vlc python3-pip python3-venv
|
||||
|
||||
# Install Python dependencies
|
||||
echo "Installing Python dependencies..."
|
||||
pip3 install --user RPi.GPIO python-dotenv psutil
|
||||
|
||||
# Add user to gpio group
|
||||
echo "Adding user to gpio group..."
|
||||
sudo usermod -a -G gpio $USER
|
||||
|
||||
# Copy service files to systemd directory
|
||||
echo "Installing systemd services..."
|
||||
sudo cp video-player.service /etc/systemd/system/
|
||||
sudo cp video-player-random.service /etc/systemd/system/
|
||||
sudo cp hide-desktop-ui.service /etc/systemd/system/
|
||||
|
||||
# Reload systemd
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
# Enable services
|
||||
echo "Enabling services..."
|
||||
sudo systemctl enable hide-desktop-ui.service
|
||||
sudo systemctl enable video-player.service
|
||||
|
||||
# Create video directory if it doesn't exist
|
||||
VIDEO_DIR="/home/$USER/Videos"
|
||||
if [ ! -d "$VIDEO_DIR" ]; then
|
||||
echo "Creating video directory: $VIDEO_DIR"
|
||||
mkdir -p "$VIDEO_DIR"
|
||||
fi
|
||||
|
||||
# Create default config if it doesn't exist
|
||||
if [ ! -f "config.json" ]; then
|
||||
echo "Creating default configuration..."
|
||||
python3 video_player.py --list-channels > /dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
# Set up autostart for desktop environment
|
||||
echo "Setting up desktop autostart..."
|
||||
AUTOSTART_DIR="/home/$USER/.config/autostart"
|
||||
mkdir -p "$AUTOSTART_DIR"
|
||||
|
||||
# Create autostart entry for hiding desktop UI
|
||||
cat > "$AUTOSTART_DIR/hide-desktop-ui.desktop" << EOF
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Hide Desktop UI
|
||||
Comment=Hide desktop UI for video player
|
||||
Exec=/home/$USER/ulivision-tv/hide_desktop_ui.sh hide
|
||||
Hidden=false
|
||||
NoDisplay=false
|
||||
X-GNOME-Autostart-enabled=true
|
||||
EOF
|
||||
|
||||
# Create autostart entry for keeping VLC on top
|
||||
cat > "$AUTOSTART_DIR/keep-vlc-on-top.desktop" << EOF
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Keep VLC On Top
|
||||
Comment=Keep VLC media player on top
|
||||
Exec=/home/$USER/ulivision-tv/hide_desktop_ui.sh keep-top
|
||||
Hidden=false
|
||||
NoDisplay=false
|
||||
X-GNOME-Autostart-enabled=true
|
||||
EOF
|
||||
|
||||
# Configure desktop environment to start video player
|
||||
echo "Configuring desktop environment..."
|
||||
|
||||
# Disable screen saver and power management
|
||||
cat > "/home/$USER/.xprofile" << EOF
|
||||
# Disable screen saver and power management
|
||||
xset s off
|
||||
xset -dpms
|
||||
xset s noblank
|
||||
|
||||
# Hide mouse cursor after 5 seconds
|
||||
unclutter -idle 5 -root &
|
||||
|
||||
# Start video player service
|
||||
systemctl --user start video-player.service 2>/dev/null || true
|
||||
EOF
|
||||
|
||||
# Make scripts executable
|
||||
chmod +x hide_desktop_ui.sh
|
||||
chmod +x setup_video_player.sh
|
||||
|
||||
echo ""
|
||||
echo "Setup complete! Here's what was configured:"
|
||||
echo "1. Installed required packages (wmctrl, unclutter, vlc, python3-vlc)"
|
||||
echo "2. Added user to gpio group (requires logout/login to take effect)"
|
||||
echo "3. Installed systemd services for video player and desktop UI hiding"
|
||||
echo "4. Created autostart entries for desktop environment"
|
||||
echo "5. Configured screen saver and power management settings"
|
||||
echo ""
|
||||
echo "To complete the setup:"
|
||||
echo "1. Log out and log back in (for GPIO group changes)"
|
||||
echo "2. Place video files in: $VIDEO_DIR"
|
||||
echo "3. Reboot the system to start all services"
|
||||
echo ""
|
||||
echo "To start the video player manually:"
|
||||
echo " sudo systemctl start video-player.service"
|
||||
echo ""
|
||||
echo "To start with random videos:"
|
||||
echo " sudo systemctl start video-player-random.service"
|
||||
echo ""
|
||||
echo "To hide desktop UI manually:"
|
||||
echo " ./hide_desktop_ui.sh hide"
|
||||
echo ""
|
||||
echo "To keep VLC on top:"
|
||||
echo " ./hide_desktop_ui.sh keep-top"
|
||||
@@ -6,10 +6,10 @@ Wants=graphical-session.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
Group=root
|
||||
WorkingDirectory=/opt/video_player
|
||||
ExecStart=/opt/video_player/venv/bin/python /opt/video_player/video_player.py --random
|
||||
User=pi
|
||||
Group=pi
|
||||
WorkingDirectory=/home/pi/ulivision-tv
|
||||
ExecStart=/usr/bin/python3 /home/pi/ulivision-tv/video_player.py --random
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
@@ -20,7 +20,8 @@ SyslogIdentifier=video-player-random
|
||||
# Environment variables
|
||||
Environment=DISPLAY=:0
|
||||
Environment=XAUTHORITY=/home/pi/.Xauthority
|
||||
Environment=PYTHONPATH=/opt/video_player
|
||||
Environment=PYTHONPATH=/home/pi/ulivision-tv
|
||||
Environment=HOME=/home/pi
|
||||
|
||||
# Security settings
|
||||
NoNewPrivileges=false
|
||||
|
||||
@@ -6,10 +6,10 @@ Wants=graphical-session.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
Group=root
|
||||
WorkingDirectory=/opt/video_player
|
||||
ExecStart=/opt/video_player/venv/bin/python /opt/video_player/video_player.py
|
||||
User=pi
|
||||
Group=pi
|
||||
WorkingDirectory=/home/pi/ulivision-tv
|
||||
ExecStart=/usr/bin/python3 /home/pi/ulivision-tv/video_player.py
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
@@ -20,7 +20,8 @@ SyslogIdentifier=video-player
|
||||
# Environment variables
|
||||
Environment=DISPLAY=:0
|
||||
Environment=XAUTHORITY=/home/pi/.Xauthority
|
||||
Environment=PYTHONPATH=/opt/video_player
|
||||
Environment=PYTHONPATH=/home/pi/ulivision-tv
|
||||
Environment=HOME=/home/pi
|
||||
|
||||
# Security settings
|
||||
NoNewPrivileges=false
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user