extension.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. import Meta from 'gi://Meta';
  2. import Clutter from 'gi://Clutter';
  3. import * as Main from 'resource:///org/gnome/shell/ui/main.js';
  4. import { Extension } from 'resource:///org/gnome/shell/extensions/extension.js';
  5. import { EffectsManager } from './conveniences/effects_manager.js';
  6. import { Connections } from './conveniences/connections.js';
  7. import { Settings } from './conveniences/settings.js';
  8. import { Keys } from './conveniences/keys.js';
  9. import { PanelBlur } from './components/panel.js';
  10. import { OverviewBlur } from './components/overview.js';
  11. import { DashBlur } from './components/dash_to_dock.js';
  12. import { LockscreenBlur } from './components/lockscreen.js';
  13. import { AppFoldersBlur } from './components/appfolders.js';
  14. import { WindowListBlur } from './components/window_list.js';
  15. import { ApplicationsBlur } from './components/applications.js';
  16. import { ScreenshotBlur } from './components/screenshot.js';
  17. // This lists the components that need to be connected in order to either use
  18. // general sigma/brightness or their own.
  19. const INDEPENDENT_COMPONENTS = [
  20. "overview", "appfolder", "panel", "dash_to_dock", "applications",
  21. "lockscreen", "window_list", "screenshot"
  22. ];
  23. /// The main extension class, created when the GNOME Shell is loaded.
  24. export default class BlurMyShell extends Extension {
  25. /// Enables the extension.
  26. enable() {
  27. // add the extension to global to make it accessible to other extensions
  28. // create it first as it is very useful when debugging crashes
  29. global.blur_my_shell = this;
  30. // create a Settings instance, to manage extension's preferences
  31. // it needs to be loaded before logging, as it checks for DEBUG
  32. this._settings = new Settings(Keys, this.getSettings());
  33. this._log("enabling extension...");
  34. // create main extension Connections instance
  35. this._connection = new Connections;
  36. // store it in a global array
  37. this._connections = [this._connection];
  38. // create a global effects manager (to prevent RAM bleeding)
  39. this._effects_manager = new EffectsManager(this._connection);
  40. // create an instance of each component, with its associated Connections
  41. let init = _ => {
  42. // create a Connections instance, to manage signals
  43. let connection = new Connections;
  44. // store it to keeps track of them globally
  45. this._connections.push(connection);
  46. return [connection, this._settings, this._effects_manager];
  47. };
  48. this._panel_blur = new PanelBlur(...init());
  49. this._dash_to_dock_blur = new DashBlur(...init());
  50. this._overview_blur = new OverviewBlur(...init());
  51. this._lockscreen_blur = new LockscreenBlur(...init());
  52. this._appfolder_blur = new AppFoldersBlur(...init());
  53. this._window_list_blur = new WindowListBlur(...init());
  54. this._applications_blur = new ApplicationsBlur(...init());
  55. this._screenshot_blur = new ScreenshotBlur(...init());
  56. // connect each component to preferences change
  57. this._connect_to_settings();
  58. // enable the lockscreen blur, only one important in both `user` session and `unlock-dialog`
  59. if (this._settings.lockscreen.BLUR && !this._lockscreen_blur.enabled)
  60. this._lockscreen_blur.enable();
  61. // ensure we take the correct action for the current session mode
  62. this._user_session_mode_enabled = false;
  63. this._on_session_mode_changed(Main.sessionMode);
  64. // watch for changes to the session mode
  65. this._connection.connect(Main.sessionMode, 'updated',
  66. _ => this._on_session_mode_changed(Main.sessionMode)
  67. );
  68. }
  69. /// Enables the components related to the user session (everything except lockscreen blur).
  70. _enable_user_session() {
  71. this._log("changing mode to user session...");
  72. // maybe disable clipped redraw
  73. this._update_clipped_redraws();
  74. // enable every component
  75. // if the shell is still starting up, wait for it to be entirely loaded;
  76. // this should prevent bugs like #136 and #137
  77. if (Main.layoutManager._startingUp) {
  78. this._connection.connect(
  79. Main.layoutManager,
  80. 'startup-complete',
  81. this._enable_components.bind(this)
  82. );
  83. } else {
  84. this._enable_components();
  85. }
  86. // try to enable the components as soon as possible anyway, this way the
  87. // overview may load before the user sees it
  88. try {
  89. if (this._settings.overview.BLUR && !this._overview_blur.enabled)
  90. this._overview_blur.enable();
  91. } catch (e) {
  92. this._log("Could not enable overview blur directly");
  93. this._log(e);
  94. }
  95. try {
  96. if (this._settings.dash_to_dock.BLUR
  97. && !this._dash_to_dock_blur.enabled)
  98. this._dash_to_dock_blur.enable();
  99. } catch (e) {
  100. this._log("Could not enable dash-to-dock blur directly");
  101. this._log(e);
  102. }
  103. try {
  104. if (this._settings.panel.BLUR && !this._panel_blur.enabled)
  105. this._panel_blur.enable();
  106. } catch (e) {
  107. this._log("Could not enable panel blur directly");
  108. this._log(e);
  109. }
  110. // tells the extension we have enabled the user session components, so that we do not
  111. // disable them later if they were not even enabled to begin with
  112. this._user_session_mode_enabled = true;
  113. }
  114. /// Disables the extension.
  115. ///
  116. /// This extension needs to use the 'unlock-dialog' session mode in order to change the blur on
  117. /// the lockscreen. We have kind of two states of enablement for this extension:
  118. /// - the 'enabled' state, which means that we have created the necessary components (which only
  119. /// are js objects) and enabled the lockscreen blur (which means swapping two functions from
  120. /// the `UnlockDialog` constructor with our ones;
  121. /// - the 'user session enabled` mode, which means that we are in the 'enabled' mode AND we are
  122. /// in the user mode, and so we enable all the other components that we created before.
  123. /// We switch from one state to the other thanks to `this._on_session_mode_changed`, and we
  124. /// track wether or not we are in the user mode with `this._user_session_mode_enabled` (because
  125. /// `this._on_session_mode_changed` might be called multiple times while in the user session
  126. /// mode, typically when going back from simple lockscreen and not sleep mode).
  127. disable() {
  128. this._log("disabling extension...");
  129. // disable every component from user session mode
  130. if (this._user_session_mode_enabled)
  131. this._disable_user_session();
  132. // disable lockscreen blur too
  133. this._lockscreen_blur.disable();
  134. // untrack them
  135. this._panel_blur = null;
  136. this._dash_to_dock_blur = null;
  137. this._overview_blur = null;
  138. this._appfolder_blur = null;
  139. this._lockscreen_blur = null;
  140. this._window_list_blur = null;
  141. this._applications_blur = null;
  142. this._screenshot_blur = null;
  143. // make sure no settings change can re-enable them
  144. this._settings.disconnect_all_settings();
  145. // force disconnecting every signal, even if component crashed
  146. this._connections.forEach((connections) => {
  147. connections.disconnect_all();
  148. });
  149. this._connections = [];
  150. // remove the clipped redraws flag
  151. this._reenable_clipped_redraws();
  152. // remove the extension from GJS's global
  153. delete global.blur_my_shell;
  154. this._log("extension disabled.");
  155. this._settings = null;
  156. }
  157. /// Disables the components related to the user session (everything except lockscreen blur).
  158. _disable_user_session() {
  159. this._log("disabling user session mode...");
  160. // disable every component except lockscreen blur
  161. this._panel_blur.disable();
  162. this._dash_to_dock_blur.disable();
  163. this._overview_blur.disable();
  164. this._appfolder_blur.disable();
  165. this._window_list_blur.disable();
  166. this._applications_blur.disable();
  167. this._screenshot_blur.disable();
  168. // remove the clipped redraws flag
  169. this._reenable_clipped_redraws();
  170. // tells the extension we have disabled the user session components, so that we do not
  171. // disable them later again if they were already disabled
  172. this._user_session_mode_enabled = false;
  173. }
  174. /// Restarts the components related to the user session.
  175. _restart() {
  176. this._log("restarting...");
  177. this._disable_user_session();
  178. this._enable_user_session();
  179. this._log("restarted.");
  180. }
  181. /// Changes the extension to operate either on 'user' mode or 'unlock-dialog' mode, switching
  182. /// from one to the other means enabling/disabling every component except lockscreen blur.
  183. _on_session_mode_changed(session) {
  184. if (session.currentMode === 'user' || session.parentMode === 'user') {
  185. if (!this._user_session_mode_enabled)
  186. // we need to activate everything
  187. this._enable_user_session();
  188. }
  189. else if (session.currentMode === 'unlock-dialog') {
  190. if (this._user_session_mode_enabled)
  191. // we need to disable the components related to the user session mode
  192. this._disable_user_session();
  193. }
  194. }
  195. /// Add or remove the clutter debug flag to disable clipped redraws.
  196. /// This will entirely fix the blur effect, but should not be used except if
  197. /// the user really needs it, as clipped redraws are a huge performance
  198. /// boost for the compositor.
  199. _update_clipped_redraws() {
  200. if (this._settings.HACKS_LEVEL === 3)
  201. this._disable_clipped_redraws();
  202. else
  203. this._reenable_clipped_redraws();
  204. }
  205. /// Add the Clutter debug flag.
  206. _disable_clipped_redraws() {
  207. Meta.add_clutter_debug_flags(
  208. null, Clutter.DrawDebugFlag.DISABLE_CLIPPED_REDRAWS, null
  209. );
  210. }
  211. /// Remove the Clutter debug flag.
  212. _reenable_clipped_redraws() {
  213. Meta.remove_clutter_debug_flags(
  214. null, Clutter.DrawDebugFlag.DISABLE_CLIPPED_REDRAWS, null
  215. );
  216. }
  217. /// Enables every component from the user session needed, should be called when the shell is
  218. /// entirely loaded as the `enable` methods interact with it.
  219. _enable_components() {
  220. // enable each component if needed, and if it is not already enabled
  221. if (this._settings.panel.BLUR && !this._panel_blur.enabled)
  222. this._panel_blur.enable();
  223. if (this._settings.dash_to_dock.BLUR && !this._dash_to_dock_blur.enabled)
  224. this._dash_to_dock_blur.enable();
  225. if (this._settings.overview.BLUR && !this._overview_blur.enabled)
  226. this._overview_blur.enable();
  227. if (this._settings.appfolder.BLUR)
  228. this._appfolder_blur.enable();
  229. if (this._settings.applications.BLUR)
  230. this._applications_blur.enable();
  231. if (this._settings.window_list.BLUR)
  232. this._window_list_blur.enable();
  233. if (this._settings.screenshot.BLUR)
  234. this._screenshot_blur.enable();
  235. this._log("all components enabled.");
  236. }
  237. /// Updates needed things in each component when a preference changed
  238. _connect_to_settings() {
  239. // global blur values changed, update everybody
  240. this._settings.SIGMA_changed(() => {
  241. this._update_sigma();
  242. });
  243. this._settings.BRIGHTNESS_changed(() => {
  244. this._update_brightness();
  245. });
  246. this._settings.COLOR_changed(() => {
  247. this._update_color();
  248. });
  249. this._settings.NOISE_AMOUNT_changed(() => {
  250. this._update_noise_amount();
  251. });
  252. this._settings.NOISE_LIGHTNESS_changed(() => {
  253. this._update_noise_lightness();
  254. });
  255. this._settings.COLOR_AND_NOISE_changed(() => {
  256. // both updating noise amount and color calls `update_enabled` on
  257. // each color and noise effects
  258. this._update_noise_amount();
  259. this._update_color();
  260. });
  261. // restart the extension when hacks level is changed, easier than
  262. // restarting individual components and should not happen often either
  263. this._settings.HACKS_LEVEL_changed(_ => this._restart());
  264. // connect each component to use the proper sigma/brightness/color
  265. INDEPENDENT_COMPONENTS.forEach(component => {
  266. this._connect_to_individual_settings(component);
  267. });
  268. // other component's preferences changed
  269. // ---------- OVERVIEW ----------
  270. // toggled on/off
  271. this._settings.overview.BLUR_changed(() => {
  272. if (this._settings.overview.BLUR) {
  273. this._overview_blur.enable();
  274. } else {
  275. this._overview_blur.disable();
  276. }
  277. });
  278. // overview components style changed
  279. this._settings.overview.STYLE_COMPONENTS_changed(() => {
  280. if (this._settings.overview.BLUR) {
  281. this._overview_blur.update_components_classname();
  282. }
  283. });
  284. // ---------- APPFOLDER ----------
  285. // toggled on/off
  286. this._settings.appfolder.BLUR_changed(() => {
  287. if (this._settings.appfolder.BLUR) {
  288. this._appfolder_blur.enable();
  289. } else {
  290. this._appfolder_blur.disable();
  291. }
  292. });
  293. // appfolder dialogs style changed
  294. this._settings.appfolder.STYLE_DIALOGS_changed(() => {
  295. if (this._settings.appfolder.BLUR)
  296. this._appfolder_blur.blur_appfolders();
  297. });
  298. // ---------- PANEL ----------
  299. // toggled on/off
  300. this._settings.panel.BLUR_changed(() => {
  301. if (this._settings.panel.BLUR) {
  302. this._panel_blur.enable();
  303. } else {
  304. this._panel_blur.disable();
  305. }
  306. });
  307. this._settings.COLOR_AND_NOISE_changed(() => {
  308. // permits making sure that the blur is not washed out when disabling
  309. // the other effects
  310. if (this._settings.panel.BLUR)
  311. this._panel_blur.invalidate_all_blur();
  312. });
  313. // static blur toggled on/off
  314. this._settings.panel.STATIC_BLUR_changed(() => {
  315. if (this._settings.panel.BLUR)
  316. this._panel_blur.update_all_blur_type();
  317. });
  318. // panel blur's overview connection toggled on/off
  319. this._settings.panel.UNBLUR_IN_OVERVIEW_changed(() => {
  320. this._panel_blur.connect_to_windows_and_overview();
  321. });
  322. // force light text toggled on/off
  323. this._settings.panel.FORCE_LIGHT_TEXT_changed(() => {
  324. if (this._settings.panel.BLUR)
  325. this._panel_blur.update_light_text_classname();
  326. });
  327. // panel override background toggled on/off
  328. this._settings.panel.OVERRIDE_BACKGROUND_changed(() => {
  329. if (this._settings.panel.BLUR)
  330. this._panel_blur.connect_to_windows_and_overview();
  331. });
  332. // panel style changed
  333. this._settings.panel.STYLE_PANEL_changed(() => {
  334. if (this._settings.panel.BLUR)
  335. this._panel_blur.connect_to_windows_and_overview();
  336. });
  337. // panel background's dynamic overriding toggled on/off
  338. this._settings.panel.OVERRIDE_BACKGROUND_DYNAMICALLY_changed(() => {
  339. if (this._settings.panel.BLUR)
  340. this._panel_blur.connect_to_windows_and_overview();
  341. });
  342. // ---------- DASH TO DOCK ----------
  343. // toggled on/off
  344. this._settings.dash_to_dock.BLUR_changed(() => {
  345. if (this._settings.dash_to_dock.BLUR) {
  346. this._dash_to_dock_blur.enable();
  347. } else {
  348. this._dash_to_dock_blur.disable();
  349. }
  350. });
  351. // static blur toggled on/off
  352. this._settings.dash_to_dock.STATIC_BLUR_changed(() => {
  353. if (this._settings.dash_to_dock.BLUR)
  354. this._dash_to_dock_blur.change_blur_type();
  355. });
  356. // dash-to-dock corner radius changed
  357. this._settings.dash_to_dock.CORNER_RADIUS_changed(() => {
  358. if (this._settings.dash_to_dock.STATIC_BLUR)
  359. this._dash_to_dock_blur.set_corner_radius(this._settings.dash_to_dock.CORNER_RADIUS);
  360. });
  361. // dash-to-dock override background toggled on/off
  362. this._settings.dash_to_dock.OVERRIDE_BACKGROUND_changed(() => {
  363. if (this._settings.dash_to_dock.BLUR)
  364. this._dash_to_dock_blur.update_background();
  365. });
  366. // dash-to-dock style changed
  367. this._settings.dash_to_dock.STYLE_DASH_TO_DOCK_changed(() => {
  368. if (this._settings.dash_to_dock.BLUR)
  369. this._dash_to_dock_blur.update_background();
  370. });
  371. // dash-to-dock blur's overview connection toggled on/off
  372. this._settings.dash_to_dock.UNBLUR_IN_OVERVIEW_changed(() => {
  373. if (this._settings.dash_to_dock.BLUR)
  374. this._dash_to_dock_blur.connect_to_overview();
  375. });
  376. // ---------- APPLICATIONS ----------
  377. // toggled on/off
  378. this._settings.applications.BLUR_changed(() => {
  379. if (this._settings.applications.BLUR) {
  380. this._applications_blur.enable();
  381. } else {
  382. this._applications_blur.disable();
  383. }
  384. });
  385. // application opacity changed
  386. this._settings.applications.OPACITY_changed(_ => {
  387. if (this._settings.applications.BLUR)
  388. this._applications_blur.set_opacity(
  389. this._settings.applications.OPACITY
  390. );
  391. });
  392. // application blur-on-overview changed
  393. this._settings.applications.BLUR_ON_OVERVIEW_changed(_ => {
  394. if (this._settings.applications.BLUR)
  395. this._applications_blur.connect_to_overview();
  396. });
  397. // application enable-all changed
  398. this._settings.applications.ENABLE_ALL_changed(_ => {
  399. if (this._settings.applications.BLUR)
  400. this._applications_blur.update_all_windows();
  401. });
  402. // application whitelist changed
  403. this._settings.applications.WHITELIST_changed(_ => {
  404. if (
  405. this._settings.applications.BLUR
  406. && !this._settings.applications.ENABLE_ALL
  407. )
  408. this._applications_blur.update_all_windows();
  409. });
  410. // application blacklist changed
  411. this._settings.applications.BLACKLIST_changed(_ => {
  412. if (
  413. this._settings.applications.BLUR
  414. && this._settings.applications.ENABLE_ALL
  415. )
  416. this._applications_blur.update_all_windows();
  417. });
  418. // ---------- LOCKSCREEN ----------
  419. // toggled on/off
  420. this._settings.lockscreen.BLUR_changed(() => {
  421. if (this._settings.lockscreen.BLUR) {
  422. this._lockscreen_blur.enable();
  423. } else {
  424. this._lockscreen_blur.disable();
  425. }
  426. });
  427. // ---------- WINDOW LIST ----------
  428. // toggled on/off
  429. this._settings.window_list.BLUR_changed(() => {
  430. if (this._settings.window_list.BLUR) {
  431. this._window_list_blur.enable();
  432. } else {
  433. this._window_list_blur.disable();
  434. }
  435. });
  436. // ---------- HIDETOPBAR ----------
  437. // toggled on/off
  438. this._settings.hidetopbar.COMPATIBILITY_changed(() => {
  439. // no need to verify if it is enabled or not, it is done anyway
  440. this._panel_blur.connect_to_windows_and_overview();
  441. });
  442. // ---------- DASH TO PANEL ----------
  443. // toggled on/off
  444. this._settings.dash_to_panel.BLUR_ORIGINAL_PANEL_changed(() => {
  445. if (this._settings.panel.BLUR)
  446. this._panel_blur.reset();
  447. });
  448. // ---------- SCREENSHOT ----------
  449. // toggled on/off
  450. this._settings.screenshot.BLUR_changed(() => {
  451. if (this._settings.screenshot.BLUR) {
  452. this._screenshot_blur.enable();
  453. } else {
  454. this._screenshot_blur.disable();
  455. }
  456. });
  457. }
  458. /// Select the component by its name and connect it to its preferences
  459. /// changes for general values, sigma and brightness.
  460. ///
  461. /// Doing this in such a way is less accessible but prevents a lot of
  462. /// boilerplate and headaches.
  463. _connect_to_individual_settings(name) {
  464. // get component and preferences needed
  465. let component = this['_' + name + '_blur'];
  466. let component_settings = this._settings[name];
  467. // general values switch is toggled
  468. component_settings.CUSTOMIZE_changed(() => {
  469. if (component_settings.CUSTOMIZE) {
  470. component.set_sigma(component_settings.SIGMA);
  471. component.set_brightness(component_settings.BRIGHTNESS);
  472. component.set_color(component_settings.COLOR);
  473. component.set_noise_amount(component_settings.NOISE_AMOUNT);
  474. component.set_noise_lightness(component_settings.NOISE_LIGHTNESS);
  475. }
  476. else {
  477. component.set_sigma(this._settings.SIGMA);
  478. component.set_brightness(this._settings.BRIGHTNESS);
  479. component.set_color(this._settings.COLOR);
  480. component.set_noise_amount(this._settings.NOISE_AMOUNT);
  481. component.set_noise_lightness(this._settings.NOISE_LIGHTNESS);
  482. }
  483. });
  484. // sigma is changed
  485. component_settings.SIGMA_changed(() => {
  486. if (component_settings.CUSTOMIZE)
  487. component.set_sigma(component_settings.SIGMA);
  488. else
  489. component.set_sigma(this._settings.SIGMA);
  490. });
  491. // brightness is changed
  492. component_settings.BRIGHTNESS_changed(() => {
  493. if (component_settings.CUSTOMIZE)
  494. component.set_brightness(component_settings.BRIGHTNESS);
  495. else
  496. component.set_brightness(this._settings.BRIGHTNESS);
  497. });
  498. // color is changed
  499. component_settings.COLOR_changed(() => {
  500. if (component_settings.CUSTOMIZE)
  501. component.set_color(component_settings.COLOR);
  502. else
  503. component.set_color(this._settings.COLOR);
  504. });
  505. // noise amount is changed
  506. component_settings.NOISE_AMOUNT_changed(() => {
  507. if (component_settings.CUSTOMIZE)
  508. component.set_noise_amount(component_settings.NOISE_AMOUNT);
  509. else
  510. component.set_noise_amount(this._settings.NOISE_AMOUNT);
  511. });
  512. // noise lightness is changed
  513. component_settings.NOISE_LIGHTNESS_changed(() => {
  514. if (component_settings.CUSTOMIZE)
  515. component.set_noise_lightness(component_settings.NOISE_LIGHTNESS);
  516. else
  517. component.set_noise_lightness(this._settings.NOISE_LIGHTNESS);
  518. });
  519. }
  520. /// Update each component's sigma value
  521. _update_sigma() {
  522. INDEPENDENT_COMPONENTS.forEach(name => {
  523. // get component and preferences needed
  524. let component = this['_' + name + '_blur'];
  525. let component_settings = this._settings[name];
  526. // update sigma accordingly
  527. if (component_settings.CUSTOMIZE) {
  528. component.set_sigma(component_settings.SIGMA);
  529. }
  530. else {
  531. component.set_sigma(this._settings.SIGMA);
  532. }
  533. });
  534. }
  535. /// Update each component's brightness value
  536. _update_brightness() {
  537. INDEPENDENT_COMPONENTS.forEach(name => {
  538. // get component and preferences needed
  539. let component = this['_' + name + '_blur'];
  540. let component_settings = this._settings[name];
  541. // update brightness accordingly
  542. if (component_settings.CUSTOMIZE)
  543. component.set_brightness(component_settings.BRIGHTNESS);
  544. else
  545. component.set_brightness(this._settings.BRIGHTNESS);
  546. });
  547. }
  548. /// Update each component's color value
  549. _update_color() {
  550. INDEPENDENT_COMPONENTS.forEach(name => {
  551. // get component and preferences needed
  552. let component = this['_' + name + '_blur'];
  553. let component_settings = this._settings[name];
  554. // update color accordingly
  555. if (component_settings.CUSTOMIZE)
  556. component.set_color(component_settings.COLOR);
  557. else
  558. component.set_color(this._settings.COLOR);
  559. });
  560. }
  561. /// Update each component's noise amount value
  562. _update_noise_amount() {
  563. INDEPENDENT_COMPONENTS.forEach(name => {
  564. // get component and preferences needed
  565. let component = this['_' + name + '_blur'];
  566. let component_settings = this._settings[name];
  567. // update color accordingly
  568. if (component_settings.CUSTOMIZE)
  569. component.set_noise_amount(component_settings.NOISE_AMOUNT);
  570. else
  571. component.set_noise_amount(this._settings.NOISE_AMOUNT);
  572. });
  573. }
  574. /// Update each component's noise lightness value
  575. _update_noise_lightness() {
  576. INDEPENDENT_COMPONENTS.forEach(name => {
  577. // get component and preferences needed
  578. let component = this['_' + name + '_blur'];
  579. let component_settings = this._settings[name];
  580. // update color accordingly
  581. if (component_settings.CUSTOMIZE)
  582. component.set_noise_lightness(component_settings.NOISE_LIGHTNESS);
  583. else
  584. component.set_noise_lightness(this._settings.NOISE_LIGHTNESS);
  585. });
  586. }
  587. _log(str) {
  588. if (this._settings.DEBUG)
  589. console.log(`[Blur my Shell > extension] ${str}`);
  590. }
  591. }