Jellyfin Forum
function user inactive - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Development (https://forum.jellyfin.org/f-development)
+--- Forum: Web Development (https://forum.jellyfin.org/f-web-development)
+--- Thread: function user inactive (/t-function-user-inactive)



function user inactive - Jobar - 2024-09-10

Hi,

I just created a function to manage user inactivity during continuous playback. Indeed, if the user is asleep or away, the playback continues indefinitely.
To get around this problem, my script runs a timer and checks that there is no keyboard or mouse event otherwise it resets the timer.
If the time is up, a popup will be displayed to confirm whether or not the user is present.
without a response from the user, this popup appears 30 seconds and redirects Jellyfin to the home page.
This script does not display the popup on the home page and dashboard.

To integrate it, a modification of the index.html page is enough.

There is just the choice of:
- The duration of inactivity chosen: 3 hours by default.
- The duration of the popup: 10 seconds by default.
- translate texts into the language of the user.

 inactive.user.js

JoBar.


RE: function user inactive - GarrettBuckner - 2024-10-01

(2024-09-10, 09:37 AM)Jobar Wrote: Hi,

I just created a function to manage user inactivity during continuous playback. Indeed, if the user is asleep or away, the playback continues indefinitely.
To get around this problem, my script runs a timer and checks that there is no keyboard or mouse event otherwise it resets the timer.
If the time is up, a popup will be displayed to confirm whether or not the user is present.
without a response from the user, this popup appears 30 seconds and redirects Jellyfin to the home page.
This script does not display the popup on the home page and dashboard.

To integrate it, a modification of the index.html page is enough.

There is just the choice of:
- The duration of inactivity chosen: 3 hours by default.
- The duration of the popup: 10 seconds by default.
- translate texts into the language of the user.

 geometry dash meltdowninactive.user.js

JoBar.

Hey there!
So, I just whipped up this function to handle user inactivity during continuous playback. You know how it goes—if someone dozes off or steps away, the playback just keeps going forever. To tackle this, my script sets up a timer that monitors for any keyboard or mouse activity. If there's no activity, it resets the timer. When the timer runs out, a popup appears to check if the user is still around. If they don’t respond, the popup sticks around for 30 seconds before redirecting Jellyfin back to the home page. Oh, and don’t worry, the popup won’t show up on the home page or the dashboard.
Integrating this is pretty simple—just a quick tweak to the index.html page will do the trick. You can also customize a few things: the default inactivity duration is set to 3 hours, and the popup stays on the screen for 10 seconds by default. Plus, you can easily translate the text into the user’s preferred language.
This should make the whole experience a lot smoother! 
Cheers, JoBar.


RE: function user inactive - Jobar - 2024-10-01

The detection is based on keyboard and mouse events. The script does not detect if someone is in front of the screen. 
It activates as soon as Jellyfin is not on its home page.

The delay I chose for the script is 3 hours. 
It can be easily modified via the variable ''var nbminute = 180; // Inactive delay in minutes'' at the beginning of the script.

The events are intercepted through this line of code: ''if (/^on(key|mouse)/.test(key)) {'', you can customize it to choose your events.

The detection of the home page or the Dashboard is done by this line of code: ''if('/home.html' != page && page.includes('/dashboard') === false){''

You can add or remove pages to define on which pages the script should trigger.

Just a heads-up for the home page. 
When the script is executed, if no action is performed, the script redirects to the home page. 
If it is removed from the excluded pages test, the script will loop, and this is not desired in my opinion.

A small note, I’ve only been using Jellyfin for a short time, so I haven't been able to confirm its functionality on all configurations. 
It might not be executed on certain client apps.

I hope I have answered your question.

JoBar.