Skip to content

Commit eeb8a78

Browse files
authored
feat: Add three command bar actions for switching the Light/Dark Mode, p=#11122
1 parent c5bc5c7 commit eeb8a78

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/zen/urlbar/ZenUBGlobalActions.sys.mjs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5+
import { XPCOMUtils } from 'resource://gre/modules/XPCOMUtils.sys.mjs';
6+
7+
const lazy = {};
8+
9+
XPCOMUtils.defineLazyPreferenceGetter(lazy, 'currentTheme', 'zen.view.window.scheme', 2);
10+
511
function isNotEmptyTab(window) {
612
return !window.gBrowser.selectedTab.hasAttribute('zen-empty-tab');
713
}
@@ -153,6 +159,30 @@ const globalActionsTemplate = [
153159
command: 'Tools:Addons',
154160
icon: 'chrome://browser/skin/zen-icons/extension.svg',
155161
},
162+
{
163+
label: 'Switch to Automatic Appearance',
164+
command: () => Services.prefs.setIntPref('zen.view.window.scheme', 2),
165+
icon: 'chrome://browser/skin/zen-icons/sparkles.svg',
166+
isAvailable: () => {
167+
return lazy.currentTheme !== 2;
168+
},
169+
},
170+
{
171+
label: 'Switch to Light Mode',
172+
command: () => Services.prefs.setIntPref('zen.view.window.scheme', 1),
173+
icon: 'chrome://browser/skin/zen-icons/face-sun.svg',
174+
isAvailable: () => {
175+
return lazy.currentTheme !== 1;
176+
},
177+
},
178+
{
179+
label: 'Switch to Dark Mode',
180+
command: () => Services.prefs.setIntPref('zen.view.window.scheme', 0),
181+
icon: 'chrome://browser/skin/zen-icons/moon-stars.svg',
182+
isAvailable: () => {
183+
return lazy.currentTheme !== 0;
184+
},
185+
},
156186
];
157187

158188
export const globalActions = globalActionsTemplate.map((action) => ({

0 commit comments

Comments
 (0)