Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to control how long the screensaver takes to start #6165

Merged
merged 6 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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.get('screensaverTime') * 1000;
ethanarns marked this conversation as resolved.
Show resolved Hide resolved
}

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
Loading