|
2 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
|
| 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 | + |
5 | 11 | function isNotEmptyTab(window) { |
6 | 12 | return !window.gBrowser.selectedTab.hasAttribute('zen-empty-tab'); |
7 | 13 | } |
@@ -153,6 +159,30 @@ const globalActionsTemplate = [ |
153 | 159 | command: 'Tools:Addons', |
154 | 160 | icon: 'chrome://browser/skin/zen-icons/extension.svg', |
155 | 161 | }, |
| 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 | + }, |
156 | 186 | ]; |
157 | 187 |
|
158 | 188 | export const globalActions = globalActionsTemplate.map((action) => ({ |
|
0 commit comments