Skip to content

Instantly share code, notes, and snippets.

@sryze
Last active February 16, 2023 14:43
Show Gist options
  • Save sryze/b0165b6be080c31d82757e32f698ebd5 to your computer and use it in GitHub Desktop.
Save sryze/b0165b6be080c31d82757e32f698ebd5 to your computer and use it in GitHub Desktop.
A shell script for LibreELEC to automatically stop Kodi playback when the HDMI monitor is disconnected / turned off
#!/bin/sh
# Usage:
# 1. Save the script to /storage/monitor-check.sh
# 2. Execute: chmod +x /storage/monitor-check.sh
# 3. Execute: crontab -e and put in this line (runs this script once a minute):
# * * * * * /storage/monitor-check.sh
# 4. Execute: systemctl restart cron
# 5. Make sure that the cron job is working by checking the journal (journalctl -xe -u cron)
if [ $(cat /sys/class/drm/card0-HDMI-A-1/status 2>/dev/null) = "disconnected" ]; then
kodi-send --action stop
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment