Skip to content

Commit

Permalink
Add option to control how long the screensaver takes to start (jellyf…
Browse files Browse the repository at this point in the history
…in#6165)

* Added option to control how long the screensaver takes to start

* ESLint fixes

* Requested pull request fixes

* Alphabetized the translation string placement

* Simplified getter
  • Loading branch information
ethanarns authored and kevgrig committed Jan 7, 2025
1 parent 1b03ac5 commit 378a856
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/components/displaySettings/displaySettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ function loadForm(context, user, userSettings) {
if (appHost.supports('screensaver')) {
context.querySelector('.selectScreensaverContainer').classList.remove('hide');
context.querySelector('.txtBackdropScreensaverIntervalContainer').classList.remove('hide');
context.querySelector('.txtScreensaverTimeContainer').classList.remove('hide');
} else {
context.querySelector('.selectScreensaverContainer').classList.add('hide');
context.querySelector('.txtBackdropScreensaverIntervalContainer').classList.add('hide');
context.querySelector('.txtScreensaverTimeContainer').classList.add('hide');
}

if (datetime.supportsLocalization()) {
Expand All @@ -108,6 +110,7 @@ function loadForm(context, user, userSettings) {
loadScreensavers(context, userSettings);

context.querySelector('#txtBackdropScreensaverInterval').value = userSettings.backdropScreensaverInterval();
context.querySelector('#txtScreensaverTime').value = userSettings.screensaverTime();

context.querySelector('.chkDisplayMissingEpisodes').checked = user.Configuration.DisplayMissingEpisodes || false;

Expand Down Expand Up @@ -152,6 +155,7 @@ function saveUser(context, user, userSettingsInstance, apiClient) {
userSettingsInstance.dashboardTheme(context.querySelector('#selectDashboardTheme').value);
userSettingsInstance.screensaver(context.querySelector('.selectScreensaver').value);
userSettingsInstance.backdropScreensaverInterval(context.querySelector('#txtBackdropScreensaverInterval').value);
userSettingsInstance.screensaverTime(context.querySelector('#txtScreensaverTime').value);

userSettingsInstance.libraryPageSize(context.querySelector('#txtLibraryPageSize').value);

Expand Down
6 changes: 6 additions & 0 deletions src/components/displaySettings/displaySettings.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ <h2 class="sectionTitle">
<select is="emby-select" class="selectScreensaver" label="${LabelScreensaver}"></select>
</div>

<div class="inputContainer hide txtScreensaverTimeContainer inputContainer-withDescription">
<input is="emby-input" type="number" id="txtScreensaverTime" pattern="[0-9]*" required="required" min="5" max="86400" step="1"
label="${LabelScreensaverTime}" />
<div class="fieldDescription">${LabelScreensaverTimeHelp}</div>
</div>

<div class="inputContainer hide txtBackdropScreensaverIntervalContainer inputContainer-withDescription">
<input is="emby-input" type="number" id="txtBackdropScreensaverInterval" pattern="[0-9]*" required="required" min="1" max="3600" step="1" label="${LabelBackdropScreensaverInterval}" />
<div class="fieldDescription">${LabelBackdropScreensaverIntervalHelp}</div>
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/screensavermanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import './screensavermanager.scss';
function getMinIdleTime() {
// Returns the minimum amount of idle time required before the screen saver can be displayed
//time units used Millisecond
return 180000;
return userSettings.screensaverTime() * 1000;
}

let lastFunctionalEvent = 0;
Expand Down Expand Up @@ -129,7 +129,7 @@ function ScreenSaverManager() {
this.show();
};

setInterval(onInterval, 10000);
setInterval(onInterval, 5000);
}

export default new ScreenSaverManager;
14 changes: 14 additions & 0 deletions src/scripts/settings/userSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,19 @@ export class UserSettings {
return parseInt(this.get('backdropScreensaverInterval', false), 10) || 5;
}

/**
* Get or set the amount of time it takes to activate the screensaver in seconds. Default 3 minutes.
* @param {number|undefined} [val] - The amount of time it takes to activate the screensaver in seconds.
* @return {number} The amount of time it takes to activate the screensaver in seconds.
*/
screensaverTime(val) {
if (val !== undefined) {
return this.set('screensaverTime', val.toString(), false);
}

return parseInt(this.get('screensaverTime', false), 10) || 180;
}

/**
* Get or set library page size.
* @param {number|undefined} [val] - Library page size.
Expand Down Expand Up @@ -650,6 +663,7 @@ export const skin = currentSettings.skin.bind(currentSettings);
export const theme = currentSettings.theme.bind(currentSettings);
export const screensaver = currentSettings.screensaver.bind(currentSettings);
export const backdropScreensaverInterval = currentSettings.backdropScreensaverInterval.bind(currentSettings);
export const screensaverTime = currentSettings.screensaverTime.bind(currentSettings);
export const libraryPageSize = currentSettings.libraryPageSize.bind(currentSettings);
export const maxDaysForNextUp = currentSettings.maxDaysForNextUp.bind(currentSettings);
export const enableRewatchingInNextUp = currentSettings.enableRewatchingInNextUp.bind(currentSettings);
Expand Down
2 changes: 2 additions & 0 deletions src/strings/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,8 @@
"LabelSaveTrickplayLocallyHelp": "Saving trickplay images into media folders will put them next to your media for easy migration and access.",
"LabelScheduledTaskLastRan": "Last ran {0}, taking {1}.",
"LabelScreensaver": "Screensaver",
"LabelScreensaverTime": "Screensaver Time",
"LabelScreensaverTimeHelp": "The amount of time in seconds of inactivity required to start the screensaver.",
"LabelSeasonNumber": "Season number",
"LabelSelectFolderGroups": "Automatically group content from the following folders into views such as 'Movies', 'Music' and 'TV'",
"LabelSelectFolderGroupsHelp": "Folders that are unchecked will be displayed by themselves in their own view.",
Expand Down

0 comments on commit 378a856

Please sign in to comment.