Last active
January 23, 2025 07:29
-
-
Save txhammer68/64d5888bf8822c9d0762533237ad6958 to your computer and use it in GitHub Desktop.
Jellyfin Active Keep Awake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import json | |
import requests | |
import os | |
## Interrupt PC sleep/suspend mode if jellyfin has active viewers | |
## simple check of jellyfin activity log | |
## create a systemd/cron timer once an hour to run this script | |
## if running it will simulate a mouse movement, which will keep the system from entering suspend/sleep mode for another hour | |
## See this thread for background info | |
# https://www.reddit.com/r/jellyfin/comments/zvqmjm/prevent_os_from_sleepinghibernating_while/ | |
# create api token in the dashboard, change below | |
#************* Change command line for desktop environment, gnome or kde plasma ************** | |
# Gnome | |
#cmd='dbus org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSaver.SimulateUserActivity' | |
# KDE Plasma 5 | |
cmd='qdbus org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSaver.SimulateUserActivity' | |
headers = { | |
"accept": "application/json", | |
"Authorization": "Mediabrowser Token=1bfeb0c6120d4f4b852d6c6720c7b21d" | |
} | |
isActive=False | |
url1 = 'http://localhost:8096/Sessions?activeWithinSeconds=90' | |
response = requests.get(url1, headers=headers).json() | |
if(len(response) > 0) : | |
isActive=response[0].get('IsActive',False) | |
if(isActive==True) : | |
os.system(cmd) | |
# print(isActive) | |
exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment