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 2 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
10 changes: 8 additions & 2 deletions src/scripts/screensavermanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ 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;
const timeSeconds = userSettings.get('screensaverTime', false);
// If it is zero or undefined
if (!timeSeconds) {
// Defaults to 3 minutes
return 180000;
}
return timeSeconds * 1000;
ethanarns marked this conversation as resolved.
Show resolved Hide resolved
}

let lastFunctionalEvent = 0;
Expand Down Expand Up @@ -129,7 +135,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-gb.json
Original file line number Diff line number Diff line change
Expand Up @@ -1769,6 +1769,8 @@
"ListView": "List View",
"LabelBackdropScreensaverInterval": "Backdrop Screensaver Interval",
"LabelBackdropScreensaverIntervalHelp": "The time in seconds between different backdrops when using the backdrop screensaver.",
"LabelScreensaverTimeHelp": "The amount of time in seconds of inactivity required to start the screensaver.",
ethanarns marked this conversation as resolved.
Show resolved Hide resolved
"LabelScreensaverTime": "Screensaver Time",
"AiTranslated": "AI Translated",
"MachineTranslated": "Machine Translated",
"ForeignPartsOnly": "Forced/Foreign parts only",
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 @@ -599,6 +599,8 @@
"LabelBaseUrlHelp": "Add a custom subdirectory to the server URL. For example: <code>http://example.com/<b>&lt;baseurl&gt;</b></code>",
"LabelBackdropScreensaverInterval": "Backdrop Screensaver Interval",
"LabelBackdropScreensaverIntervalHelp": "The time in seconds between different backdrops when using the backdrop screensaver.",
"LabelScreensaverTimeHelp": "The amount of time in seconds of inactivity required to start the screensaver.",
"LabelScreensaverTime": "Screensaver Time",
ethanarns marked this conversation as resolved.
Show resolved Hide resolved
"LabelBindToLocalNetworkAddress": "Bind to local network address",
"LabelBindToLocalNetworkAddressHelp": "Override the local IP address for the HTTP server. If left empty, the server will bind to all available addresses. Changing this value requires a restart.",
"LabelBirthDate": "Birth date",
Expand Down
Loading