mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-06 01:20:41 +00:00
feat: add startup chime feature
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test (18.x) (push) Has been cancelled
test / test (20.x) (push) Has been cancelled
test / test (22.x) (push) Has been cancelled
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test (18.x) (push) Has been cancelled
test / test (20.x) (push) Has been cancelled
test / test (22.x) (push) Has been cancelled
Added ability to play Puter chime sound at startup after login with a toggle in personalization settings to enable/disable it. ai: true
This commit is contained in:
@@ -48,6 +48,13 @@ export default {
|
||||
<option value="show">${i18n('clock_visible_show')}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="settings-card">
|
||||
<strong style="flex-grow:1;">Startup Sound</strong>
|
||||
<label class="switch">
|
||||
<input type="checkbox" class="startup-chime-toggle">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="settings-card" style="display: block; height: auto;">
|
||||
<strong style="margin: 15px 0 30px; display: block;">${i18n('menubar_style')}</strong>
|
||||
<div style="flex-grow:1; margin-top: 10px;">
|
||||
@@ -102,6 +109,19 @@ export default {
|
||||
|
||||
window.change_clock_visible();
|
||||
|
||||
// Initialize startup chime toggle
|
||||
puter.kv.get('startup_chime_enabled').then(async (val) => {
|
||||
// Default to enabled if not set
|
||||
const enabled = val === 'false' ? false : true;
|
||||
$el_window.find('.startup-chime-toggle').prop('checked', enabled);
|
||||
});
|
||||
|
||||
// Handle startup chime toggle change
|
||||
$el_window.find('.startup-chime-toggle').on('change', function(e) {
|
||||
const enabled = $(this).is(':checked');
|
||||
puter.kv.set('startup_chime_enabled', enabled.toString());
|
||||
});
|
||||
|
||||
puter.kv.get('menubar_style').then(async (val) => {
|
||||
if(val === 'system' || !val){
|
||||
$el_window.find('#menubar_style_system').prop('checked', true);
|
||||
|
||||
@@ -28,6 +28,7 @@ import JustHTML from './Components/JustHTML.js';
|
||||
import StepView from './Components/StepView.js';
|
||||
import Button from './Components/Button.js';
|
||||
import RecoveryCodeEntryView from './Components/RecoveryCodeEntryView.js';
|
||||
import play_startup_chime from '../helpers/play_startup_chime.js';
|
||||
|
||||
async function UIWindowLogin(options){
|
||||
options = options ?? {};
|
||||
|
||||
@@ -30,6 +30,7 @@ import UIWindowProgress from './UI/UIWindowProgress.js';
|
||||
import globToRegExp from "./helpers/globToRegExp.js";
|
||||
import get_html_element_from_options from "./helpers/get_html_element_from_options.js";
|
||||
import item_icon from "./helpers/item_icon.js";
|
||||
import play_startup_chime from "./helpers/play_startup_chime.js";
|
||||
|
||||
window.is_auth = ()=>{
|
||||
if(localStorage.getItem("auth_token") === null || window.auth_token === null)
|
||||
@@ -436,6 +437,11 @@ window.update_auth_data = async (auth_token, user)=>{
|
||||
window.auth_token = auth_token;
|
||||
localStorage.setItem('auth_token', auth_token);
|
||||
|
||||
// Play startup chime if enabled
|
||||
if (typeof play_startup_chime === 'function') {
|
||||
play_startup_chime();
|
||||
}
|
||||
|
||||
// Has username changed?
|
||||
if(window.user?.username !== user.username)
|
||||
update_username_in_gui(user.username);
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright (C) 2024-present Puter Technologies Inc.
|
||||
*
|
||||
* This file is part of Puter.
|
||||
*
|
||||
* Puter is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plays the Puter startup chime sound if enabled in settings
|
||||
* @returns {Promise<void>} A promise that resolves when the sound has played or if playing is skipped
|
||||
*/
|
||||
export default async function play_startup_chime() {
|
||||
try {
|
||||
// Check if startup chime is enabled in settings
|
||||
const startupChimeEnabled = await puter.kv.get('startup_chime_enabled');
|
||||
|
||||
// If explicitly disabled, don't play
|
||||
if (startupChimeEnabled === 'false') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create audio element and play the chime
|
||||
const audio = new Audio('/audio/puter_chime.mp3');
|
||||
await audio.play();
|
||||
} catch (error) {
|
||||
// Silently fail if audio can't be played (common in browsers without user interaction)
|
||||
console.log('Could not play startup chime:', error);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user