Я настроил правило udev для выполнения сценария оболочки от имени пользователя ( который называется администратором):
Код: Выделить всё
ACTION=="add", RUN+="/bin/su admin -c '/home/admin/Desktop/test/test.sh'"
Код: Выделить всё
#!/bin/bash
python3 /home/admin/Desktop/test/play_vids.py >> /home/admin/Desktop/test/logs.txt 2>&1 || echo "Error executing play_vids.py" >> /home/admin/Desktop/test/logs.txt
Код: Выделить всё
import os
import subprocess
import pyudev
video_dir = "/home/admin/Desktop/test"
video_exts = ['.mp4', '.avi', '.mkv', '.mov']
video_files = [f for f in os.listdir(video_dir) if any(f.endswith(ext) for ext in video_exts)]
video_files.sort()
for video_file in video_files:
subprocess.call(['cvlc', '--fullscreen', os.path.join(video_dir, video_file)])
Код: Выделить всё
[000055565091ff00] vlcpulse audio output error: PulseAudio server connection failure: Connection refused
[0000555650991d80] dbus interface error: Failed to connect to the D-Bus session daemon: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[0000555650991d80] main interface error: no suitable interface module
[000055565084d560] main libvlc error: interface "dbus,none" initialization failed
[000055565095db60] main interface error: no suitable interface module
[000055565084d560] main libvlc error: interface "globalhotkeys,none" initialization failed
[00005556508f2180] dummy interface: using the dummy interface module...
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
[00007ffea8002d20] gles2 generic error: parent window not available
[00007ffea8002d20] xcb generic error: window not available
[00007ffea80013f0] mmal_xsplitter vout display: Try drm
[00007ffea8002d20] drm_vout generic:
Подробнее здесь: [url]https://stackoverflow.com/questions/78355821/udev-rule-fails-to-execute-vlc-command-from-terminal-it-works[/url]