From eeb8a78741febe9d37ee5981c417147fd85aea55 Mon Sep 17 00:00:00 2001 From: Ryosuke <88011751+nrysk@users.noreply.github.com> Date: Sun, 9 Nov 2025 00:39:17 +0900 Subject: [PATCH] feat: Add three command bar actions for switching the Light/Dark Mode, p=#11122 --- src/zen/urlbar/ZenUBGlobalActions.sys.mjs | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/zen/urlbar/ZenUBGlobalActions.sys.mjs b/src/zen/urlbar/ZenUBGlobalActions.sys.mjs index 5f09607d4..12d288346 100644 --- a/src/zen/urlbar/ZenUBGlobalActions.sys.mjs +++ b/src/zen/urlbar/ZenUBGlobalActions.sys.mjs @@ -2,6 +2,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +import { XPCOMUtils } from 'resource://gre/modules/XPCOMUtils.sys.mjs'; + +const lazy = {}; + +XPCOMUtils.defineLazyPreferenceGetter(lazy, 'currentTheme', 'zen.view.window.scheme', 2); + function isNotEmptyTab(window) { return !window.gBrowser.selectedTab.hasAttribute('zen-empty-tab'); } @@ -153,6 +159,30 @@ const globalActionsTemplate = [ command: 'Tools:Addons', icon: 'chrome://browser/skin/zen-icons/extension.svg', }, + { + label: 'Switch to Automatic Appearance', + command: () => Services.prefs.setIntPref('zen.view.window.scheme', 2), + icon: 'chrome://browser/skin/zen-icons/sparkles.svg', + isAvailable: () => { + return lazy.currentTheme !== 2; + }, + }, + { + label: 'Switch to Light Mode', + command: () => Services.prefs.setIntPref('zen.view.window.scheme', 1), + icon: 'chrome://browser/skin/zen-icons/face-sun.svg', + isAvailable: () => { + return lazy.currentTheme !== 1; + }, + }, + { + label: 'Switch to Dark Mode', + command: () => Services.prefs.setIntPref('zen.view.window.scheme', 0), + icon: 'chrome://browser/skin/zen-icons/moon-stars.svg', + isAvailable: () => { + return lazy.currentTheme !== 0; + }, + }, ]; export const globalActions = globalActionsTemplate.map((action) => ({