Project: Switch to Prettier for code formatting
This commit is contained in:
@@ -4,5 +4,6 @@
|
||||
.cache
|
||||
|
||||
build
|
||||
builddir
|
||||
dist
|
||||
node_modules
|
||||
|
||||
+14
-2
@@ -47,10 +47,20 @@ lint:
|
||||
interruptible: true
|
||||
rules:
|
||||
- changes:
|
||||
- src/**/*.js
|
||||
- src/**/*.js
|
||||
script:
|
||||
- npm run test-lint
|
||||
|
||||
style:
|
||||
extends: .node
|
||||
stage: check
|
||||
interruptible: true
|
||||
rules:
|
||||
- changes:
|
||||
- src/**/*.js
|
||||
script:
|
||||
- npm run test-style
|
||||
|
||||
reuse:
|
||||
image:
|
||||
name: fsfe/reuse:latest
|
||||
@@ -66,6 +76,8 @@ extension:
|
||||
needs:
|
||||
- job: lint
|
||||
optional: true
|
||||
- job: style
|
||||
optional: true
|
||||
- reuse
|
||||
image: debian:stable-slim
|
||||
before_script:
|
||||
@@ -147,7 +159,7 @@ pages:
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||
changes:
|
||||
- website/**/*
|
||||
- website/**/*
|
||||
artifacts:
|
||||
paths:
|
||||
- public
|
||||
|
||||
@@ -20,7 +20,6 @@ Extension info:
|
||||
|
||||
## Description of the problem
|
||||
|
||||
|
||||
## Steps to reproduce
|
||||
|
||||
1.
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
# SPDX-FileCopyrightText: Night Theme Switcher Contributors
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
extends:
|
||||
- ./lint/eslintrc-gjs.yml
|
||||
- ./lint/eslintrc-shell.yml
|
||||
- ./lint/eslintrc-extension.yml
|
||||
printWidth: 120
|
||||
+76
-72
@@ -5,7 +5,6 @@ SPDX-License-Identifier: CC-BY-SA-4.0
|
||||
|
||||
# Changelog
|
||||
|
||||
|
||||
## [82] - 2026-03-10
|
||||
|
||||
This version adds support for GNOME 50 and removes support for GNOME 49.
|
||||
@@ -18,7 +17,6 @@ This version adds support for GNOME 50 and removes support for GNOME 49.
|
||||
|
||||
- GNOME 49 support
|
||||
|
||||
|
||||
## [81] - 2026-01-14
|
||||
|
||||
### Changed
|
||||
@@ -34,7 +32,6 @@ This version adds support for GNOME 50 and removes support for GNOME 49.
|
||||
|
||||
- Conversion to/from 24h/12h format was wrong
|
||||
|
||||
|
||||
## [80] - 2025-09-06
|
||||
|
||||
This version adds support for GNOME 49 and removes support for GNOME 48.
|
||||
@@ -60,7 +57,6 @@ This version adds support for GNOME 49 and removes support for GNOME 48.
|
||||
|
||||
- GNOME 48 support
|
||||
|
||||
|
||||
## [79] - 2025-03-16
|
||||
|
||||
This version adds support for GNOME 48 and removes support for GNOME 47.
|
||||
@@ -80,7 +76,6 @@ This version adds support for GNOME 48 and removes support for GNOME 47.
|
||||
|
||||
- GNOME 47 support
|
||||
|
||||
|
||||
## [78] - 2024-09-18
|
||||
|
||||
This version adds support for GNOME 47 and removes support for GNOME 46.
|
||||
@@ -106,7 +101,6 @@ This version adds support for GNOME 47 and removes support for GNOME 46.
|
||||
|
||||
- GNOME 46 support
|
||||
|
||||
|
||||
## [77] - 2024-03-10
|
||||
|
||||
### Changed
|
||||
@@ -122,7 +116,6 @@ This version adds support for GNOME 47 and removes support for GNOME 46.
|
||||
|
||||
- Unknown Location notification was not working
|
||||
|
||||
|
||||
## [76] - 2024-03-10
|
||||
|
||||
This version adds support for GNOME 46 and removes support for GNOME 45. It also adds hidden settings to set the color scheme used at day and night. It removes legacy GTK theme, Shell theme, icon theme and cursor switching.
|
||||
@@ -148,7 +141,6 @@ This version adds support for GNOME 46 and removes support for GNOME 45. It also
|
||||
- Updated Polish translation by @gnu-ewm
|
||||
- Updated Turkish translation by @ersen and @Elagoht
|
||||
|
||||
|
||||
## [75] - 2023-08-20
|
||||
|
||||
This version adds support for GNOME 45 and removes support for GNOME 44.
|
||||
@@ -166,7 +158,6 @@ This version adds support for GNOME 45 and removes support for GNOME 44.
|
||||
- Updated Polish translation by @mbled
|
||||
- Updated Russian translation by @AHOHNMYC
|
||||
|
||||
|
||||
## [74] - 2023-02-27
|
||||
|
||||
This version adds support for GNOME 44 and removes support for GNOME 43.
|
||||
@@ -179,7 +170,6 @@ This version adds support for GNOME 44 and removes support for GNOME 43.
|
||||
|
||||
- GNOME 43 support
|
||||
|
||||
|
||||
## [73] - 2023-02-27
|
||||
|
||||
### Added
|
||||
@@ -195,7 +185,6 @@ This version adds support for GNOME 44 and removes support for GNOME 43.
|
||||
- Updated German translation by @seismist
|
||||
- Updated Spanish translation by @gallegonovato and @oscfdezdz
|
||||
|
||||
|
||||
## [72] - 2022-12-07
|
||||
|
||||
### Changed
|
||||
@@ -205,7 +194,6 @@ This version adds support for GNOME 44 and removes support for GNOME 43.
|
||||
- Updated Occitan translation by @quenty_occitania
|
||||
- Updated Russian translation by @daudix-UFO
|
||||
|
||||
|
||||
## [71] - 2022-11-07
|
||||
|
||||
### Changed
|
||||
@@ -218,7 +206,6 @@ This version adds support for GNOME 44 and removes support for GNOME 43.
|
||||
|
||||
- Schedules with sunrise or sunset on a different day are now supported
|
||||
|
||||
|
||||
## [70] - 2022-10-31
|
||||
|
||||
### Added
|
||||
@@ -232,7 +219,6 @@ This version adds support for GNOME 44 and removes support for GNOME 43.
|
||||
- Updated German translation
|
||||
- Updated Turkish translation by @ersen
|
||||
|
||||
|
||||
## [69] - 2022-10-29
|
||||
|
||||
### Fixed
|
||||
@@ -241,7 +227,6 @@ This version adds support for GNOME 44 and removes support for GNOME 43.
|
||||
- Background thumbnail generation was blocking the preferences dialog
|
||||
- It was possible to set invalid sunset and sunrise times in the preferences dialog
|
||||
|
||||
|
||||
## [68] - 2022-10-28
|
||||
|
||||
### Added
|
||||
@@ -254,7 +239,6 @@ This version adds support for GNOME 44 and removes support for GNOME 43.
|
||||
- Updated Italian translation by @phaerrax
|
||||
- Updated Russian translation by @daudix-UFO
|
||||
|
||||
|
||||
## [67] - 2022-09-19
|
||||
|
||||
### Changed
|
||||
@@ -262,7 +246,6 @@ This version adds support for GNOME 44 and removes support for GNOME 43.
|
||||
- Updated Arabic translation by Omar TS
|
||||
- Updated Occitan translation by @quenty_occitania
|
||||
|
||||
|
||||
## [66] - 2022-09-08
|
||||
|
||||
This version adds support for GNOME 43 and removes support for GNOME 42.
|
||||
@@ -295,7 +278,6 @@ Note to packagers: Make sure the build type is not `debug` or the extension will
|
||||
- On-demand time source (replaced by the built-in dark mode quick setting)
|
||||
- Transition setting
|
||||
|
||||
|
||||
## [65] - 2022-06-17
|
||||
|
||||
### Added
|
||||
@@ -315,13 +297,14 @@ Note to packagers: Make sure the build type is not `debug` or the extension will
|
||||
- Background button did not accept all supported image formats
|
||||
- Background button did not interpolate thumbnail
|
||||
|
||||
|
||||
## [64] - 2022-04-27
|
||||
|
||||
### Added
|
||||
|
||||
- Italian translation by @phaerrax
|
||||
|
||||
### Changed
|
||||
|
||||
- Updated Arabic translation by Omar TS
|
||||
- Updated Chinese (Simplified) translation by @wsxy162
|
||||
- Updated Dutch translation
|
||||
@@ -334,22 +317,24 @@ Note to packagers: Make sure the build type is not `debug` or the extension will
|
||||
- Updated Turkish translation by @ersen
|
||||
|
||||
### Fixed
|
||||
|
||||
- Background button was not activated when activating a row
|
||||
- Background button did not support SVG images
|
||||
|
||||
|
||||
## [63] - 2022-04-13
|
||||
|
||||
### Changed
|
||||
|
||||
- Updated Polish translation by Przemek Juszczyk
|
||||
|
||||
### Fixed
|
||||
- Empty background buttons in the preferences when the monitor size is unavailable
|
||||
|
||||
- Empty background buttons in the preferences when the monitor size is unavailable
|
||||
|
||||
## [62] - 2022-04-08
|
||||
|
||||
### Changed
|
||||
|
||||
- Updated Chinese (Simplified) translation by @wsxy162
|
||||
- Updated Dutch translation by @Vistaus
|
||||
- Updated French translation
|
||||
@@ -357,43 +342,46 @@ Note to packagers: Make sure the build type is not `debug` or the extension will
|
||||
- Updated Turkish translation by @ersen
|
||||
|
||||
### Fixed
|
||||
|
||||
- On-demand icon not loaded after extension installation
|
||||
- Adwaita, Adwaita-dark, HighContrast and HighContrastInverse were added to the list of GTK themes even if they were not present on the system
|
||||
- Chinese (Simplified) translation was not loaded
|
||||
|
||||
|
||||
## [61] - 2022-04-04
|
||||
|
||||
### Changed
|
||||
|
||||
- Build system has been replaced by Meson to make packaging easier, see the README for the updated installation instructions
|
||||
- Updated Arabic translation
|
||||
- Updated Polish translation by Przemek Juszczyk
|
||||
- Updated Portuguese (Brazil) translation
|
||||
|
||||
|
||||
## [60] - 2022-03-15
|
||||
|
||||
### Added
|
||||
|
||||
- Polish translation by Tomasz Dróżdż
|
||||
|
||||
### Changed
|
||||
|
||||
- Updated Chinese (Simplified) translation by poi
|
||||
- Updated German translation by eladyn
|
||||
|
||||
|
||||
## [59] - 2022-02-26
|
||||
|
||||
### Added
|
||||
- Initial work on Occitan translation by @quenty_occitania
|
||||
|
||||
- Initial work on Occitan translation by @quenty_occitania
|
||||
|
||||
## [58] - 2022-02-25
|
||||
|
||||
### Added
|
||||
|
||||
- Allow dropping images on background chooser button
|
||||
- Keep extension enabled on lock screen
|
||||
|
||||
### Changed
|
||||
|
||||
- Time source settings grouped under an Advanced section
|
||||
- Background chooser button follows monitor aspect ratio
|
||||
- Updated Dutch translation by @Vistaus
|
||||
@@ -402,22 +390,23 @@ Note to packagers: Make sure the build type is not `debug` or the extension will
|
||||
- Updated Spanish translation by @oscfdezdz
|
||||
- Updated Turkish translation by @ersen
|
||||
|
||||
|
||||
## [57] - 2022-02-20
|
||||
|
||||
### Fixed
|
||||
- Transition ran after changing the color scheme
|
||||
|
||||
- Transition ran after changing the color scheme
|
||||
|
||||
## [56] - 2022-02-20
|
||||
|
||||
### Added
|
||||
|
||||
- GNOME 42 support
|
||||
- Use of the new color scheme desktop setting
|
||||
- Transition between day and night mode
|
||||
- Chinese (Simplified) translation by poi
|
||||
|
||||
### Changed
|
||||
|
||||
- Preferences ported to libadwaita
|
||||
- Backgrounds preferences set the system regular and dark backgrounds
|
||||
- GTK and Shell themes switching disabled by default
|
||||
@@ -428,23 +417,23 @@ Note to packagers: Make sure the build type is not `debug` or the extension will
|
||||
- Updated Turkish translation by @ersen
|
||||
|
||||
### Removed
|
||||
|
||||
- GNOME 41 support
|
||||
- Automatic theme variants detection
|
||||
|
||||
|
||||
## [55] - 2021-11-03
|
||||
|
||||
### Added
|
||||
- Russian translation by Sixella
|
||||
|
||||
- Russian translation by Sixella
|
||||
|
||||
## [54] - 2021-11-03
|
||||
|
||||
### Added
|
||||
|
||||
- Fluent themes support
|
||||
- Initial Romanian translation by Andrei Lazarov
|
||||
|
||||
|
||||
## [53] - 2021-10-08
|
||||
|
||||
### Added
|
||||
@@ -460,21 +449,22 @@ Note to packagers: Make sure the build type is not `debug` or the extension will
|
||||
- Updated German translation by Kepler 69c
|
||||
- Updated Spanish translation by @oscfdezdz
|
||||
|
||||
|
||||
## [52] - 2021-08-27
|
||||
|
||||
### Added
|
||||
|
||||
- GNOME 41 support
|
||||
- Zorin themes support
|
||||
- Arabic translation by Omar TS
|
||||
|
||||
### Removed
|
||||
- GNOME 40 support
|
||||
|
||||
- GNOME 40 support
|
||||
|
||||
## [51] - 2021-08-22
|
||||
|
||||
### Added
|
||||
|
||||
- Ability to change programmatically the on-demand time (#64)
|
||||
- Dutch translation by @Vistaus
|
||||
- Norwegian Bokmål translation by @kingu
|
||||
@@ -482,6 +472,7 @@ Note to packagers: Make sure the build type is not `debug` or the extension will
|
||||
- New CHANGELOG.md file
|
||||
|
||||
### Changed
|
||||
|
||||
- Updated preferences window UI:
|
||||
- New "Appearance" tab grouping GTK, shell, icon, cursor themes and backgrounds
|
||||
- New "Support us" popover
|
||||
@@ -490,303 +481,316 @@ Note to packagers: Make sure the build type is not `debug` or the extension will
|
||||
- Releases will now be tagged only by their version number instead of being prefixed by "v"
|
||||
|
||||
### Fixed
|
||||
|
||||
- Preferences window was not scrollable on small screens (#56)
|
||||
- Themes dropdown was not scrollable (#61)
|
||||
|
||||
|
||||
## [50] - 2021-04-22
|
||||
|
||||
### Added
|
||||
- Allow icon theme to override on-demand icons
|
||||
|
||||
- Allow icon theme to override on-demand icons
|
||||
|
||||
## [49] - 2021-03-29
|
||||
|
||||
### Added
|
||||
- Turkish translation by @tasali
|
||||
|
||||
- Turkish translation by @tasali
|
||||
|
||||
## [48] - 2021-17-03
|
||||
|
||||
### Fixed
|
||||
- Fix GNOME version for EGO
|
||||
|
||||
- Fix GNOME version for EGO
|
||||
|
||||
## [47] - 2021-17-03
|
||||
|
||||
### Added
|
||||
- Support for GNOME 40
|
||||
|
||||
- Support for GNOME 40
|
||||
|
||||
## [46] - 2021-17-02
|
||||
|
||||
### Added
|
||||
|
||||
- German translation contributed by @ls-moose
|
||||
|
||||
### Fixed
|
||||
- Don't block the shell when enabled on a incompatible version
|
||||
|
||||
- Don't block the shell when enabled on a incompatible version
|
||||
|
||||
## [45] - 2021-05-01
|
||||
|
||||
### Fixed
|
||||
- On-demand panel button not responding to touch event (#42)
|
||||
|
||||
- On-demand panel button not responding to touch event (#42)
|
||||
|
||||
## [44] - 2020-12-20
|
||||
|
||||
### Added
|
||||
- Spanish translation by @oscfdezdz
|
||||
|
||||
- Spanish translation by @oscfdezdz
|
||||
|
||||
## [43] - 2020-12-08
|
||||
|
||||
### Added
|
||||
|
||||
- Ability to set dynamic wallpaper as background image (by @whatdoeslunasay)
|
||||
|
||||
### Fixed
|
||||
- Stuck on startup under X session (#41)
|
||||
|
||||
- Stuck on startup under X session (#41)
|
||||
|
||||
## [42] - 2020-12-03
|
||||
|
||||
### Fixed
|
||||
- On-demand timer took precedence over automatic time source (#38)
|
||||
|
||||
- On-demand timer took precedence over automatic time source (#38)
|
||||
|
||||
## [41] - 2020-11-16
|
||||
|
||||
### Fixed
|
||||
- Various bugs
|
||||
|
||||
- Various bugs
|
||||
|
||||
## [40] - 2020-11-06
|
||||
|
||||
### Added
|
||||
|
||||
- Option to follow Night Light "Disable until tomorrow"
|
||||
- On-demand option for all automatic sources
|
||||
|
||||
|
||||
## [39] - 2020-09-26
|
||||
|
||||
### Added
|
||||
- Custom icons for on-demand switcher
|
||||
|
||||
- Custom icons for on-demand switcher
|
||||
|
||||
## [38] - 2020-09-24
|
||||
|
||||
### Changed
|
||||
- Improved preferences window
|
||||
|
||||
- Improved preferences window
|
||||
|
||||
## [37] - 2020-09-07
|
||||
|
||||
### Added
|
||||
|
||||
- Compatible with GNOME Shell 3.38
|
||||
|
||||
### Fixed
|
||||
- Various bugs
|
||||
|
||||
- Various bugs
|
||||
|
||||
## [36] - 2020-08-10
|
||||
|
||||
### Added
|
||||
|
||||
- Support for Adwaita Colors theme
|
||||
- Support for McOS11-Shell theme
|
||||
- Support for Mc-OS CTLina theme
|
||||
- Support for WhiteSur theme
|
||||
- Support for Yaru Colors theme
|
||||
|
||||
|
||||
## [35] - 2020-07-08
|
||||
|
||||
### Added
|
||||
|
||||
- Option for on-demand button placement
|
||||
|
||||
### Fixed
|
||||
- Various bugs
|
||||
|
||||
- Various bugs
|
||||
|
||||
## [34] - 2020-08-04
|
||||
|
||||
### Fixed
|
||||
- Various bugs
|
||||
|
||||
- Various bugs
|
||||
|
||||
## [33] - 2020-08-03
|
||||
|
||||
### Changed
|
||||
|
||||
- Updated preferences UI
|
||||
|
||||
### Fixed
|
||||
- Various bugs
|
||||
|
||||
- Various bugs
|
||||
|
||||
## [32] - 2020-07-29
|
||||
|
||||
### Fixed
|
||||
- Various bugs
|
||||
|
||||
- Various bugs
|
||||
|
||||
## [31] - 2020-06-15
|
||||
|
||||
### Added
|
||||
|
||||
- Cursor theme switching
|
||||
- Icon theme switching
|
||||
- On-demand switch thanks to @goodwillcoding
|
||||
|
||||
|
||||
## [30] - 2020-05-25
|
||||
|
||||
### Added
|
||||
|
||||
- Include Night Shell Switcher functionality, don't require the User Themes extension any more (but will work with it if it is installed)
|
||||
- Allow manually setting the time source
|
||||
- Allow setting custom commands to be launched at time change
|
||||
- Allow switching background images
|
||||
|
||||
### Changed
|
||||
|
||||
- Major rewrite of the extension's architecture
|
||||
- Improve compatibility with older GNOME Shell versions (>=3.28)
|
||||
|
||||
|
||||
## [29] - 2020-05-15
|
||||
|
||||
### Fixed
|
||||
- Various bugs
|
||||
|
||||
- Various bugs
|
||||
|
||||
## [28] - 2020-05-13
|
||||
|
||||
### Fixed
|
||||
- Various bugs
|
||||
|
||||
- Various bugs
|
||||
|
||||
## [27] - 2020-05-09
|
||||
|
||||
### Added
|
||||
|
||||
- Check if the guessed theme is installed
|
||||
- Support for manual theme selection
|
||||
|
||||
|
||||
## [26] - 2020-05-06
|
||||
|
||||
### Added
|
||||
- Location Services and manual schedule support
|
||||
|
||||
- Location Services and manual schedule support
|
||||
|
||||
## [25] - 2020-04-20
|
||||
|
||||
### Added
|
||||
|
||||
- Macwaita theme support
|
||||
- Nextwaita theme support
|
||||
|
||||
|
||||
## [24] - 2020-04-16
|
||||
|
||||
### Added
|
||||
|
||||
- Prof-Gnome-3 theme support
|
||||
- Orchis theme support
|
||||
- Cabinet theme support
|
||||
- Simply Circles theme support
|
||||
|
||||
|
||||
## [23] - 2020-04-13
|
||||
|
||||
### Changed
|
||||
|
||||
- Improved performances
|
||||
|
||||
### Fixed
|
||||
- Variants were reset on session exit (#11)
|
||||
|
||||
- Variants were reset on session exit (#11)
|
||||
|
||||
## [22] - 2020-04-02
|
||||
|
||||
### Added
|
||||
- Support for Plata theme
|
||||
|
||||
- Support for Plata theme
|
||||
|
||||
## [21] - 2020-03-27
|
||||
|
||||
### Changed
|
||||
- Improved performances
|
||||
|
||||
- Improved performances
|
||||
|
||||
## [20] - 2020-03-23
|
||||
|
||||
### Fixed
|
||||
- Theme flicker on screen unlock (#5)
|
||||
|
||||
- Theme flicker on screen unlock (#5)
|
||||
|
||||
## [19] - 2020-02-27
|
||||
|
||||
### Added
|
||||
|
||||
- Support for Teja theme
|
||||
- Support for ChromeOS theme
|
||||
|
||||
### Changed
|
||||
- User experience improvements
|
||||
|
||||
- User experience improvements
|
||||
|
||||
## [18] - 2020-02-26
|
||||
|
||||
### Changed
|
||||
|
||||
- User experience improvements
|
||||
|
||||
### Fixed
|
||||
- Various bugs
|
||||
|
||||
- Various bugs
|
||||
|
||||
## [17] - 2020-02-24
|
||||
|
||||
### Added
|
||||
|
||||
- GNOME Shell 3.36 compatibility
|
||||
|
||||
### Fixed
|
||||
- Various bugs
|
||||
|
||||
- Various bugs
|
||||
|
||||
## [16] - 2020-02-14
|
||||
|
||||
### Changed
|
||||
|
||||
- Code refactoring
|
||||
|
||||
### Fixed
|
||||
|
||||
- Arc variants guessing
|
||||
- Matcha variants guessing
|
||||
|
||||
|
||||
## [15] - 2020-02-13
|
||||
|
||||
### Added
|
||||
|
||||
- Adapta theme support
|
||||
- Canta theme support
|
||||
- Flat-Remix-GTK theme support
|
||||
- Layan theme support
|
||||
- Qogir compatibility
|
||||
|
||||
|
||||
## [14] - 2020-02-13
|
||||
|
||||
### Added
|
||||
- Vimix theme support
|
||||
|
||||
- Vimix theme support
|
||||
|
||||
## [13] - 2020-02-08
|
||||
|
||||
### Changed
|
||||
- Improved error handling
|
||||
|
||||
- Improved error handling
|
||||
|
||||
## [12] - 2020-02-01
|
||||
|
||||
### Added
|
||||
|
||||
- Mojave theme support
|
||||
|
||||
### Fixed
|
||||
- Theme change not detecting variants
|
||||
|
||||
- Theme change not detecting variants
|
||||
|
||||
## [11] - 2020-01-27
|
||||
|
||||
### Added
|
||||
|
||||
- Matcha theme support
|
||||
|
||||
+7
-7
@@ -12,13 +12,13 @@ You're welcome to contribute to the [code](#contributing-to-the-code) or to the
|
||||
## Table of contents <!-- omit in toc -->
|
||||
|
||||
- [Testing the extension](#testing-the-extension)
|
||||
- [Transfering to a virtual machine](#transfering-to-a-virtual-machine)
|
||||
- [Printing debug logs](#printing-debug-logs)
|
||||
- [Transfering to a virtual machine](#transfering-to-a-virtual-machine)
|
||||
- [Printing debug logs](#printing-debug-logs)
|
||||
- [Contributing to the code](#contributing-to-the-code)
|
||||
- [Coding style](#coding-style)
|
||||
- [Copyright notice](#copyright-notice)
|
||||
- [Creating new files](#creating-new-files)
|
||||
- [Localized strings](#localized-strings)
|
||||
- [Coding style](#coding-style)
|
||||
- [Copyright notice](#copyright-notice)
|
||||
- [Creating new files](#creating-new-files)
|
||||
- [Localized strings](#localized-strings)
|
||||
- [Contributing to the translations](#contributing-to-the-translations)
|
||||
|
||||
---
|
||||
@@ -65,7 +65,7 @@ You can then push to a branch and create a new merge request.
|
||||
|
||||
### Coding style
|
||||
|
||||
We follow the [GNOME Shell coding style](https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/HEAD/HACKING.md) and we use [ESLint](https://eslint.org/) to enforce it.
|
||||
We use [ESLint](https://eslint.org/) to check for coding mistakes, and [Prettier](https://prettier.io/) to enforce a consistent styling.
|
||||
|
||||
To make sure your code follows it:
|
||||
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification follow.
|
||||
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
one line to give the program's name and an idea of what it does. Copyright (C) yyyy name of author
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice
|
||||
@@ -1,174 +0,0 @@
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the library GPL. It is numbered 2 because it goes with version 2 of the ordinary GPL.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Library General Public License, applies to some specially designated Free Software Foundation software, and to any other libraries whose authors decide to use it. You can use it for your libraries, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link a program with the library, you must provide complete object files to the recipients so that they can relink them with the library, after making changes to the library and recompiling it. And you must show them these terms so they know their rights.
|
||||
|
||||
Our method of protecting your rights has two steps: (1) copyright the library, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the library.
|
||||
|
||||
Also, for each distributor's protection, we want to make certain that everyone understands that there is no warranty for this free library. If the library is modified by someone else and passed on, we want its recipients to know that what they have is not the original version, so that any problems introduced by others will not reflect on the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that companies distributing free software will individually obtain patent licenses, thus in effect transforming the program into proprietary software. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary GNU General Public License, which was designed for utility programs. This license, the GNU Library General Public License, applies to certain designated libraries. This license is quite different from the ordinary one; be sure to read it in full, and don't assume that anything in it is the same as in the ordinary license.
|
||||
|
||||
The reason we have a separate public license for some libraries is that they blur the distinction we usually make between modifying or adding to a program and simply using it. Linking a program with a library, without changing the library, is in some sense simply using the library, and is analogous to running a utility program or application program. However, in a textual and legal sense, the linked executable is a combined work, a derivative of the original library, and the ordinary General Public License treats it as such.
|
||||
|
||||
Because of this blurred distinction, using the ordinary General Public License for libraries did not effectively promote software sharing, because most developers did not use the libraries. We concluded that weaker conditions might promote sharing better.
|
||||
|
||||
However, unrestricted linking of non-free programs would deprive the users of those programs of all benefit from the free status of the libraries themselves. This Library General Public License is intended to permit developers of non-free programs to use free libraries, while preserving your freedom as a user of such programs to change the free libraries that are incorporated in them. (We have not seen how to achieve this as regards changes in header files, but we have achieved it as regards changes in the actual functions of the Library.) The hope is that this will lead to faster development of free libraries.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, while the latter only works together with the library.
|
||||
|
||||
Note that it is possible for a library to be covered by the ordinary General Public License rather than by this special one.
|
||||
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Library General Public License (also called "this License"). Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also compile or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.)
|
||||
|
||||
b) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution.
|
||||
|
||||
c) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place.
|
||||
|
||||
d) Verify that the user has already received a copy of these materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new versions of the Library General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
one line to give the library's name and an idea of what it does.
|
||||
Copyright (C) year name of author
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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 Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in
|
||||
the library `Frob' (a library for tweaking knobs) written
|
||||
by James Random Hacker.
|
||||
|
||||
signature of Ty Coon, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
@@ -1,9 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) <year> <copyright holders>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,25 @@
|
||||
// SPDX-FileCopyrightText: Night Theme Switcher Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import js from "@eslint/js";
|
||||
import globals from "globals";
|
||||
import { defineConfig } from "eslint/config";
|
||||
import { jsdoc } from "eslint-plugin-jsdoc";
|
||||
import eslintConfigPrettier from "eslint-config-prettier/flat";
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
files: ["**/*.{js,mjs,cjs}"],
|
||||
plugins: { js },
|
||||
extends: ["js/recommended"],
|
||||
languageOptions: { globals: { NTS: "writable", ...globals.browser } },
|
||||
rules: {
|
||||
"no-empty": ["error", { allowEmptyCatch: true }],
|
||||
"no-unused-vars": ["error", { argsIgnorePattern: "_" }],
|
||||
},
|
||||
},
|
||||
jsdoc({
|
||||
config: "flat/recommended",
|
||||
}),
|
||||
eslintConfigPrettier,
|
||||
]);
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"include": ["src/**/*", "node_modules/@girs/**/*"]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
SPDX-FileCopyrightText: Night Theme Switcher Contributors
|
||||
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
@@ -1,14 +0,0 @@
|
||||
# SPDX-FileCopyrightText: Night Theme Switcher Contributors
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
rules:
|
||||
no-unused-vars:
|
||||
- error
|
||||
- vars: 'local'
|
||||
varsIgnorePattern: (^unused|_$)
|
||||
argsIgnorePattern: ^(unused|_)
|
||||
object-curly-spacing: off
|
||||
globals:
|
||||
NTS: writable
|
||||
parserOptions:
|
||||
sourceType: module
|
||||
@@ -1,267 +0,0 @@
|
||||
---
|
||||
# SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
|
||||
# SPDX-FileCopyrightText: 2018 Claudio André <claudioandre.br@gmail.com>
|
||||
env:
|
||||
es2021: true
|
||||
extends: 'eslint:recommended'
|
||||
plugins:
|
||||
- jsdoc
|
||||
rules:
|
||||
array-bracket-newline:
|
||||
- error
|
||||
- consistent
|
||||
array-bracket-spacing:
|
||||
- error
|
||||
- never
|
||||
array-callback-return: error
|
||||
arrow-parens:
|
||||
- error
|
||||
- as-needed
|
||||
arrow-spacing: error
|
||||
block-scoped-var: error
|
||||
block-spacing: error
|
||||
brace-style: error
|
||||
# Waiting for this to have matured a bit in eslint
|
||||
# camelcase:
|
||||
# - error
|
||||
# - properties: never
|
||||
# allow: [^vfunc_, ^on_, _instance_init]
|
||||
comma-dangle:
|
||||
- error
|
||||
- arrays: always-multiline
|
||||
objects: always-multiline
|
||||
functions: never
|
||||
comma-spacing:
|
||||
- error
|
||||
- before: false
|
||||
after: true
|
||||
comma-style:
|
||||
- error
|
||||
- last
|
||||
computed-property-spacing: error
|
||||
curly:
|
||||
- error
|
||||
- multi-or-nest
|
||||
- consistent
|
||||
dot-location:
|
||||
- error
|
||||
- property
|
||||
eol-last: error
|
||||
eqeqeq: error
|
||||
func-call-spacing: error
|
||||
func-name-matching: error
|
||||
func-style:
|
||||
- error
|
||||
- declaration
|
||||
- allowArrowFunctions: true
|
||||
indent:
|
||||
- error
|
||||
- 4
|
||||
- ignoredNodes:
|
||||
# Allow not indenting the body of GObject.registerClass, since in the
|
||||
# future it's intended to be a decorator
|
||||
- 'CallExpression[callee.object.name=GObject][callee.property.name=registerClass] > ClassExpression:first-child'
|
||||
# Allow dedenting chained member expressions
|
||||
MemberExpression: 'off'
|
||||
jsdoc/check-alignment: error
|
||||
jsdoc/check-param-names: error
|
||||
jsdoc/check-tag-names: error
|
||||
jsdoc/check-types: error
|
||||
jsdoc/implements-on-classes: error
|
||||
jsdoc/tag-lines:
|
||||
- error
|
||||
- any
|
||||
- startLines: 1
|
||||
jsdoc/require-jsdoc: error
|
||||
jsdoc/require-param: error
|
||||
jsdoc/require-param-description: error
|
||||
jsdoc/require-param-name: error
|
||||
jsdoc/require-param-type: error
|
||||
key-spacing:
|
||||
- error
|
||||
- beforeColon: false
|
||||
afterColon: true
|
||||
keyword-spacing:
|
||||
- error
|
||||
- before: true
|
||||
after: true
|
||||
linebreak-style:
|
||||
- error
|
||||
- unix
|
||||
lines-between-class-members:
|
||||
- error
|
||||
- always
|
||||
- exceptAfterSingleLine: true
|
||||
max-nested-callbacks: error
|
||||
max-statements-per-line: error
|
||||
new-parens: error
|
||||
no-array-constructor: error
|
||||
no-await-in-loop: error
|
||||
no-caller: error
|
||||
no-constant-condition:
|
||||
- error
|
||||
- checkLoops: false
|
||||
no-div-regex: error
|
||||
no-empty:
|
||||
- error
|
||||
- allowEmptyCatch: true
|
||||
no-extra-bind: error
|
||||
no-extra-parens:
|
||||
- error
|
||||
- all
|
||||
- conditionalAssign: false
|
||||
nestedBinaryExpressions: false
|
||||
returnAssign: false
|
||||
no-implicit-coercion:
|
||||
- error
|
||||
- allow:
|
||||
- '!!'
|
||||
no-invalid-this: error
|
||||
no-iterator: error
|
||||
no-label-var: error
|
||||
no-lonely-if: error
|
||||
no-loop-func: error
|
||||
no-nested-ternary: error
|
||||
no-new-object: error
|
||||
no-new-wrappers: error
|
||||
no-octal-escape: error
|
||||
no-proto: error
|
||||
no-prototype-builtins: 'off'
|
||||
no-restricted-globals: [error, window]
|
||||
no-restricted-properties:
|
||||
- error
|
||||
- object: Lang
|
||||
property: copyProperties
|
||||
message: Use Object.assign()
|
||||
- object: Lang
|
||||
property: bind
|
||||
message: Use arrow notation or Function.prototype.bind()
|
||||
- object: Lang
|
||||
property: Class
|
||||
message: Use ES6 classes
|
||||
no-restricted-syntax:
|
||||
- error
|
||||
- selector: >-
|
||||
MethodDefinition[key.name="_init"] >
|
||||
FunctionExpression[params.length=1] >
|
||||
BlockStatement[body.length=1]
|
||||
CallExpression[arguments.length=1][callee.object.type="Super"][callee.property.name="_init"] >
|
||||
Identifier:first-child
|
||||
message: _init() that only calls super._init() is unnecessary
|
||||
- selector: >-
|
||||
MethodDefinition[key.name="_init"] >
|
||||
FunctionExpression[params.length=0] >
|
||||
BlockStatement[body.length=1]
|
||||
CallExpression[arguments.length=0][callee.object.type="Super"][callee.property.name="_init"]
|
||||
message: _init() that only calls super._init() is unnecessary
|
||||
- selector: BinaryExpression[operator="instanceof"][right.name="Array"]
|
||||
message: Use Array.isArray()
|
||||
no-return-assign: error
|
||||
no-return-await: error
|
||||
no-self-compare: error
|
||||
no-shadow: error
|
||||
no-shadow-restricted-names: error
|
||||
no-spaced-func: error
|
||||
no-tabs: error
|
||||
no-template-curly-in-string: error
|
||||
no-throw-literal: error
|
||||
no-trailing-spaces: error
|
||||
no-undef-init: error
|
||||
no-unneeded-ternary: error
|
||||
no-unused-expressions: error
|
||||
no-unused-vars:
|
||||
- error
|
||||
# Vars use a suffix _ instead of a prefix because of file-scope private vars
|
||||
- varsIgnorePattern: (^unused|_$)
|
||||
argsIgnorePattern: ^(unused|_)
|
||||
no-useless-call: error
|
||||
no-useless-computed-key: error
|
||||
no-useless-concat: error
|
||||
no-useless-constructor: error
|
||||
no-useless-rename: error
|
||||
no-useless-return: error
|
||||
no-whitespace-before-property: error
|
||||
no-with: error
|
||||
nonblock-statement-body-position:
|
||||
- error
|
||||
- below
|
||||
object-curly-newline:
|
||||
- error
|
||||
- consistent: true
|
||||
multiline: true
|
||||
object-curly-spacing: error
|
||||
object-shorthand: error
|
||||
operator-assignment: error
|
||||
operator-linebreak: error
|
||||
padded-blocks:
|
||||
- error
|
||||
- never
|
||||
# These may be a bit controversial, we can try them out and enable them later
|
||||
# prefer-const: error
|
||||
# prefer-destructuring: error
|
||||
prefer-numeric-literals: error
|
||||
prefer-promise-reject-errors: error
|
||||
prefer-rest-params: error
|
||||
prefer-spread: error
|
||||
prefer-template: error
|
||||
quotes:
|
||||
- error
|
||||
- single
|
||||
- avoidEscape: true
|
||||
require-await: error
|
||||
rest-spread-spacing: error
|
||||
semi:
|
||||
- error
|
||||
- always
|
||||
semi-spacing:
|
||||
- error
|
||||
- before: false
|
||||
after: true
|
||||
semi-style: error
|
||||
space-before-blocks: error
|
||||
space-before-function-paren:
|
||||
- error
|
||||
- named: never
|
||||
# for `function ()` and `async () =>`, preserve space around keywords
|
||||
anonymous: always
|
||||
asyncArrow: always
|
||||
space-in-parens: error
|
||||
space-infix-ops:
|
||||
- error
|
||||
- int32Hint: false
|
||||
space-unary-ops: error
|
||||
spaced-comment: error
|
||||
switch-colon-spacing: error
|
||||
symbol-description: error
|
||||
template-curly-spacing: error
|
||||
template-tag-spacing: error
|
||||
unicode-bom: error
|
||||
wrap-iife:
|
||||
- error
|
||||
- inside
|
||||
yield-star-spacing: error
|
||||
yoda: error
|
||||
settings:
|
||||
jsdoc:
|
||||
mode: typescript
|
||||
globals:
|
||||
ARGV: readonly
|
||||
Debugger: readonly
|
||||
GIRepositoryGType: readonly
|
||||
globalThis: readonly
|
||||
imports: readonly
|
||||
Intl: readonly
|
||||
log: readonly
|
||||
logError: readonly
|
||||
print: readonly
|
||||
printerr: readonly
|
||||
window: readonly
|
||||
TextEncoder: readonly
|
||||
TextDecoder: readonly
|
||||
console: readonly
|
||||
setTimeout: readonly
|
||||
setInterval: readonly
|
||||
clearTimeout: readonly
|
||||
clearInterval: readonly
|
||||
parserOptions:
|
||||
ecmaVersion: 2022
|
||||
@@ -1,25 +0,0 @@
|
||||
# SPDX-FileCopyrightText: GNOME Shell Developers
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
# From https://gitlab.gnome.org/GNOME/gnome-shell/
|
||||
rules:
|
||||
camelcase:
|
||||
- error
|
||||
- properties: never
|
||||
allow: [^vfunc_, ^on_]
|
||||
consistent-return: error
|
||||
eqeqeq:
|
||||
- error
|
||||
- smart
|
||||
key-spacing:
|
||||
- error
|
||||
- mode: minimum
|
||||
beforeColon: false
|
||||
afterColon: true
|
||||
prefer-arrow-callback: error
|
||||
jsdoc/require-param-description: off
|
||||
jsdoc/require-jsdoc:
|
||||
- error
|
||||
- exemptEmptyFunctions: true
|
||||
publicOnly:
|
||||
esm: true
|
||||
+2
-2
@@ -5,7 +5,7 @@ project(
|
||||
'nightthemeswitcher',
|
||||
version: '82',
|
||||
license: ['GPL-3.0-or-later', 'CC-BY-SA-4.0'],
|
||||
meson_version: '>= 0.56.0'
|
||||
meson_version: '>= 0.56.0',
|
||||
)
|
||||
|
||||
UUID = 'nightthemeswitcher@romainvigier.fr'
|
||||
@@ -22,7 +22,7 @@ i18n = import('i18n')
|
||||
|
||||
npm_exe = find_program('npm', required: false)
|
||||
if npm_exe.found()
|
||||
run_target('dev', command: [ npm_exe, 'install', '--save-dev' ])
|
||||
run_target('dev', command: [npm_exe, 'install', '--save-dev'])
|
||||
endif
|
||||
|
||||
subdir('src')
|
||||
|
||||
Generated
+3096
-2148
File diff suppressed because it is too large
Load Diff
+28
-13
@@ -1,15 +1,30 @@
|
||||
{
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension"
|
||||
},
|
||||
"license": "GPL-3.0-or-later",
|
||||
"scripts": {
|
||||
"test-lint": "eslint .",
|
||||
"test": "npm run test-lint"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^8.47.0",
|
||||
"eslint-plugin-jsdoc": "^46.4.6"
|
||||
}
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension"
|
||||
},
|
||||
"license": "GPL-3.0-or-later",
|
||||
"scripts": {
|
||||
"test-lint": "eslint .",
|
||||
"test-style": "prettier --check .",
|
||||
"test": "npm run test-lint && npm run test-style"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@girs/adw-1": "^4.1.0",
|
||||
"@girs/gdesktopenums-3.0": "^4.1.0",
|
||||
"@girs/gdk-4.0": "^4.1.0",
|
||||
"@girs/gdkpixbuf-2.0": "^4.1.0",
|
||||
"@girs/geoclue-2.0": "^4.1.0",
|
||||
"@girs/gio-2.0": "^4.1.0",
|
||||
"@girs/glib-2.0": "^4.1.0",
|
||||
"@girs/gobject-2.0": "^4.1.0",
|
||||
"@girs/gtk-4.0": "^4.1.0",
|
||||
"@girs/meta-18": "^4.1.0",
|
||||
"@girs/shell-18": "^4.1.0",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-jsdoc": "^63.2.0",
|
||||
"globals": "^17.7.0",
|
||||
"prettier": "3.9.5"
|
||||
}
|
||||
}
|
||||
|
||||
+3
-10
@@ -9,10 +9,7 @@ gnome.compile_resources(
|
||||
install_dir: INSTALL_DIR / 'resources',
|
||||
)
|
||||
|
||||
install_data(
|
||||
DNS + '.gschema.xml',
|
||||
install_dir: INSTALL_DIR / 'schemas'
|
||||
)
|
||||
install_data(DNS + '.gschema.xml', install_dir: INSTALL_DIR / 'schemas')
|
||||
|
||||
if not get_option('pack')
|
||||
glib_compile_schemas_exe = find_program('glib-compile-schemas')
|
||||
@@ -21,12 +18,8 @@ if not get_option('pack')
|
||||
build_by_default: true,
|
||||
build_always_stale: true,
|
||||
output: 'gschemas.compiled',
|
||||
command: [
|
||||
glib_compile_schemas_exe,
|
||||
'--targetdir=@OUTDIR@',
|
||||
'@CURRENT_SOURCE_DIR@'
|
||||
],
|
||||
command: [glib_compile_schemas_exe, '--targetdir=@OUTDIR@', '@CURRENT_SOURCE_DIR@'],
|
||||
install: true,
|
||||
install_dir: INSTALL_DIR / 'schemas'
|
||||
install_dir: INSTALL_DIR / 'schemas',
|
||||
)
|
||||
endif
|
||||
|
||||
+1
-3
@@ -3,10 +3,8 @@
|
||||
|
||||
/**
|
||||
* Print a message in debug builds.
|
||||
*
|
||||
* @param {string} msg Message to print.
|
||||
*/
|
||||
export function message(msg) {
|
||||
if (NTS.metadata['build-type'] === 'debug')
|
||||
console.log(`[${NTS.metadata.name}] ${msg}`);
|
||||
if (NTS.metadata["build-type"] === "debug") console.log(`[${NTS.metadata.name}] ${msg}`);
|
||||
}
|
||||
|
||||
@@ -3,12 +3,11 @@
|
||||
|
||||
/**
|
||||
* Color Schemes.
|
||||
*
|
||||
* @readonly
|
||||
* @enum {string}
|
||||
*/
|
||||
export const ColorScheme = {
|
||||
DEFAULT: 'default',
|
||||
PREFER_DARK: 'prefer-dark',
|
||||
PREFER_LIGHT: 'prefer-night',
|
||||
DEFAULT: "default",
|
||||
PREFER_DARK: "prefer-dark",
|
||||
PREFER_LIGHT: "prefer-night",
|
||||
};
|
||||
|
||||
+3
-4
@@ -3,12 +3,11 @@
|
||||
|
||||
/**
|
||||
* Times.
|
||||
*
|
||||
* @readonly
|
||||
* @enum {string}
|
||||
*/
|
||||
export const Time = {
|
||||
UNKNOWN: 'unknown',
|
||||
DAY: 'day',
|
||||
NIGHT: 'night',
|
||||
UNKNOWN: "unknown",
|
||||
DAY: "day",
|
||||
NIGHT: "night",
|
||||
};
|
||||
|
||||
+27
-30
@@ -1,49 +1,46 @@
|
||||
// SPDX-FileCopyrightText: Night Theme Switcher Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
import { Extension } from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||
import { Extension } from "resource:///org/gnome/shell/extensions/extension.js";
|
||||
|
||||
import * as debug from './debug.js';
|
||||
|
||||
import { ColorSchemeSwitcher } from './modules/ColorSchemeSwitcher.js';
|
||||
import { CommandsSwitcher } from './modules/CommandsSwitcher.js';
|
||||
import { Timer } from './modules/Timer.js';
|
||||
import * as debug from "./debug.js";
|
||||
|
||||
import { ColorSchemeSwitcher } from "./modules/ColorSchemeSwitcher.js";
|
||||
import { CommandsSwitcher } from "./modules/CommandsSwitcher.js";
|
||||
import { Timer } from "./modules/Timer.js";
|
||||
|
||||
export default class NightThemeSwitcher extends Extension {
|
||||
#modules = [];
|
||||
#modules = [];
|
||||
|
||||
enable() {
|
||||
globalThis.NTS = this;
|
||||
enable() {
|
||||
globalThis.NTS = this;
|
||||
|
||||
debug.message('Enabling extension...');
|
||||
debug.message("Enabling extension...");
|
||||
|
||||
const timer = new Timer();
|
||||
const timer = new Timer();
|
||||
|
||||
[
|
||||
timer,
|
||||
new ColorSchemeSwitcher({ timer }),
|
||||
new CommandsSwitcher({ timer }),
|
||||
].forEach(module => this.#modules.push(module));
|
||||
[timer, new ColorSchemeSwitcher({ timer }), new CommandsSwitcher({ timer })].forEach((module) =>
|
||||
this.#modules.push(module),
|
||||
);
|
||||
|
||||
this.#modules.forEach(module => module.enable());
|
||||
this.#modules.forEach((module) => module.enable());
|
||||
|
||||
debug.message('Extension enabled.');
|
||||
}
|
||||
debug.message("Extension enabled.");
|
||||
}
|
||||
|
||||
disable() {
|
||||
// Extension won't be disabled in `unlock-dialog` session mode. This is
|
||||
// to enable the color scheme switch while the lock screen is displayed,
|
||||
// as the background image and the shell theme are visible in this mode.
|
||||
debug.message('Disabling extension...');
|
||||
disable() {
|
||||
// Extension won't be disabled in `unlock-dialog` session mode. This is
|
||||
// to enable the color scheme switch while the lock screen is displayed,
|
||||
// as the background image and the shell theme are visible in this mode.
|
||||
debug.message("Disabling extension...");
|
||||
|
||||
this.#modules.forEach(module => module.disable());
|
||||
this.#modules = [];
|
||||
this.#modules.forEach((module) => module.disable());
|
||||
this.#modules = [];
|
||||
|
||||
debug.message('Extension disabled.');
|
||||
debug.message("Extension disabled.");
|
||||
|
||||
delete globalThis.NTS;
|
||||
}
|
||||
delete globalThis.NTS;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -8,9 +8,9 @@ configure_file(
|
||||
'DNS': DNS,
|
||||
'UUID': UUID,
|
||||
'VERSION': meson.project_version(),
|
||||
'BUILD_TYPE': get_option('buildtype')
|
||||
'BUILD_TYPE': get_option('buildtype'),
|
||||
},
|
||||
install_dir: INSTALL_DIR
|
||||
install_dir: INSTALL_DIR,
|
||||
)
|
||||
|
||||
main = [
|
||||
@@ -56,6 +56,6 @@ if (get_option('pack'))
|
||||
meson.project_source_root() / 'build-aux' / 'pack.sh',
|
||||
zip_exe.full_path(),
|
||||
UUID,
|
||||
meson.project_source_root() / get_option('packdir')
|
||||
meson.project_source_root() / get_option('packdir'),
|
||||
)
|
||||
endif
|
||||
|
||||
+10
-10
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "Night Theme Switcher",
|
||||
"description": "Automatically toggle your desktop’s color scheme between light and dark, switch backgrounds and run custom commands at sunset and sunrise.",
|
||||
"uuid": "@UUID@",
|
||||
"gettext-domain": "@UUID@",
|
||||
"settings-schema": "@DNS@",
|
||||
"url": "https://nightthemeswitcher.romainvigier.fr",
|
||||
"session-modes": ["unlock-dialog", "user"],
|
||||
"shell-version": ["50"],
|
||||
"version": @VERSION@,
|
||||
"build-type": "@BUILD_TYPE@"
|
||||
"name": "Night Theme Switcher",
|
||||
"description": "Automatically toggle your desktop’s color scheme between light and dark, switch backgrounds and run custom commands at sunset and sunrise.",
|
||||
"uuid": "@UUID@",
|
||||
"gettext-domain": "@UUID@",
|
||||
"settings-schema": "@DNS@",
|
||||
"url": "https://nightthemeswitcher.romainvigier.fr",
|
||||
"session-modes": ["unlock-dialog", "user"],
|
||||
"shell-version": ["50"],
|
||||
"version": @VERSION@,
|
||||
"build-type": "@BUILD_TYPE@"
|
||||
}
|
||||
|
||||
@@ -1,88 +1,87 @@
|
||||
// SPDX-FileCopyrightText: Night Theme Switcher Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import Gio from 'gi://Gio';
|
||||
import Gio from "gi://Gio";
|
||||
|
||||
import * as debug from '../debug.js';
|
||||
import * as debug from "../debug.js";
|
||||
|
||||
import { Time } from '../enums/Time.js';
|
||||
import { Time } from "../enums/Time.js";
|
||||
|
||||
import { Switcher } from './Switcher.js';
|
||||
import { Switcher } from "./Switcher.js";
|
||||
|
||||
/**
|
||||
* The Color Scheme Switcher changes the system color scheme according to the time.
|
||||
*/
|
||||
export class ColorSchemeSwitcher extends Switcher {
|
||||
#settings;
|
||||
#interfaceSettings;
|
||||
#timer;
|
||||
#settings;
|
||||
#interfaceSettings;
|
||||
#timer;
|
||||
|
||||
#settingsConnections = [];
|
||||
#settingsConnections = [];
|
||||
|
||||
/**
|
||||
* @param {object} params Params object.
|
||||
* @param {Timer} params.timer Timer to listen to.
|
||||
*/
|
||||
constructor({ timer }) {
|
||||
const settings = NTS.getSettings(`${NTS.metadata['settings-schema']}.color-scheme`);
|
||||
super({
|
||||
name: 'Color Scheme',
|
||||
timer,
|
||||
settings,
|
||||
callback: time => this.#onTimeChanged(time),
|
||||
});
|
||||
this.#timer = timer;
|
||||
this.#settings = settings;
|
||||
this.#interfaceSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' });
|
||||
}
|
||||
/**
|
||||
* @param {object} params Params object.
|
||||
* @param {import("./Timer.js").Timer} params.timer Timer to listen to.
|
||||
*/
|
||||
constructor({ timer }) {
|
||||
const settings = NTS.getSettings(`${NTS.metadata["settings-schema"]}.color-scheme`);
|
||||
super({
|
||||
name: "Color Scheme",
|
||||
timer,
|
||||
settings,
|
||||
callback: (time) => this.#onTimeChanged(time),
|
||||
});
|
||||
this.#timer = timer;
|
||||
this.#settings = settings;
|
||||
this.#interfaceSettings = new Gio.Settings({ schema: "org.gnome.desktop.interface" });
|
||||
}
|
||||
|
||||
enable() {
|
||||
super.enable();
|
||||
this.#connectSettings();
|
||||
}
|
||||
enable() {
|
||||
super.enable();
|
||||
this.#connectSettings();
|
||||
}
|
||||
|
||||
disable() {
|
||||
super.disable();
|
||||
this.#disconnectSettings();
|
||||
}
|
||||
disable() {
|
||||
super.disable();
|
||||
this.#disconnectSettings();
|
||||
}
|
||||
|
||||
#connectSettings() {
|
||||
debug.message('Connecting Color Scheme Switcher to settings...');
|
||||
this.#settingsConnections.push({
|
||||
settings: this.#settings,
|
||||
id: this.#settings.connect('changed::day', this.#onColorSchemeChanged.bind(this)),
|
||||
});
|
||||
this.#settingsConnections.push({
|
||||
settings: this.#settings,
|
||||
id: this.#settings.connect('changed::night', this.#onColorSchemeChanged.bind(this)),
|
||||
});
|
||||
this.#settingsConnections.push({
|
||||
settings: this.#interfaceSettings,
|
||||
id: this.#interfaceSettings.connect('changed::color-scheme', this.#onSystemColorSchemeChanged.bind(this)),
|
||||
});
|
||||
}
|
||||
#connectSettings() {
|
||||
debug.message("Connecting Color Scheme Switcher to settings...");
|
||||
this.#settingsConnections.push({
|
||||
settings: this.#settings,
|
||||
id: this.#settings.connect("changed::day", this.#onColorSchemeChanged.bind(this)),
|
||||
});
|
||||
this.#settingsConnections.push({
|
||||
settings: this.#settings,
|
||||
id: this.#settings.connect("changed::night", this.#onColorSchemeChanged.bind(this)),
|
||||
});
|
||||
this.#settingsConnections.push({
|
||||
settings: this.#interfaceSettings,
|
||||
id: this.#interfaceSettings.connect("changed::color-scheme", this.#onSystemColorSchemeChanged.bind(this)),
|
||||
});
|
||||
}
|
||||
|
||||
#disconnectSettings() {
|
||||
this.#settingsConnections.forEach(({ settings, id }) => settings.disconnect(id));
|
||||
this.#settingsConnections = [];
|
||||
debug.message('Disconnected Color Scheme Switcher from settings.');
|
||||
}
|
||||
#disconnectSettings() {
|
||||
this.#settingsConnections.forEach(({ settings, id }) => settings.disconnect(id));
|
||||
this.#settingsConnections = [];
|
||||
debug.message("Disconnected Color Scheme Switcher from settings.");
|
||||
}
|
||||
|
||||
#onTimeChanged(time) {
|
||||
const colorScheme = time === Time.NIGHT ? this.#settings.get_string('night') : this.#settings.get_string('day');
|
||||
this.#interfaceSettings.set_string('color-scheme', colorScheme);
|
||||
}
|
||||
#onTimeChanged(time) {
|
||||
const colorScheme = time === Time.NIGHT ? this.#settings.get_string("night") : this.#settings.get_string("day");
|
||||
this.#interfaceSettings.set_string("color-scheme", colorScheme);
|
||||
}
|
||||
|
||||
#onColorSchemeChanged(_settings, time) {
|
||||
const colorScheme = this.#settings.get_string(time);
|
||||
debug.message(`${time} color scheme changed to ${colorScheme}.`);
|
||||
if (time === this.#timer.time)
|
||||
this.#interfaceSettings.set_string('color-scheme', colorScheme);
|
||||
}
|
||||
#onColorSchemeChanged(_settings, time) {
|
||||
const colorScheme = this.#settings.get_string(time);
|
||||
debug.message(`${time} color scheme changed to ${colorScheme}.`);
|
||||
if (time === this.#timer.time) this.#interfaceSettings.set_string("color-scheme", colorScheme);
|
||||
}
|
||||
|
||||
#onSystemColorSchemeChanged() {
|
||||
const colorScheme = this.#interfaceSettings.get_string('color-scheme');
|
||||
debug.message(`System color scheme changed to ${colorScheme}.`);
|
||||
this.#timer.syncTimeToColorScheme(colorScheme);
|
||||
}
|
||||
#onSystemColorSchemeChanged() {
|
||||
const colorScheme = this.#interfaceSettings.get_string("color-scheme");
|
||||
debug.message(`System color scheme changed to ${colorScheme}.`);
|
||||
this.#timer.syncTimeToColorScheme(colorScheme);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,44 +1,41 @@
|
||||
// SPDX-FileCopyrightText: Night Theme Switcher Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import GLib from 'gi://GLib';
|
||||
import GLib from "gi://GLib";
|
||||
|
||||
import * as debug from '../debug.js';
|
||||
import * as debug from "../debug.js";
|
||||
|
||||
import { Time } from '../enums/Time.js';
|
||||
|
||||
import { Switcher } from './Switcher.js';
|
||||
import { Time } from "../enums/Time.js";
|
||||
|
||||
import { Switcher } from "./Switcher.js";
|
||||
|
||||
/**
|
||||
* The Commands Switcher spawns commands according to the time.
|
||||
*/
|
||||
export class CommandsSwitcher extends Switcher {
|
||||
#settings;
|
||||
#settings;
|
||||
|
||||
/**
|
||||
* @param {object} params Params object.
|
||||
* @param {Timer} params.timer Timer to listen to.
|
||||
*/
|
||||
constructor({ timer }) {
|
||||
const settings = NTS.getSettings(`${NTS.metadata['settings-schema']}.commands`);
|
||||
super({
|
||||
name: 'Command',
|
||||
timer,
|
||||
settings,
|
||||
callback: time => this.#onTimeChanged(time),
|
||||
disableable: true,
|
||||
});
|
||||
this.#settings = settings;
|
||||
}
|
||||
/**
|
||||
* @param {object} params Params object.
|
||||
* @param {import("./Timer.js").Timer} params.timer Timer to listen to.
|
||||
*/
|
||||
constructor({ timer }) {
|
||||
const settings = NTS.getSettings(`${NTS.metadata["settings-schema"]}.commands`);
|
||||
super({
|
||||
name: "Command",
|
||||
timer,
|
||||
settings,
|
||||
callback: (time) => this.#onTimeChanged(time),
|
||||
disableable: true,
|
||||
});
|
||||
this.#settings = settings;
|
||||
}
|
||||
|
||||
#onTimeChanged(time) {
|
||||
if (time === Time.UNKNOWN)
|
||||
return;
|
||||
const command = this.#settings.get_string(time === Time.DAY ? 'sunrise' : 'sunset');
|
||||
if (!command)
|
||||
return;
|
||||
GLib.spawn_async(null, ['sh', '-c', command], null, GLib.SpawnFlags.SEARCH_PATH, null);
|
||||
debug.message(`Spawned ${time} command.`);
|
||||
}
|
||||
#onTimeChanged(time) {
|
||||
if (time === Time.UNKNOWN) return;
|
||||
const command = this.#settings.get_string(time === Time.DAY ? "sunrise" : "sunset");
|
||||
if (!command) return;
|
||||
GLib.spawn_async(null, ["sh", "-c", command], null, GLib.SpawnFlags.SEARCH_PATH, null);
|
||||
debug.message(`Spawned ${time} command.`);
|
||||
}
|
||||
}
|
||||
|
||||
+72
-77
@@ -1,101 +1,96 @@
|
||||
// SPDX-FileCopyrightText: Night Theme Switcher Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import * as debug from '../debug.js';
|
||||
|
||||
import * as debug from "../debug.js";
|
||||
|
||||
/**
|
||||
* Function called when the time changes.
|
||||
*
|
||||
* @callback TimeChangedCallback
|
||||
* @param {Time} time New time.
|
||||
* @param {import("../enums/Time.js").Time} time New time.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* The Switcher runs a callback function when the time changes.
|
||||
*
|
||||
*/
|
||||
export class Switcher {
|
||||
#name;
|
||||
#timer;
|
||||
#settings;
|
||||
#callback;
|
||||
#disableable;
|
||||
#name;
|
||||
#timer;
|
||||
#settings;
|
||||
#callback;
|
||||
#disableable;
|
||||
|
||||
#statusConnection = null;
|
||||
#timerConnection = null;
|
||||
#statusConnection = null;
|
||||
#timerConnection = null;
|
||||
|
||||
/**
|
||||
* @param {object} params Params object.
|
||||
* @param {string} params.name Name of the switcher.
|
||||
* @param {Timer} params.timer Timer to listen to.
|
||||
* @param {Gio.Settings} params.settings Settings.
|
||||
* @param {TimeChangedCallback} params.callback Callback function.
|
||||
* @param {boolean} params.disableable If the switcher can be disabled using an `enabled` key in the settings.
|
||||
*/
|
||||
constructor({ name, timer, settings, callback, disableable = false }) {
|
||||
this.#name = name;
|
||||
this.#timer = timer;
|
||||
this.#settings = settings;
|
||||
this.#callback = callback;
|
||||
this.#disableable = disableable;
|
||||
/**
|
||||
* @param {object} params Params object.
|
||||
* @param {string} params.name Name of the switcher.
|
||||
* @param {import("./Timer.js").Timer} params.timer Timer to listen to.
|
||||
* @param {import("gi://Gio").default.Settings} params.settings Settings.
|
||||
* @param {TimeChangedCallback} params.callback Callback function.
|
||||
* @param {boolean} params.disableable If the switcher can be disabled using an `enabled` key in the settings.
|
||||
*/
|
||||
constructor({ name, timer, settings, callback, disableable = false }) {
|
||||
this.#name = name;
|
||||
this.#timer = timer;
|
||||
this.#settings = settings;
|
||||
this.#callback = callback;
|
||||
this.#disableable = disableable;
|
||||
}
|
||||
|
||||
enable() {
|
||||
debug.message(`Enabling ${this.#name} switcher...`);
|
||||
if (this.#disableable) this.#watchStatus();
|
||||
if (!this.#disableable || this.#settings.get_boolean("enabled")) {
|
||||
this.#connectTimer();
|
||||
this.#onTimeChanged();
|
||||
}
|
||||
debug.message(`${this.#name} switcher enabled.`);
|
||||
}
|
||||
|
||||
enable() {
|
||||
debug.message(`Enabling ${this.#name} switcher...`);
|
||||
if (this.#disableable)
|
||||
this.#watchStatus();
|
||||
if (!this.#disableable || this.#settings.get_boolean('enabled')) {
|
||||
this.#connectTimer();
|
||||
this.#onTimeChanged();
|
||||
}
|
||||
debug.message(`${this.#name} switcher enabled.`);
|
||||
disable() {
|
||||
debug.message(`Disabling ${this.#name} switcher...`);
|
||||
this.#disconnectTimer();
|
||||
if (this.#disableable) this.#unwatchStatus();
|
||||
debug.message(`${this.#name} switcher disabled.`);
|
||||
}
|
||||
|
||||
#watchStatus() {
|
||||
debug.message(`Watching ${this.#name} switching status...`);
|
||||
this.#statusConnection = this.#settings.connect("changed::enabled", this.#onStatusChanged.bind(this));
|
||||
}
|
||||
|
||||
#unwatchStatus() {
|
||||
if (this.#statusConnection) {
|
||||
this.#settings.disconnect(this.#statusConnection);
|
||||
this.#statusConnection = null;
|
||||
}
|
||||
debug.message(`Stopped watching ${this.#name} switching status.`);
|
||||
}
|
||||
|
||||
disable() {
|
||||
debug.message(`Disabling ${this.#name} switcher...`);
|
||||
this.#disconnectTimer();
|
||||
if (this.#disableable)
|
||||
this.#unwatchStatus();
|
||||
debug.message(`${this.#name} switcher disabled.`);
|
||||
#connectTimer() {
|
||||
debug.message(`Connecting ${this.#name} switcher to Timer...`);
|
||||
this.#timerConnection = this.#timer.connect("notify::time", this.#onTimeChanged.bind(this));
|
||||
}
|
||||
|
||||
#disconnectTimer() {
|
||||
if (this.#timerConnection) {
|
||||
this.#timer.disconnect(this.#timerConnection);
|
||||
this.#timerConnection = null;
|
||||
}
|
||||
debug.message(`Disconnected ${this.#name} switcher from Timer.`);
|
||||
}
|
||||
|
||||
#onStatusChanged() {
|
||||
debug.message(
|
||||
`${this.#name} switching has been ${this.#settings.get_boolean("enabled") ? "enabled" : "disabled"}.`,
|
||||
);
|
||||
this.disable();
|
||||
this.enable();
|
||||
}
|
||||
|
||||
#watchStatus() {
|
||||
debug.message(`Watching ${this.#name} switching status...`);
|
||||
this.#statusConnection = this.#settings.connect('changed::enabled', this.#onStatusChanged.bind(this));
|
||||
}
|
||||
|
||||
#unwatchStatus() {
|
||||
if (this.#statusConnection) {
|
||||
this.#settings.disconnect(this.#statusConnection);
|
||||
this.#statusConnection = null;
|
||||
}
|
||||
debug.message(`Stopped watching ${this.#name} switching status.`);
|
||||
}
|
||||
|
||||
#connectTimer() {
|
||||
debug.message(`Connecting ${this.#name} switcher to Timer...`);
|
||||
this.#timerConnection = this.#timer.connect('notify::time', this.#onTimeChanged.bind(this));
|
||||
}
|
||||
|
||||
#disconnectTimer() {
|
||||
if (this.#timerConnection) {
|
||||
this.#timer.disconnect(this.#timerConnection);
|
||||
this.#timerConnection = null;
|
||||
}
|
||||
debug.message(`Disconnected ${this.#name} switcher from Timer.`);
|
||||
}
|
||||
|
||||
|
||||
#onStatusChanged() {
|
||||
debug.message(`${this.#name} switching has been ${this.#settings.get_boolean('enabled') ? 'enabled' : 'disabled'}.`);
|
||||
this.disable();
|
||||
this.enable();
|
||||
}
|
||||
|
||||
#onTimeChanged() {
|
||||
this.#callback(this.#timer.time);
|
||||
}
|
||||
#onTimeChanged() {
|
||||
this.#callback(this.#timer.time);
|
||||
}
|
||||
}
|
||||
|
||||
+330
-319
@@ -1,22 +1,21 @@
|
||||
// SPDX-FileCopyrightText: Night Theme Switcher Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import Geoclue from 'gi://Geoclue';
|
||||
import Gio from 'gi://Gio';
|
||||
import GLib from 'gi://GLib';
|
||||
import GObject from 'gi://GObject';
|
||||
import Meta from 'gi://Meta';
|
||||
import Shell from 'gi://Shell';
|
||||
import Geoclue from "gi://Geoclue";
|
||||
import Gio from "gi://Gio";
|
||||
import GLib from "gi://GLib";
|
||||
import GObject from "gi://GObject";
|
||||
import Meta from "gi://Meta";
|
||||
import Shell from "gi://Shell";
|
||||
|
||||
import { gettext as _ } from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||
import { layoutManager, messageTray, wm } from 'resource:///org/gnome/shell/ui/main.js';
|
||||
import * as MessageTray from 'resource:///org/gnome/shell/ui/messageTray.js';
|
||||
import { gettext as _ } from "resource:///org/gnome/shell/extensions/extension.js";
|
||||
import { layoutManager, messageTray, wm } from "resource:///org/gnome/shell/ui/main.js";
|
||||
import * as MessageTray from "resource:///org/gnome/shell/ui/messageTray.js";
|
||||
|
||||
import * as debug from '../debug.js';
|
||||
|
||||
import { ColorScheme } from '../enums/ColorScheme.js'; // eslint-disable-line no-unused-vars
|
||||
import { Time } from '../enums/Time.js';
|
||||
import * as debug from "../debug.js";
|
||||
|
||||
import { ColorScheme } from "../enums/ColorScheme.js";
|
||||
import { Time } from "../enums/Time.js";
|
||||
|
||||
/**
|
||||
* The Timer is responsible for signaling any time change to the other modules.
|
||||
@@ -28,353 +27,365 @@ import { Time } from '../enums/Time.js';
|
||||
* forced the manual schedule in the preferences.
|
||||
*/
|
||||
export class Timer extends GObject.Object {
|
||||
#settings;
|
||||
#colorSchemeSettings;
|
||||
#interfaceSettings;
|
||||
#locationSettings;
|
||||
#time;
|
||||
#settings;
|
||||
#colorSchemeSettings;
|
||||
#interfaceSettings;
|
||||
#locationSettings;
|
||||
/** @type {Time | undefined} */
|
||||
#time;
|
||||
|
||||
#cancellable = null;
|
||||
#previousKeybinding = null;
|
||||
#timeTimeoutId = null;
|
||||
#geoclue = null;
|
||||
#geoclueLocationConnectionId = null;
|
||||
#suntimesTimeoutId = null;
|
||||
#manuallySetTime = false;
|
||||
#cancellable = null;
|
||||
#previousKeybinding = null;
|
||||
#timeTimeoutId = null;
|
||||
#geoclue = null;
|
||||
#geoclueLocationConnectionId = null;
|
||||
#suntimesTimeoutId = null;
|
||||
#manuallySetTime = false;
|
||||
|
||||
#settingsConnections = [];
|
||||
#settingsConnections = [];
|
||||
|
||||
static {
|
||||
GObject.registerClass({
|
||||
Properties: {
|
||||
time: GObject.ParamSpec.string('time', 'Time', 'Time', GObject.ParamFlags.READWRITE, Time.UNKNOWN),
|
||||
},
|
||||
}, this);
|
||||
static {
|
||||
GObject.registerClass(
|
||||
{
|
||||
Properties: {
|
||||
time: GObject.ParamSpec.string("time", "Time", "Time", GObject.ParamFlags.READWRITE, Time.UNKNOWN),
|
||||
},
|
||||
},
|
||||
this,
|
||||
);
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.#settings = NTS.getSettings(`${NTS.metadata["settings-schema"]}.time`);
|
||||
this.#colorSchemeSettings = NTS.getSettings(`${NTS.metadata["settings-schema"]}.color-scheme`);
|
||||
this.#interfaceSettings = new Gio.Settings({ schema: "org.gnome.desktop.interface" });
|
||||
this.#locationSettings = new Gio.Settings({ schema: "org.gnome.system.location" });
|
||||
}
|
||||
|
||||
enable() {
|
||||
debug.message("Enabling Timer...");
|
||||
this.#cancellable = new Gio.Cancellable();
|
||||
this.#connectSettings();
|
||||
this.#trackTime();
|
||||
if (this.#settings.get_boolean("manual-schedule")) {
|
||||
debug.message("Using the manual schedule.");
|
||||
} else {
|
||||
debug.message("Using location.");
|
||||
this.#trackLocation();
|
||||
this.#trackSuntimes();
|
||||
}
|
||||
this.#addKeybinding();
|
||||
this.#changeTime(this.#computeTime());
|
||||
debug.message("Timer enabled.");
|
||||
}
|
||||
|
||||
disable() {
|
||||
debug.message("Disabling Timer...");
|
||||
this.#removeKeybinding();
|
||||
this.#untrackSuntimes();
|
||||
this.#untrackLocation();
|
||||
this.#untrackTime();
|
||||
this.#disconnectSettings();
|
||||
this.#cancellable.cancel();
|
||||
debug.message("Timer disabled.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ColorScheme} colorScheme Color scheme to sync the time to.
|
||||
*/
|
||||
syncTimeToColorScheme(colorScheme) {
|
||||
this.#changeTime(this.#colorSchemeToTime(colorScheme), true);
|
||||
}
|
||||
|
||||
get time() {
|
||||
return this.#time || Time.UNKNOWN;
|
||||
}
|
||||
|
||||
#changeTime(time, manual = false) {
|
||||
if (time === this.#time) {
|
||||
if (!manual && this.#manuallySetTime) this.#manuallySetTime = false;
|
||||
return;
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.#settings = NTS.getSettings(`${NTS.metadata['settings-schema']}.time`);
|
||||
this.#colorSchemeSettings = NTS.getSettings(`${NTS.metadata['settings-schema']}.color-scheme`);
|
||||
this.#interfaceSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' });
|
||||
this.#locationSettings = new Gio.Settings({ schema: 'org.gnome.system.location' });
|
||||
if (!manual && time !== this.#time && this.#manuallySetTime) return;
|
||||
|
||||
this.#time = time;
|
||||
this.#manuallySetTime = manual;
|
||||
|
||||
debug.message(manual ? `Time manually set to ${time}.` : `Time changed to ${time}.`);
|
||||
|
||||
const isMonitorFullscreen = layoutManager.monitors.some((monitor) => monitor.inFullscreen);
|
||||
if (this.#settings.get_boolean("fullscreen-transition") || !isMonitorFullscreen) {
|
||||
try {
|
||||
layoutManager.screenTransition.run();
|
||||
} catch {}
|
||||
}
|
||||
|
||||
enable() {
|
||||
debug.message('Enabling Timer...');
|
||||
this.#cancellable = new Gio.Cancellable();
|
||||
this.#connectSettings();
|
||||
this.#trackTime();
|
||||
if (this.#settings.get_boolean('manual-schedule')) {
|
||||
debug.message('Using the manual schedule.');
|
||||
} else {
|
||||
debug.message('Using location.');
|
||||
this.#trackLocation();
|
||||
this.#trackSuntimes();
|
||||
}
|
||||
this.#addKeybinding();
|
||||
this.#changeTime(this.#computeTime());
|
||||
debug.message('Timer enabled.');
|
||||
this.notify("time");
|
||||
}
|
||||
|
||||
#connectSettings() {
|
||||
debug.message("Connecting Timer to settings...");
|
||||
this.#settingsConnections.push({
|
||||
settings: this.#locationSettings,
|
||||
id: this.#locationSettings.connect("changed::enabled", this.#onLocationStateChanged.bind(this)),
|
||||
});
|
||||
this.#settingsConnections.push({
|
||||
settings: this.#settings,
|
||||
id: this.#settings.connect("changed::manual-schedule", this.#onManualScheduleStateChanged.bind(this)),
|
||||
});
|
||||
this.#settingsConnections.push({
|
||||
settings: this.#settings,
|
||||
id: this.#settings.connect(
|
||||
"changed::nightthemeswitcher-ondemand-keybinding",
|
||||
this.#onOndemandKeybindingChanged.bind(this),
|
||||
),
|
||||
});
|
||||
// Only listen to the offset setting when not using a manual schedule
|
||||
if (!this.#settings.get_boolean("manual-schedule")) {
|
||||
this.#settingsConnections.push({
|
||||
settings: this.#settings,
|
||||
id: this.#settings.connect("changed::offset", this.#onOffsetChanged.bind(this)),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
disable() {
|
||||
debug.message('Disabling Timer...');
|
||||
this.#removeKeybinding();
|
||||
this.#untrackSuntimes();
|
||||
this.#untrackLocation();
|
||||
this.#untrackTime();
|
||||
this.#disconnectSettings();
|
||||
this.#cancellable.cancel();
|
||||
debug.message('Timer disabled.');
|
||||
#disconnectSettings() {
|
||||
this.#settingsConnections.forEach(({ settings, id }) => settings.disconnect(id));
|
||||
this.#settingsConnections = [];
|
||||
debug.message("Disconnected Timer from settings.");
|
||||
}
|
||||
|
||||
#trackTime() {
|
||||
debug.message("Watching for time change...");
|
||||
this.#timeTimeoutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, () => {
|
||||
this.#changeTime(this.#computeTime());
|
||||
return GLib.SOURCE_CONTINUE;
|
||||
});
|
||||
}
|
||||
|
||||
#untrackTime() {
|
||||
if (this.#timeTimeoutId) {
|
||||
GLib.Source.remove(this.#timeTimeoutId);
|
||||
this.#timeTimeoutId = null;
|
||||
}
|
||||
debug.message("Stopped watching for time change.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ColorScheme} colorScheme Color scheme to sync the time to.
|
||||
*/
|
||||
syncTimeToColorScheme(colorScheme) {
|
||||
this.#changeTime(this.#colorSchemeToTime(colorScheme), true);
|
||||
#trackLocation() {
|
||||
debug.message("Connecting to GeoClue...");
|
||||
Geoclue.Simple.new(
|
||||
"org.gnome.Shell",
|
||||
Geoclue.AccuracyLevel.CITY,
|
||||
this.#cancellable,
|
||||
this.#onGeoclueReady.bind(this),
|
||||
);
|
||||
}
|
||||
|
||||
#untrackLocation() {
|
||||
debug.message("Disconnecting from GeoClue...");
|
||||
if (this.#geoclue && this.#geoclueLocationConnectionId) {
|
||||
this.#geoclue.disconnect(this.#geoclueLocationConnectionId);
|
||||
this.#geoclueLocationConnectionId = null;
|
||||
this.#geoclue = null;
|
||||
}
|
||||
debug.message("Disconnected from GeoClue.");
|
||||
}
|
||||
|
||||
#trackSuntimes() {
|
||||
debug.message("Regularly updating sun times...");
|
||||
this.#suntimesTimeoutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 3600, () => {
|
||||
this.#updateSuntimes();
|
||||
return GLib.SOURCE_CONTINUE;
|
||||
});
|
||||
}
|
||||
|
||||
get time() {
|
||||
return this.#time || Time.UNKNOWN;
|
||||
#untrackSuntimes() {
|
||||
if (this.#suntimesTimeoutId) {
|
||||
GLib.Source.remove(this.#suntimesTimeoutId);
|
||||
this.#suntimesTimeoutId = null;
|
||||
}
|
||||
debug.message("Stopped regularly updating sun times.");
|
||||
}
|
||||
|
||||
#changeTime(time, manual = false) {
|
||||
if (time === this.#time) {
|
||||
if (!manual && this.#manuallySetTime)
|
||||
this.#manuallySetTime = false;
|
||||
return;
|
||||
}
|
||||
#addKeybinding() {
|
||||
this.#previousKeybinding = this.#settings.get_strv("nightthemeswitcher-ondemand-keybinding")[0];
|
||||
if (!this.#settings.get_strv("nightthemeswitcher-ondemand-keybinding")[0]) return;
|
||||
debug.message("Adding keybinding...");
|
||||
wm.addKeybinding(
|
||||
"nightthemeswitcher-ondemand-keybinding",
|
||||
this.#settings,
|
||||
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
|
||||
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
|
||||
() => {
|
||||
const time = this.time === Time.NIGHT ? Time.DAY : Time.NIGHT;
|
||||
this.#changeTime(time, true);
|
||||
},
|
||||
);
|
||||
debug.message("Added keybinding.");
|
||||
}
|
||||
|
||||
if (!manual && time !== this.#time && this.#manuallySetTime)
|
||||
return;
|
||||
|
||||
this.#time = time;
|
||||
this.#manuallySetTime = manual;
|
||||
|
||||
debug.message(manual ? `Time manually set to ${time}.` : `Time changed to ${time}.`);
|
||||
|
||||
const isMonitorFullscreen = layoutManager.monitors.some(monitor => monitor.inFullscreen);
|
||||
if (this.#settings.get_boolean('fullscreen-transition') || !isMonitorFullscreen) {
|
||||
try {
|
||||
layoutManager.screenTransition.run();
|
||||
} catch {}
|
||||
}
|
||||
|
||||
this.notify('time');
|
||||
#removeKeybinding() {
|
||||
if (this.#previousKeybinding) {
|
||||
debug.message("Removing keybinding...");
|
||||
wm.removeKeybinding("nightthemeswitcher-ondemand-keybinding");
|
||||
debug.message("Removed keybinding.");
|
||||
}
|
||||
}
|
||||
|
||||
#colorSchemeToTime(colorScheme) {
|
||||
return colorScheme === this.#colorSchemeSettings.get_string("night") ? Time.NIGHT : Time.DAY;
|
||||
}
|
||||
|
||||
#connectSettings() {
|
||||
debug.message('Connecting Timer to settings...');
|
||||
this.#settingsConnections.push({
|
||||
settings: this.#locationSettings,
|
||||
id: this.#locationSettings.connect('changed::enabled', this.#onLocationStateChanged.bind(this)),
|
||||
});
|
||||
this.#settingsConnections.push({
|
||||
settings: this.#settings,
|
||||
id: this.#settings.connect('changed::manual-schedule', this.#onManualScheduleStateChanged.bind(this)),
|
||||
});
|
||||
this.#settingsConnections.push({
|
||||
settings: this.#settings,
|
||||
id: this.#settings.connect('changed::nightthemeswitcher-ondemand-keybinding', this.#onOndemandKeybindingChanged.bind(this)),
|
||||
});
|
||||
// Only listen to the offset setting when not using a manual schedule
|
||||
if (!this.#settings.get_boolean('manual-schedule')) {
|
||||
this.#settingsConnections.push({
|
||||
settings: this.#settings,
|
||||
id: this.#settings.connect('changed::offset', this.#onOffsetChanged.bind(this)),
|
||||
});
|
||||
}
|
||||
}
|
||||
#onLocationStateChanged() {
|
||||
this.disable();
|
||||
this.enable();
|
||||
}
|
||||
|
||||
#disconnectSettings() {
|
||||
this.#settingsConnections.forEach(({ settings, id }) => settings.disconnect(id));
|
||||
this.#settingsConnections = [];
|
||||
debug.message('Disconnected Timer from settings.');
|
||||
}
|
||||
#onManualScheduleStateChanged() {
|
||||
this.disable();
|
||||
this.enable();
|
||||
}
|
||||
|
||||
#onOffsetChanged() {
|
||||
this.#updateSuntimes();
|
||||
}
|
||||
|
||||
#trackTime() {
|
||||
debug.message('Watching for time change...');
|
||||
this.#timeTimeoutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, () => {
|
||||
this.#changeTime(this.#computeTime());
|
||||
return GLib.SOURCE_CONTINUE;
|
||||
});
|
||||
}
|
||||
#onOndemandKeybindingChanged() {
|
||||
this.#removeKeybinding();
|
||||
this.#addKeybinding();
|
||||
}
|
||||
|
||||
#untrackTime() {
|
||||
if (this.#timeTimeoutId) {
|
||||
GLib.Source.remove(this.#timeTimeoutId);
|
||||
this.#timeTimeoutId = null;
|
||||
}
|
||||
debug.message('Stopped watching for time change.');
|
||||
}
|
||||
|
||||
|
||||
#trackLocation() {
|
||||
debug.message('Connecting to GeoClue...');
|
||||
Geoclue.Simple.new(
|
||||
'org.gnome.Shell',
|
||||
Geoclue.AccuracyLevel.CITY,
|
||||
this.#cancellable,
|
||||
this.#onGeoclueReady.bind(this)
|
||||
#onGeoclueReady(_geoclue, result) {
|
||||
try {
|
||||
this.#geoclue = Geoclue.Simple.new_finish(result);
|
||||
this.#geoclueLocationConnectionId = this.#geoclue.connect("notify::location", this.#onLocationChanged.bind(this));
|
||||
debug.message("Connected to GeoClue.");
|
||||
this.#onLocationChanged();
|
||||
} catch (e) {
|
||||
const [latitude, longitude] = this.#settings.get_value("location").deepUnpack();
|
||||
if (latitude >= -90 && latitude <= 90 && longitude >= -180 && longitude <= 180) {
|
||||
console.error(
|
||||
`[${NTS.metadata.name}] Unable to retrieve the location, using the last known location instead.\n${e}`,
|
||||
);
|
||||
}
|
||||
|
||||
#untrackLocation() {
|
||||
debug.message('Disconnecting from GeoClue...');
|
||||
if (this.#geoclue && this.#geoclueLocationConnectionId) {
|
||||
this.#geoclue.disconnect(this.#geoclueLocationConnectionId);
|
||||
this.#geoclueLocationConnectionId = null;
|
||||
this.#geoclue = null;
|
||||
}
|
||||
debug.message('Disconnected from GeoClue.');
|
||||
}
|
||||
|
||||
|
||||
#trackSuntimes() {
|
||||
debug.message('Regularly updating sun times...');
|
||||
this.#suntimesTimeoutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 3600, () => {
|
||||
this.#updateSuntimes();
|
||||
return GLib.SOURCE_CONTINUE;
|
||||
});
|
||||
}
|
||||
|
||||
#untrackSuntimes() {
|
||||
if (this.#suntimesTimeoutId) {
|
||||
GLib.Source.remove(this.#suntimesTimeoutId);
|
||||
this.#suntimesTimeoutId = null;
|
||||
}
|
||||
debug.message('Stopped regularly updating sun times.');
|
||||
}
|
||||
|
||||
|
||||
#addKeybinding() {
|
||||
this.#previousKeybinding = this.#settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0];
|
||||
if (!this.#settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0])
|
||||
return;
|
||||
debug.message('Adding keybinding...');
|
||||
wm.addKeybinding(
|
||||
'nightthemeswitcher-ondemand-keybinding',
|
||||
this.#settings,
|
||||
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
|
||||
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
|
||||
() => {
|
||||
const time = this.time === Time.NIGHT ? Time.DAY : Time.NIGHT;
|
||||
this.#changeTime(time, true);
|
||||
}
|
||||
this.#updateSuntimes();
|
||||
} else {
|
||||
console.error(
|
||||
`[${NTS.metadata.name}] Unable to retrieve the location, using the manual schedule times instead.\n${e}`,
|
||||
);
|
||||
debug.message('Added keybinding.');
|
||||
|
||||
const source = new MessageTray.Source({
|
||||
title: NTS.metadata.name,
|
||||
icon: Gio.icon_new_for_string(
|
||||
GLib.build_filenamev([NTS.metadata.path, "icons", "nightthemeswitcher-symbolic.svg"]),
|
||||
),
|
||||
});
|
||||
messageTray.add(source);
|
||||
|
||||
const notification = new MessageTray.Notification({
|
||||
source,
|
||||
title: _("Unknown Location"),
|
||||
body: _("A manual schedule will be used to switch the dark mode."),
|
||||
"icon-name": "location-services-disabled-symbolic",
|
||||
});
|
||||
notification.addAction(_("Edit Manual Schedule"), () => NTS.openPreferences());
|
||||
|
||||
notification.connect("activated", () => NTS.openPreferences());
|
||||
|
||||
source.addNotification(notification);
|
||||
|
||||
this.#settings.set_boolean("manual-schedule", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#removeKeybinding() {
|
||||
if (this.#previousKeybinding) {
|
||||
debug.message('Removing keybinding...');
|
||||
wm.removeKeybinding('nightthemeswitcher-ondemand-keybinding');
|
||||
debug.message('Removed keybinding.');
|
||||
}
|
||||
}
|
||||
#onLocationChanged(_geoclue, _location) {
|
||||
debug.message("Location has changed.");
|
||||
const { latitude, longitude } = this.#geoclue.get_location();
|
||||
this.#settings.set_value("location", new GLib.Variant("(dd)", [latitude, longitude]));
|
||||
debug.message(`Current location: (${latitude};${longitude})`);
|
||||
this.#updateSuntimes();
|
||||
}
|
||||
|
||||
#computeTime() {
|
||||
const sunrise = this.#settings.get_double("sunrise");
|
||||
const sunset = this.#settings.get_double("sunset");
|
||||
const datetime = GLib.DateTime.new_now_local();
|
||||
const hour = datetime.get_hour() + datetime.get_minute() / 60 + datetime.get_second() / 3600;
|
||||
|
||||
#colorSchemeToTime(colorScheme) {
|
||||
return colorScheme === this.#colorSchemeSettings.get_string('night') ? Time.NIGHT : Time.DAY;
|
||||
}
|
||||
// Regular schedule
|
||||
if (sunrise < sunset) return hour >= sunrise && hour < sunset ? Time.DAY : Time.NIGHT;
|
||||
// Sunset happens on the day after
|
||||
else if (sunrise > sunset) return hour >= sunrise || hour < sunset ? Time.DAY : Time.NIGHT;
|
||||
// Sunset and Sunrise times are identical; preserve current theme
|
||||
else return this.#time || this.#colorSchemeToTime(this.#interfaceSettings.get_string("color-scheme"));
|
||||
}
|
||||
|
||||
#updateSuntimes() {
|
||||
const [latitude, longitude] = this.#settings.get_value("location").deepUnpack();
|
||||
|
||||
#onLocationStateChanged() {
|
||||
this.disable();
|
||||
this.enable();
|
||||
}
|
||||
if (latitude < -90 && latitude > 90 && longitude < -180 && longitude > 180) return;
|
||||
|
||||
#onManualScheduleStateChanged() {
|
||||
this.disable();
|
||||
this.enable();
|
||||
}
|
||||
debug.message("Updating sun times...");
|
||||
|
||||
#onOffsetChanged() {
|
||||
this.#updateSuntimes();
|
||||
}
|
||||
const rad = (degrees) => (degrees * Math.PI) / 180;
|
||||
const deg = (radians) => (radians * 180) / Math.PI;
|
||||
|
||||
#onOndemandKeybindingChanged() {
|
||||
this.#removeKeybinding();
|
||||
this.#addKeybinding();
|
||||
}
|
||||
// Calculations from https://www.esrl.noaa.gov/gmd/grad/solcalc/calcdetails.html
|
||||
const dtNow = GLib.DateTime.new_now_local();
|
||||
const dtZero = GLib.DateTime.new_utc(1900, 1, 1, 0, 0, 0);
|
||||
|
||||
#onGeoclueReady(_geoclue, result) {
|
||||
try {
|
||||
this.#geoclue = Geoclue.Simple.new_finish(result);
|
||||
this.#geoclueLocationConnectionId = this.#geoclue.connect('notify::location', this.#onLocationChanged.bind(this));
|
||||
debug.message('Connected to GeoClue.');
|
||||
this.#onLocationChanged();
|
||||
} catch (e) {
|
||||
const [latitude, longitude] = this.#settings.get_value('location').deepUnpack();
|
||||
if (latitude >= -90 && latitude <= 90 && longitude >= -180 && longitude <= 180) {
|
||||
console.error(`[${NTS.metadata.name}] Unable to retrieve the location, using the last known location instead.\n${e}`);
|
||||
this.#updateSuntimes();
|
||||
} else {
|
||||
console.error(`[${NTS.metadata.name}] Unable to retrieve the location, using the manual schedule times instead.\n${e}`);
|
||||
const timeSpan = dtNow.difference(dtZero);
|
||||
|
||||
const source = new MessageTray.Source({
|
||||
title: NTS.metadata.name,
|
||||
icon: Gio.icon_new_for_string(GLib.build_filenamev([NTS.metadata.path, 'icons', 'nightthemeswitcher-symbolic.svg'])),
|
||||
});
|
||||
messageTray.add(source);
|
||||
const date = timeSpan / 1000 / 1000 / 60 / 60 / 24 + 2;
|
||||
const tzOffset = dtNow.get_utc_offset() / 1000 / 1000 / 60 / 60;
|
||||
|
||||
const notification = new MessageTray.Notification(
|
||||
{
|
||||
source,
|
||||
title: _('Unknown Location'),
|
||||
body: _('A manual schedule will be used to switch the dark mode.'),
|
||||
'icon-name': 'location-services-disabled-symbolic',
|
||||
}
|
||||
);
|
||||
notification.addAction(_('Edit Manual Schedule'), () => NTS.openPreferences());
|
||||
const julianDay = date + 2415018.5 - tzOffset / 24;
|
||||
const julianCentury = (julianDay - 2451545) / 36525;
|
||||
const geomMeanLongSun = (280.46646 + julianCentury * (36000.76983 + julianCentury * 0.0003032)) % 360;
|
||||
const geomMeanAnomSun = 357.52911 + julianCentury * (35999.05029 - 0.0001537 * julianCentury);
|
||||
const eccentEarthOrbit = 0.016708634 - julianCentury * (0.000042037 + 0.0000001267 * julianCentury);
|
||||
const sunEqOfCtr =
|
||||
Math.sin(rad(geomMeanAnomSun)) * (1.914602 - julianCentury * (0.004817 + 0.000014 * julianCentury)) +
|
||||
Math.sin(rad(2 * geomMeanAnomSun)) * (0.019993 - 0.000101 * julianCentury) +
|
||||
Math.sin(rad(3 * geomMeanAnomSun)) * 0.000289;
|
||||
const sunTrueLong = geomMeanLongSun + sunEqOfCtr;
|
||||
const sunAppLong = sunTrueLong - 0.00569 - 0.00478 * Math.sin(rad(125.04 - 1934.136 * julianCentury));
|
||||
const meanObliqEcliptic =
|
||||
23 + (26 + (21.448 - julianCentury * (46.815 + julianCentury * (0.00059 - julianCentury * 0.001813))) / 60) / 60;
|
||||
const obliqCorr = meanObliqEcliptic + 0.00256 * Math.cos(rad(125.04 - 1934.136 * julianCentury));
|
||||
const sunDeclin = deg(Math.asin(Math.sin(rad(obliqCorr)) * Math.sin(rad(sunAppLong))));
|
||||
const varY = Math.tan(rad(obliqCorr / 2)) * Math.tan(rad(obliqCorr / 2));
|
||||
const eqOfTime =
|
||||
4 *
|
||||
deg(
|
||||
varY * Math.sin(2 * rad(geomMeanLongSun)) -
|
||||
2 * eccentEarthOrbit * Math.sin(rad(geomMeanAnomSun)) +
|
||||
4 * eccentEarthOrbit * varY * Math.sin(rad(geomMeanAnomSun)) * Math.cos(2 * rad(geomMeanLongSun)) -
|
||||
0.5 * varY * varY * Math.sin(4 * rad(geomMeanLongSun)) -
|
||||
1.25 * eccentEarthOrbit * eccentEarthOrbit * Math.sin(2 * rad(geomMeanAnomSun)),
|
||||
);
|
||||
const haSunrise = deg(
|
||||
Math.acos(
|
||||
Math.cos(rad(90.833)) / (Math.cos(rad(latitude)) * Math.cos(rad(sunDeclin))) -
|
||||
Math.tan(rad(latitude)) * Math.tan(rad(sunDeclin)),
|
||||
),
|
||||
);
|
||||
const solarNoon = (720 - 4 * longitude - eqOfTime + tzOffset * 60) / 1440;
|
||||
|
||||
notification.connect('activated', () => NTS.openPreferences());
|
||||
const timeSunrise = solarNoon - (haSunrise * 4) / 1440;
|
||||
const timeSunset = solarNoon + (haSunrise * 4) / 1440;
|
||||
|
||||
source.addNotification(notification);
|
||||
const modulo = (n, m) => ((n % m) + m) % m;
|
||||
|
||||
this.#settings.set_boolean('manual-schedule', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
const offset = this.#settings.get_double("offset");
|
||||
const sunrise = modulo(timeSunrise * 24 + offset, 24);
|
||||
const sunset = modulo(timeSunset * 24 - offset, 24);
|
||||
|
||||
#onLocationChanged(_geoclue, _location) {
|
||||
debug.message('Location has changed.');
|
||||
const { latitude, longitude } = this.#geoclue.get_location();
|
||||
this.#settings.set_value('location', new GLib.Variant('(dd)', [latitude, longitude]));
|
||||
debug.message(`Current location: (${latitude};${longitude})`);
|
||||
this.#updateSuntimes();
|
||||
}
|
||||
this.#settings.set_double("sunrise", sunrise);
|
||||
this.#settings.set_double("sunset", sunset);
|
||||
|
||||
|
||||
#computeTime() {
|
||||
const sunrise = this.#settings.get_double('sunrise');
|
||||
const sunset = this.#settings.get_double('sunset');
|
||||
const datetime = GLib.DateTime.new_now_local();
|
||||
const hour = datetime.get_hour() + datetime.get_minute() / 60 + datetime.get_second() / 3600;
|
||||
|
||||
// Regular schedule
|
||||
if (sunrise < sunset)
|
||||
return hour >= sunrise && hour < sunset ? Time.DAY : Time.NIGHT;
|
||||
// Sunset happens on the day after
|
||||
else if (sunrise > sunset)
|
||||
return hour >= sunrise || hour < sunset ? Time.DAY : Time.NIGHT;
|
||||
// Sunset and Sunrise times are identical; preserve current theme
|
||||
else
|
||||
return this.#time || this.#colorSchemeToTime(this.#interfaceSettings.get_string('color-scheme'));
|
||||
}
|
||||
|
||||
#updateSuntimes() {
|
||||
const [latitude, longitude] = this.#settings.get_value('location').deepUnpack();
|
||||
|
||||
if (latitude < -90 && latitude > 90 && longitude < -180 && longitude > 180)
|
||||
return;
|
||||
|
||||
debug.message('Updating sun times...');
|
||||
|
||||
const rad = degrees => degrees * Math.PI / 180;
|
||||
const deg = radians => radians * 180 / Math.PI;
|
||||
|
||||
// Calculations from https://www.esrl.noaa.gov/gmd/grad/solcalc/calcdetails.html
|
||||
const dtNow = GLib.DateTime.new_now_local();
|
||||
const dtZero = GLib.DateTime.new_utc(1900, 1, 1, 0, 0, 0);
|
||||
|
||||
const timeSpan = dtNow.difference(dtZero);
|
||||
|
||||
const date = timeSpan / 1000 / 1000 / 60 / 60 / 24 + 2;
|
||||
const tzOffset = dtNow.get_utc_offset() / 1000 / 1000 / 60 / 60;
|
||||
|
||||
const julianDay = date + 2415018.5 - tzOffset / 24;
|
||||
const julianCentury = (julianDay - 2451545) / 36525;
|
||||
const geomMeanLongSun = (280.46646 + julianCentury * (36000.76983 + julianCentury * 0.0003032)) % 360;
|
||||
const geomMeanAnomSun = 357.52911 + julianCentury * (35999.05029 - 0.0001537 * julianCentury);
|
||||
const eccentEarthOrbit = 0.016708634 - julianCentury * (0.000042037 + 0.0000001267 * julianCentury);
|
||||
const sunEqOfCtr = Math.sin(rad(geomMeanAnomSun)) * (1.914602 - julianCentury * (0.004817 + 0.000014 * julianCentury)) + Math.sin(rad(2 * geomMeanAnomSun)) * (0.019993 - 0.000101 * julianCentury) + Math.sin(rad(3 * geomMeanAnomSun)) * 0.000289;
|
||||
const sunTrueLong = geomMeanLongSun + sunEqOfCtr;
|
||||
const sunAppLong = sunTrueLong - 0.00569 - 0.00478 * Math.sin(rad(125.04 - 1934.136 * julianCentury));
|
||||
const meanObliqEcliptic = 23 + (26 + ((21.448 - julianCentury * (46.815 + julianCentury * (0.00059 - julianCentury * 0.001813)))) / 60) / 60;
|
||||
const obliqCorr = meanObliqEcliptic + 0.00256 * Math.cos(rad(125.04 - 1934.136 * julianCentury));
|
||||
const sunDeclin = deg(Math.asin(Math.sin(rad(obliqCorr)) * Math.sin(rad(sunAppLong))));
|
||||
const varY = Math.tan(rad(obliqCorr / 2)) * Math.tan(rad(obliqCorr / 2));
|
||||
const eqOfTime = 4 * deg(varY * Math.sin(2 * rad(geomMeanLongSun)) - 2 * eccentEarthOrbit * Math.sin(rad(geomMeanAnomSun)) + 4 * eccentEarthOrbit * varY * Math.sin(rad(geomMeanAnomSun)) * Math.cos(2 * rad(geomMeanLongSun)) - 0.5 * varY * varY * Math.sin(4 * rad(geomMeanLongSun)) - 1.25 * eccentEarthOrbit * eccentEarthOrbit * Math.sin(2 * rad(geomMeanAnomSun)));
|
||||
const haSunrise = deg(Math.acos(Math.cos(rad(90.833)) / (Math.cos(rad(latitude)) * Math.cos(rad(sunDeclin))) - Math.tan(rad(latitude)) * Math.tan(rad(sunDeclin))));
|
||||
const solarNoon = (720 - 4 * longitude - eqOfTime + tzOffset * 60) / 1440;
|
||||
|
||||
const timeSunrise = solarNoon - haSunrise * 4 / 1440;
|
||||
const timeSunset = solarNoon + haSunrise * 4 / 1440;
|
||||
|
||||
const modulo = (n, m) => ((n % m) + m) % m;
|
||||
|
||||
const offset = this.#settings.get_double('offset');
|
||||
const sunrise = modulo(timeSunrise * 24 + offset, 24);
|
||||
const sunset = modulo(timeSunset * 24 - offset, 24);
|
||||
|
||||
this.#settings.set_double('sunrise', sunrise);
|
||||
this.#settings.set_double('sunset', sunset);
|
||||
|
||||
debug.message(`New sun times: (sunrise: ${sunrise}; sunset: ${sunset})`);
|
||||
}
|
||||
debug.message(`New sun times: (sunrise: ${sunrise}; sunset: ${sunset})`);
|
||||
}
|
||||
}
|
||||
|
||||
+171
-165
@@ -1,184 +1,190 @@
|
||||
// SPDX-FileCopyrightText: Night Theme Switcher Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import Adw from 'gi://Adw';
|
||||
import Gdk from 'gi://Gdk';
|
||||
import GdkPixbuf from 'gi://GdkPixbuf';
|
||||
import Gio from 'gi://Gio';
|
||||
import GLib from 'gi://GLib';
|
||||
import GObject from 'gi://GObject';
|
||||
import Gtk from 'gi://Gtk';
|
||||
import Adw from "gi://Adw";
|
||||
import Gdk from "gi://Gdk";
|
||||
import GdkPixbuf from "gi://GdkPixbuf";
|
||||
import Gio from "gi://Gio";
|
||||
import GLib from "gi://GLib";
|
||||
import GObject from "gi://GObject";
|
||||
import Gtk from "gi://Gtk";
|
||||
|
||||
import { gettext as _ } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
|
||||
|
||||
|
||||
Gio._promisify(Gtk.FileDialog.prototype, 'open', 'open_finish');
|
||||
import { gettext as _ } from "resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js";
|
||||
|
||||
Gio._promisify(Gtk.FileDialog.prototype, "open", "open_finish");
|
||||
|
||||
export class BackgroundButton extends Gtk.Button {
|
||||
#uri;
|
||||
#uri;
|
||||
|
||||
static {
|
||||
GObject.registerClass({
|
||||
GTypeName: 'BackgroundButton',
|
||||
Template: 'resource:///org/gnome/Shell/Extensions/nightthemeswitcher/preferences/ui/BackgroundButton.ui',
|
||||
InternalChildren: ['file_dialog', 'thumbnail'],
|
||||
Properties: {
|
||||
uri: GObject.ParamSpec.string(
|
||||
'uri',
|
||||
'URI',
|
||||
'URI to the background file',
|
||||
GObject.ParamFlags.READWRITE,
|
||||
null
|
||||
),
|
||||
thumbWidth: GObject.ParamSpec.int(
|
||||
'thumb-width',
|
||||
'Thumbnail width',
|
||||
'Width of the displayed thumbnail',
|
||||
GObject.ParamFlags.READWRITE,
|
||||
0, 600,
|
||||
180
|
||||
),
|
||||
thumbHeight: GObject.ParamSpec.int(
|
||||
'thumb-height',
|
||||
'Thumbnail height',
|
||||
'Height of the displayed thumbnail',
|
||||
GObject.ParamFlags.READWRITE,
|
||||
0, 600,
|
||||
180
|
||||
),
|
||||
},
|
||||
}, this);
|
||||
}
|
||||
static {
|
||||
GObject.registerClass(
|
||||
{
|
||||
GTypeName: "BackgroundButton",
|
||||
Template: "resource:///org/gnome/Shell/Extensions/nightthemeswitcher/preferences/ui/BackgroundButton.ui",
|
||||
InternalChildren: ["file_dialog", "thumbnail"],
|
||||
Properties: {
|
||||
uri: GObject.ParamSpec.string("uri", "URI", "URI to the background file", GObject.ParamFlags.READWRITE, null),
|
||||
thumbWidth: GObject.ParamSpec.int(
|
||||
"thumb-width",
|
||||
"Thumbnail width",
|
||||
"Width of the displayed thumbnail",
|
||||
GObject.ParamFlags.READWRITE,
|
||||
0,
|
||||
600,
|
||||
180,
|
||||
),
|
||||
thumbHeight: GObject.ParamSpec.int(
|
||||
"thumb-height",
|
||||
"Thumbnail height",
|
||||
"Height of the displayed thumbnail",
|
||||
GObject.ParamFlags.READWRITE,
|
||||
0,
|
||||
600,
|
||||
180,
|
||||
),
|
||||
},
|
||||
},
|
||||
this,
|
||||
);
|
||||
}
|
||||
|
||||
constructor({ ...params } = {}) {
|
||||
super(params);
|
||||
this.#setupSize();
|
||||
this.#setupDropTarget();
|
||||
this.#setupFileDialog();
|
||||
}
|
||||
constructor({ ...params } = {}) {
|
||||
super(params);
|
||||
this.#setupSize();
|
||||
this.#setupDropTarget();
|
||||
this.#setupFileDialog();
|
||||
}
|
||||
|
||||
get uri() {
|
||||
return this.#uri || null;
|
||||
}
|
||||
get uri() {
|
||||
return this.#uri || null;
|
||||
}
|
||||
|
||||
set uri(uri) {
|
||||
if (uri === this.#uri)
|
||||
return;
|
||||
this.#uri = uri;
|
||||
this.notify('uri');
|
||||
GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
|
||||
this.#updateThumbnail();
|
||||
return GLib.SOURCE_REMOVE;
|
||||
});
|
||||
}
|
||||
set uri(uri) {
|
||||
if (uri === this.#uri) return;
|
||||
this.#uri = uri;
|
||||
this.notify("uri");
|
||||
GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
|
||||
this.#updateThumbnail();
|
||||
return GLib.SOURCE_REMOVE;
|
||||
});
|
||||
}
|
||||
|
||||
#setupSize() {
|
||||
const display = Gdk.Display.get_default();
|
||||
const monitor = display.get_monitors().get_item(0);
|
||||
if (monitor.width_mm === 0 || monitor.height_mm === 0)
|
||||
return;
|
||||
if (monitor.width_mm > monitor.height_mm)
|
||||
this.thumbHeight *= monitor.height_mm / monitor.width_mm;
|
||||
else
|
||||
this.thumbWidth *= monitor.width_mm / monitor.height_mm;
|
||||
}
|
||||
#setupSize() {
|
||||
const display = Gdk.Display.get_default();
|
||||
const monitor = display.get_monitors().get_item(0);
|
||||
if (monitor.width_mm === 0 || monitor.height_mm === 0) return;
|
||||
if (monitor.width_mm > monitor.height_mm) this.thumbHeight *= monitor.height_mm / monitor.width_mm;
|
||||
else this.thumbWidth *= monitor.width_mm / monitor.height_mm;
|
||||
}
|
||||
|
||||
#setupDropTarget() {
|
||||
const dropTarget = Gtk.DropTarget.new(Gio.File.$gtype, Gdk.DragAction.COPY);
|
||||
dropTarget.connect('drop', (_target, file, _x, _y) => {
|
||||
const contentType = Gio.content_type_guess(file.get_basename(), null)[0];
|
||||
if (this.#isContentTypeSupported(contentType)) {
|
||||
this.uri = file.get_uri();
|
||||
return true;
|
||||
} else {
|
||||
if (this.root instanceof Adw.PreferencesWindow) {
|
||||
this.root.add_toast(new Adw.Toast({
|
||||
title: _('This image format is not supported.'),
|
||||
timeout: 10,
|
||||
}));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
this.add_controller(dropTarget);
|
||||
}
|
||||
|
||||
#setupFileDialog() {
|
||||
const filter = new Gtk.FileFilter();
|
||||
filter.set_name(_('Image files'));
|
||||
this.#getSupportedContentTypes().forEach(type => filter.add_mime_type(type));
|
||||
this._file_dialog.filters = Gio.ListStore.new(Gtk.FileFilter);
|
||||
this._file_dialog.filters.append(filter);
|
||||
}
|
||||
|
||||
#getSupportedContentTypes() {
|
||||
return GdkPixbuf.Pixbuf.get_formats().flatMap(format => format.get_mime_types()).concat('application/xml');
|
||||
}
|
||||
|
||||
#isContentTypeSupported(contentType) {
|
||||
for (const supportedContentType of this.#getSupportedContentTypes()) {
|
||||
if (Gio.content_type_equals(contentType, supportedContentType))
|
||||
return true;
|
||||
#setupDropTarget() {
|
||||
const dropTarget = Gtk.DropTarget.new(Gio.File.$gtype, Gdk.DragAction.COPY);
|
||||
dropTarget.connect("drop", (_target, file, _x, _y) => {
|
||||
const contentType = Gio.content_type_guess(file.get_basename(), null)[0];
|
||||
if (this.#isContentTypeSupported(contentType)) {
|
||||
this.uri = file.get_uri();
|
||||
return true;
|
||||
} else {
|
||||
if (this.root instanceof Adw.PreferencesWindow) {
|
||||
this.root.add_toast(
|
||||
new Adw.Toast({
|
||||
title: _("This image format is not supported."),
|
||||
timeout: 10,
|
||||
}),
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
this.add_controller(dropTarget);
|
||||
}
|
||||
|
||||
#setupFileDialog() {
|
||||
const filter = new Gtk.FileFilter();
|
||||
filter.set_name(_("Image files"));
|
||||
this.#getSupportedContentTypes().forEach((type) => filter.add_mime_type(type));
|
||||
this._file_dialog.filters = Gio.ListStore.new(Gtk.FileFilter);
|
||||
this._file_dialog.filters.append(filter);
|
||||
}
|
||||
|
||||
#getSupportedContentTypes() {
|
||||
return GdkPixbuf.Pixbuf.get_formats()
|
||||
.flatMap((format) => format.get_mime_types())
|
||||
.concat("application/xml");
|
||||
}
|
||||
|
||||
#isContentTypeSupported(contentType) {
|
||||
for (const supportedContentType of this.#getSupportedContentTypes()) {
|
||||
if (Gio.content_type_equals(contentType, supportedContentType)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
vfunc_mnemonic_activate() {
|
||||
this.#setURIFromFileDialog();
|
||||
}
|
||||
|
||||
onClicked(_button) {
|
||||
this.#setURIFromFileDialog();
|
||||
}
|
||||
|
||||
async #setURIFromFileDialog() {
|
||||
try {
|
||||
const file = await this._file_dialog.open(this.get_root(), null);
|
||||
this.uri = file.get_uri();
|
||||
} catch {}
|
||||
}
|
||||
|
||||
#updateThumbnail() {
|
||||
this._thumbnail.paintable = null;
|
||||
|
||||
if (!this.uri) return;
|
||||
|
||||
const file = Gio.File.new_for_uri(this.uri);
|
||||
const contentType = Gio.content_type_guess(file.get_basename(), null)[0];
|
||||
|
||||
if (!this.#isContentTypeSupported(contentType)) return;
|
||||
|
||||
let path;
|
||||
if (Gio.content_type_equals(contentType, "application/xml")) {
|
||||
const decoder = new TextDecoder("utf-8");
|
||||
const contents = decoder.decode(file.load_contents(null)[1]);
|
||||
try {
|
||||
path = contents.match(/<file>(.+)<\/file>/m)[1];
|
||||
if (!this.#isContentTypeSupported(Gio.content_type_guess(path, null)[0])) throw new Error();
|
||||
} catch (e) {
|
||||
console.error(`No suitable background file found in ${file.get_path()}.\n${e}`);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
path = file.get_path();
|
||||
}
|
||||
|
||||
vfunc_mnemonic_activate() {
|
||||
this.#setURIFromFileDialog();
|
||||
}
|
||||
const pixbuf = GdkPixbuf.Pixbuf.new_from_file(path);
|
||||
const scale =
|
||||
pixbuf.width / pixbuf.height > this.thumbWidth / this.thumbHeight
|
||||
? this.thumbHeight / pixbuf.height
|
||||
: this.thumbWidth / pixbuf.width;
|
||||
const thumbPixbuf = GdkPixbuf.Pixbuf.new(
|
||||
pixbuf.colorspace,
|
||||
pixbuf.has_alpha,
|
||||
pixbuf.bits_per_sample,
|
||||
this.thumbWidth,
|
||||
this.thumbHeight,
|
||||
);
|
||||
pixbuf.scale(
|
||||
thumbPixbuf,
|
||||
0,
|
||||
0,
|
||||
this.thumbWidth,
|
||||
this.thumbHeight,
|
||||
-(pixbuf.width * scale - this.thumbWidth) / 2,
|
||||
-(pixbuf.height * scale - this.thumbHeight) / 2,
|
||||
scale,
|
||||
scale,
|
||||
GdkPixbuf.InterpType.TILES,
|
||||
);
|
||||
|
||||
onClicked(_button) {
|
||||
this.#setURIFromFileDialog();
|
||||
}
|
||||
|
||||
async #setURIFromFileDialog() {
|
||||
try {
|
||||
const file = await this._file_dialog.open(this.get_root(), null);
|
||||
this.uri = file.get_uri();
|
||||
} catch {}
|
||||
}
|
||||
|
||||
#updateThumbnail() {
|
||||
this._thumbnail.paintable = null;
|
||||
|
||||
if (!this.uri)
|
||||
return;
|
||||
|
||||
const file = Gio.File.new_for_uri(this.uri);
|
||||
const contentType = Gio.content_type_guess(file.get_basename(), null)[0];
|
||||
|
||||
if (!this.#isContentTypeSupported(contentType))
|
||||
return;
|
||||
|
||||
let path;
|
||||
if (Gio.content_type_equals(contentType, 'application/xml')) {
|
||||
const decoder = new TextDecoder('utf-8');
|
||||
const contents = decoder.decode(file.load_contents(null)[1]);
|
||||
try {
|
||||
path = contents.match(/<file>(.+)<\/file>/m)[1];
|
||||
if (!this.#isContentTypeSupported(Gio.content_type_guess(path, null)[0]))
|
||||
throw new Error();
|
||||
} catch (e) {
|
||||
console.error(`No suitable background file found in ${file.get_path()}.\n${e}`);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
path = file.get_path();
|
||||
}
|
||||
|
||||
const pixbuf = GdkPixbuf.Pixbuf.new_from_file(path);
|
||||
const scale = pixbuf.width / pixbuf.height > this.thumbWidth / this.thumbHeight ? this.thumbHeight / pixbuf.height : this.thumbWidth / pixbuf.width;
|
||||
const thumbPixbuf = GdkPixbuf.Pixbuf.new(pixbuf.colorspace, pixbuf.has_alpha, pixbuf.bits_per_sample, this.thumbWidth, this.thumbHeight);
|
||||
pixbuf.scale(
|
||||
thumbPixbuf,
|
||||
0, 0,
|
||||
this.thumbWidth, this.thumbHeight,
|
||||
-(pixbuf.width * scale - this.thumbWidth) / 2, -(pixbuf.height * scale - this.thumbHeight) / 2,
|
||||
scale, scale,
|
||||
GdkPixbuf.InterpType.TILES
|
||||
);
|
||||
|
||||
this._thumbnail.paintable = Gdk.Texture.new_for_pixbuf(thumbPixbuf);
|
||||
}
|
||||
this._thumbnail.paintable = Gdk.Texture.new_for_pixbuf(thumbPixbuf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,27 @@
|
||||
// SPDX-FileCopyrightText: Night Theme Switcher Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import Adw from 'gi://Adw';
|
||||
import Gio from 'gi://Gio';
|
||||
import GObject from 'gi://GObject';
|
||||
|
||||
import Adw from "gi://Adw";
|
||||
import Gio from "gi://Gio";
|
||||
import GObject from "gi://GObject";
|
||||
|
||||
export class BackgroundsPage extends Adw.PreferencesPage {
|
||||
static {
|
||||
GObject.registerClass({
|
||||
GTypeName: 'BackgroundsPage',
|
||||
Template: 'resource:///org/gnome/Shell/Extensions/nightthemeswitcher/preferences/ui/BackgroundsPage.ui',
|
||||
InternalChildren: [
|
||||
'day_button',
|
||||
'night_button',
|
||||
],
|
||||
}, this);
|
||||
}
|
||||
static {
|
||||
GObject.registerClass(
|
||||
{
|
||||
GTypeName: "BackgroundsPage",
|
||||
Template: "resource:///org/gnome/Shell/Extensions/nightthemeswitcher/preferences/ui/BackgroundsPage.ui",
|
||||
InternalChildren: ["day_button", "night_button"],
|
||||
},
|
||||
this,
|
||||
);
|
||||
}
|
||||
|
||||
constructor({ ...params } = {}) {
|
||||
super(params);
|
||||
const settings = new Gio.Settings({ schema: 'org.gnome.desktop.background' });
|
||||
constructor({ ...params } = {}) {
|
||||
super(params);
|
||||
const settings = new Gio.Settings({ schema: "org.gnome.desktop.background" });
|
||||
|
||||
settings.bind('picture-uri', this._day_button, 'uri', Gio.SettingsBindFlags.DEFAULT);
|
||||
settings.bind('picture-uri-dark', this._night_button, 'uri', Gio.SettingsBindFlags.DEFAULT);
|
||||
}
|
||||
settings.bind("picture-uri", this._day_button, "uri", Gio.SettingsBindFlags.DEFAULT);
|
||||
settings.bind("picture-uri-dark", this._night_button, "uri", Gio.SettingsBindFlags.DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,27 @@
|
||||
// SPDX-FileCopyrightText: Night Theme Switcher Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import Adw from 'gi://Adw';
|
||||
import Gio from 'gi://Gio';
|
||||
import GObject from 'gi://GObject';
|
||||
|
||||
import Adw from "gi://Adw";
|
||||
import Gio from "gi://Gio";
|
||||
import GObject from "gi://GObject";
|
||||
|
||||
export class CommandsPage extends Adw.PreferencesPage {
|
||||
static {
|
||||
GObject.registerClass({
|
||||
GTypeName: 'CommandsPage',
|
||||
Template: 'resource:///org/gnome/Shell/Extensions/nightthemeswitcher/preferences/ui/CommandsPage.ui',
|
||||
InternalChildren: [
|
||||
'enabled_switch',
|
||||
'sunrise_entry',
|
||||
'sunset_entry',
|
||||
],
|
||||
}, this);
|
||||
}
|
||||
static {
|
||||
GObject.registerClass(
|
||||
{
|
||||
GTypeName: "CommandsPage",
|
||||
Template: "resource:///org/gnome/Shell/Extensions/nightthemeswitcher/preferences/ui/CommandsPage.ui",
|
||||
InternalChildren: ["enabled_switch", "sunrise_entry", "sunset_entry"],
|
||||
},
|
||||
this,
|
||||
);
|
||||
}
|
||||
|
||||
constructor({ settings, ...params } = {}) {
|
||||
super(params);
|
||||
constructor({ settings, ...params } = {}) {
|
||||
super(params);
|
||||
|
||||
settings.bind('enabled', this._enabled_switch, 'active', Gio.SettingsBindFlags.DEFAULT);
|
||||
settings.bind('sunrise', this._sunrise_entry, 'text', Gio.SettingsBindFlags.DEFAULT);
|
||||
settings.bind('sunset', this._sunset_entry, 'text', Gio.SettingsBindFlags.DEFAULT);
|
||||
}
|
||||
settings.bind("enabled", this._enabled_switch, "active", Gio.SettingsBindFlags.DEFAULT);
|
||||
settings.bind("sunrise", this._sunrise_entry, "text", Gio.SettingsBindFlags.DEFAULT);
|
||||
settings.bind("sunset", this._sunset_entry, "text", Gio.SettingsBindFlags.DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
// SPDX-FileCopyrightText: Night Theme Switcher Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import Adw from 'gi://Adw';
|
||||
import GObject from 'gi://GObject';
|
||||
|
||||
import Adw from "gi://Adw";
|
||||
import GObject from "gi://GObject";
|
||||
|
||||
export class ContributePage extends Adw.PreferencesPage {
|
||||
static {
|
||||
GObject.registerClass({
|
||||
GTypeName: 'ContributePage',
|
||||
Template: 'resource:///org/gnome/Shell/Extensions/nightthemeswitcher/preferences/ui/ContributePage.ui',
|
||||
}, this);
|
||||
}
|
||||
static {
|
||||
GObject.registerClass(
|
||||
{
|
||||
GTypeName: "ContributePage",
|
||||
Template: "resource:///org/gnome/Shell/Extensions/nightthemeswitcher/preferences/ui/ContributePage.ui",
|
||||
},
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +1,47 @@
|
||||
// SPDX-FileCopyrightText: Night Theme Switcher Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import Adw from 'gi://Adw';
|
||||
import Gio from 'gi://Gio';
|
||||
import GObject from 'gi://GObject';
|
||||
|
||||
import Adw from "gi://Adw";
|
||||
import Gio from "gi://Gio";
|
||||
import GObject from "gi://GObject";
|
||||
|
||||
export class SchedulePage extends Adw.PreferencesPage {
|
||||
static {
|
||||
GObject.registerClass({
|
||||
GTypeName: 'SchedulePage',
|
||||
Template: 'resource:///org/gnome/Shell/Extensions/nightthemeswitcher/preferences/ui/SchedulePage.ui',
|
||||
InternalChildren: [
|
||||
'manual_schedule_switch',
|
||||
'keyboard_shortcut_button',
|
||||
'schedule_sunrise_time_chooser',
|
||||
'schedule_sunset_time_chooser',
|
||||
'schedule_offset_spin_button',
|
||||
'fullscreen_transition_switch',
|
||||
],
|
||||
}, this);
|
||||
}
|
||||
static {
|
||||
GObject.registerClass(
|
||||
{
|
||||
GTypeName: "SchedulePage",
|
||||
Template: "resource:///org/gnome/Shell/Extensions/nightthemeswitcher/preferences/ui/SchedulePage.ui",
|
||||
InternalChildren: [
|
||||
"manual_schedule_switch",
|
||||
"keyboard_shortcut_button",
|
||||
"schedule_sunrise_time_chooser",
|
||||
"schedule_sunset_time_chooser",
|
||||
"schedule_offset_spin_button",
|
||||
"fullscreen_transition_switch",
|
||||
],
|
||||
},
|
||||
this,
|
||||
);
|
||||
}
|
||||
|
||||
constructor({ settings, ...params } = {}) {
|
||||
super(params);
|
||||
constructor({ settings, ...params } = {}) {
|
||||
super(params);
|
||||
|
||||
settings.bind('manual-schedule', this._manual_schedule_switch, 'active', Gio.SettingsBindFlags.DEFAULT);
|
||||
settings.bind("manual-schedule", this._manual_schedule_switch, "active", Gio.SettingsBindFlags.DEFAULT);
|
||||
|
||||
settings.bind('sunrise', this._schedule_sunrise_time_chooser, 'time', Gio.SettingsBindFlags.DEFAULT);
|
||||
settings.bind('sunset', this._schedule_sunset_time_chooser, 'time', Gio.SettingsBindFlags.DEFAULT);
|
||||
settings.bind("sunrise", this._schedule_sunrise_time_chooser, "time", Gio.SettingsBindFlags.DEFAULT);
|
||||
settings.bind("sunset", this._schedule_sunset_time_chooser, "time", Gio.SettingsBindFlags.DEFAULT);
|
||||
|
||||
settings.bind('offset', this._schedule_offset_spin_button, 'value', Gio.SettingsBindFlags.DEFAULT);
|
||||
settings.bind("offset", this._schedule_offset_spin_button, "value", Gio.SettingsBindFlags.DEFAULT);
|
||||
|
||||
settings.bind('fullscreen-transition', this._fullscreen_transition_switch, 'active', Gio.SettingsBindFlags.DEFAULT);
|
||||
settings.bind("fullscreen-transition", this._fullscreen_transition_switch, "active", Gio.SettingsBindFlags.DEFAULT);
|
||||
|
||||
settings.connect('changed::nightthemeswitcher-ondemand-keybinding', () => {
|
||||
this._keyboard_shortcut_button.keybinding = settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0];
|
||||
});
|
||||
this._keyboard_shortcut_button.connect('notify::keybinding', () => {
|
||||
settings.set_strv('nightthemeswitcher-ondemand-keybinding', [this._keyboard_shortcut_button.keybinding]);
|
||||
});
|
||||
this._keyboard_shortcut_button.keybinding = settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0];
|
||||
}
|
||||
settings.connect("changed::nightthemeswitcher-ondemand-keybinding", () => {
|
||||
this._keyboard_shortcut_button.keybinding = settings.get_strv("nightthemeswitcher-ondemand-keybinding")[0];
|
||||
});
|
||||
this._keyboard_shortcut_button.connect("notify::keybinding", () => {
|
||||
settings.set_strv("nightthemeswitcher-ondemand-keybinding", [this._keyboard_shortcut_button.keybinding]);
|
||||
});
|
||||
this._keyboard_shortcut_button.keybinding = settings.get_strv("nightthemeswitcher-ondemand-keybinding")[0];
|
||||
}
|
||||
}
|
||||
|
||||
+101
-114
@@ -1,147 +1,134 @@
|
||||
// SPDX-FileCopyrightText: Night Theme Switcher Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import Gdk from 'gi://Gdk';
|
||||
import GObject from 'gi://GObject';
|
||||
import Gtk from 'gi://Gtk';
|
||||
|
||||
import Gdk from "gi://Gdk";
|
||||
import GObject from "gi://GObject";
|
||||
import Gtk from "gi://Gtk";
|
||||
|
||||
export class ShortcutButton extends Gtk.Stack {
|
||||
static {
|
||||
GObject.registerClass({
|
||||
GTypeName: 'ShortcutButton',
|
||||
Template: 'resource:///org/gnome/Shell/Extensions/nightthemeswitcher/preferences/ui/ShortcutButton.ui',
|
||||
InternalChildren: ['choose_button', 'change_button', 'clear_button', 'dialog'],
|
||||
Properties: {
|
||||
keybinding: GObject.ParamSpec.string(
|
||||
'keybinding',
|
||||
'Keybinding',
|
||||
'Key sequence',
|
||||
GObject.ParamFlags.READWRITE,
|
||||
null
|
||||
),
|
||||
},
|
||||
}, this);
|
||||
}
|
||||
|
||||
vfunc_mnemonic_activate() {
|
||||
this.activate();
|
||||
}
|
||||
|
||||
activate() {
|
||||
if (this.keybinding)
|
||||
return this._change_button.activate();
|
||||
else
|
||||
return this._choose_button.activate();
|
||||
}
|
||||
|
||||
openDialog() {
|
||||
this._dialog.transient_for = this.get_root();
|
||||
this._dialog.present();
|
||||
}
|
||||
|
||||
onKeybindingChanged(button) {
|
||||
button.visible_child_name = button.keybinding ? 'edit' : 'choose';
|
||||
}
|
||||
|
||||
onChooseButtonClicked(_button) {
|
||||
this.openDialog();
|
||||
}
|
||||
|
||||
onChangeButtonClicked(_button) {
|
||||
this.openDialog();
|
||||
}
|
||||
|
||||
onClearButtonClicked(_button) {
|
||||
this.keybinding = '';
|
||||
}
|
||||
|
||||
onKeyPressed(_widget, keyval, keycode, state) {
|
||||
let mask = state & Gtk.accelerator_get_default_mod_mask();
|
||||
mask &= ~Gdk.ModifierType.LOCK_MASK;
|
||||
|
||||
if (mask === 0 && keyval === Gdk.KEY_Escape) {
|
||||
this._dialog.close();
|
||||
return Gdk.EVENT_STOP;
|
||||
}
|
||||
|
||||
if (
|
||||
!isBindingValid({ mask, keycode, keyval }) ||
|
||||
!isAccelValid({ mask, keyval })
|
||||
)
|
||||
return Gdk.EVENT_STOP;
|
||||
|
||||
this.keybinding = Gtk.accelerator_name_with_keycode(
|
||||
static {
|
||||
GObject.registerClass(
|
||||
{
|
||||
GTypeName: "ShortcutButton",
|
||||
Template: "resource:///org/gnome/Shell/Extensions/nightthemeswitcher/preferences/ui/ShortcutButton.ui",
|
||||
InternalChildren: ["choose_button", "change_button", "clear_button", "dialog"],
|
||||
Properties: {
|
||||
keybinding: GObject.ParamSpec.string(
|
||||
"keybinding",
|
||||
"Keybinding",
|
||||
"Key sequence",
|
||||
GObject.ParamFlags.READWRITE,
|
||||
null,
|
||||
keyval,
|
||||
keycode,
|
||||
mask
|
||||
);
|
||||
this._dialog.close();
|
||||
return Gdk.EVENT_STOP;
|
||||
}
|
||||
}
|
||||
),
|
||||
},
|
||||
},
|
||||
this,
|
||||
);
|
||||
}
|
||||
|
||||
vfunc_mnemonic_activate() {
|
||||
this.activate();
|
||||
}
|
||||
|
||||
activate() {
|
||||
if (this.keybinding) return this._change_button.activate();
|
||||
else return this._choose_button.activate();
|
||||
}
|
||||
|
||||
openDialog() {
|
||||
this._dialog.transient_for = this.get_root();
|
||||
this._dialog.present();
|
||||
}
|
||||
|
||||
onKeybindingChanged(button) {
|
||||
button.visible_child_name = button.keybinding ? "edit" : "choose";
|
||||
}
|
||||
|
||||
onChooseButtonClicked(_button) {
|
||||
this.openDialog();
|
||||
}
|
||||
|
||||
onChangeButtonClicked(_button) {
|
||||
this.openDialog();
|
||||
}
|
||||
|
||||
onClearButtonClicked(_button) {
|
||||
this.keybinding = "";
|
||||
}
|
||||
|
||||
onKeyPressed(_widget, keyval, keycode, state) {
|
||||
let mask = state & Gtk.accelerator_get_default_mod_mask();
|
||||
mask &= ~Gdk.ModifierType.LOCK_MASK;
|
||||
|
||||
if (mask === 0 && keyval === Gdk.KEY_Escape) {
|
||||
this._dialog.close();
|
||||
return Gdk.EVENT_STOP;
|
||||
}
|
||||
|
||||
if (!isBindingValid({ mask, keycode, keyval }) || !isAccelValid({ mask, keyval })) return Gdk.EVENT_STOP;
|
||||
|
||||
this.keybinding = Gtk.accelerator_name_with_keycode(null, keyval, keycode, mask);
|
||||
this._dialog.close();
|
||||
return Gdk.EVENT_STOP;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given keyval is forbidden.
|
||||
*
|
||||
* @param {number} keyval The keyval number.
|
||||
* @returns {boolean} `true` if the keyval is forbidden.
|
||||
*/
|
||||
function isKeyvalForbidden(keyval) {
|
||||
const forbiddenKeyvals = [
|
||||
Gdk.KEY_Home,
|
||||
Gdk.KEY_Left,
|
||||
Gdk.KEY_Up,
|
||||
Gdk.KEY_Right,
|
||||
Gdk.KEY_Down,
|
||||
Gdk.KEY_Page_Up,
|
||||
Gdk.KEY_Page_Down,
|
||||
Gdk.KEY_End,
|
||||
Gdk.KEY_Tab,
|
||||
Gdk.KEY_KP_Enter,
|
||||
Gdk.KEY_Return,
|
||||
Gdk.KEY_Mode_switch,
|
||||
];
|
||||
return forbiddenKeyvals.includes(keyval);
|
||||
const forbiddenKeyvals = [
|
||||
Gdk.KEY_Home,
|
||||
Gdk.KEY_Left,
|
||||
Gdk.KEY_Up,
|
||||
Gdk.KEY_Right,
|
||||
Gdk.KEY_Down,
|
||||
Gdk.KEY_Page_Up,
|
||||
Gdk.KEY_Page_Down,
|
||||
Gdk.KEY_End,
|
||||
Gdk.KEY_Tab,
|
||||
Gdk.KEY_KP_Enter,
|
||||
Gdk.KEY_Return,
|
||||
Gdk.KEY_Mode_switch,
|
||||
];
|
||||
return forbiddenKeyvals.includes(keyval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given key combo is a valid binding
|
||||
*
|
||||
* @param {{mask: number, keycode: number, keyval:number}} combo An object
|
||||
* representing the key combo.
|
||||
* @returns {boolean} `true` if the key combo is a valid binding.
|
||||
*/
|
||||
function isBindingValid({ mask, keycode, keyval }) {
|
||||
if ((mask === 0 || mask === Gdk.ModifierType.SHIFT_MASK) && keycode !== 0) {
|
||||
if (
|
||||
(keyval >= Gdk.KEY_a && keyval <= Gdk.KEY_z) ||
|
||||
(keyval >= Gdk.KEY_A && keyval <= Gdk.KEY_Z) ||
|
||||
(keyval >= Gdk.KEY_0 && keyval <= Gdk.KEY_9) ||
|
||||
(keyval >= Gdk.KEY_kana_fullstop && keyval <= Gdk.KEY_semivoicedsound) ||
|
||||
(keyval >= Gdk.KEY_Arabic_comma && keyval <= Gdk.KEY_Arabic_sukun) ||
|
||||
(keyval >= Gdk.KEY_Serbian_dje && keyval <= Gdk.KEY_Cyrillic_HARDSIGN) ||
|
||||
(keyval >= Gdk.KEY_Greek_ALPHAaccent && keyval <= Gdk.KEY_Greek_omega) ||
|
||||
(keyval >= Gdk.KEY_hebrew_doublelowline && keyval <= Gdk.KEY_hebrew_taf) ||
|
||||
(keyval >= Gdk.KEY_Thai_kokai && keyval <= Gdk.KEY_Thai_lekkao) ||
|
||||
(keyval >= Gdk.KEY_Hangul_Kiyeog && keyval <= Gdk.KEY_Hangul_J_YeorinHieuh) ||
|
||||
(keyval === Gdk.KEY_space && mask === 0) ||
|
||||
isKeyvalForbidden(keyval)
|
||||
)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
if ((mask === 0 || mask === Gdk.ModifierType.SHIFT_MASK) && keycode !== 0) {
|
||||
if (
|
||||
(keyval >= Gdk.KEY_a && keyval <= Gdk.KEY_z) ||
|
||||
(keyval >= Gdk.KEY_A && keyval <= Gdk.KEY_Z) ||
|
||||
(keyval >= Gdk.KEY_0 && keyval <= Gdk.KEY_9) ||
|
||||
(keyval >= Gdk.KEY_kana_fullstop && keyval <= Gdk.KEY_semivoicedsound) ||
|
||||
(keyval >= Gdk.KEY_Arabic_comma && keyval <= Gdk.KEY_Arabic_sukun) ||
|
||||
(keyval >= Gdk.KEY_Serbian_dje && keyval <= Gdk.KEY_Cyrillic_HARDSIGN) ||
|
||||
(keyval >= Gdk.KEY_Greek_ALPHAaccent && keyval <= Gdk.KEY_Greek_omega) ||
|
||||
(keyval >= Gdk.KEY_hebrew_doublelowline && keyval <= Gdk.KEY_hebrew_taf) ||
|
||||
(keyval >= Gdk.KEY_Thai_kokai && keyval <= Gdk.KEY_Thai_lekkao) ||
|
||||
(keyval >= Gdk.KEY_Hangul_Kiyeog && keyval <= Gdk.KEY_Hangul_J_YeorinHieuh) ||
|
||||
(keyval === Gdk.KEY_space && mask === 0) ||
|
||||
isKeyvalForbidden(keyval)
|
||||
)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given key combo is a valid accelerator.
|
||||
*
|
||||
* @param {{mask: number, keyval:number}} combo An object representing the key
|
||||
* combo.
|
||||
* @returns {boolean} `true` if the key combo is a valid accelerator.
|
||||
*/
|
||||
function isAccelValid({ mask, keyval }) {
|
||||
return Gtk.accelerator_valid(keyval, mask) || (keyval === Gdk.KEY_Tab && mask !== 0);
|
||||
return Gtk.accelerator_valid(keyval, mask) || (keyval === Gdk.KEY_Tab && mask !== 0);
|
||||
}
|
||||
|
||||
@@ -1,97 +1,113 @@
|
||||
// SPDX-FileCopyrightText: Night Theme Switcher Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import GDesktopEnums from 'gi://GDesktopEnums';
|
||||
import Gio from 'gi://Gio';
|
||||
import GObject from 'gi://GObject';
|
||||
import Gtk from 'gi://Gtk';
|
||||
|
||||
import GDesktopEnums from "gi://GDesktopEnums";
|
||||
import Gio from "gi://Gio";
|
||||
import GObject from "gi://GObject";
|
||||
import Gtk from "gi://Gtk";
|
||||
|
||||
export class TimeChooser extends Gtk.Widget {
|
||||
#clockFormat;
|
||||
#interfaceSettings;
|
||||
#clockFormat;
|
||||
#interfaceSettings;
|
||||
|
||||
static {
|
||||
GObject.registerClass({
|
||||
GTypeName: 'TimeChooser',
|
||||
Template: 'resource:///org/gnome/Shell/Extensions/nightthemeswitcher/preferences/ui/TimeChooser.ui',
|
||||
InternalChildren: ['clock_format_stack', 'hours_12', 'minutes_12', 'hours_24', 'minutes_24', 'am_toggle_button', 'pm_toggle_button'],
|
||||
Properties: {
|
||||
time: GObject.ParamSpec.double(
|
||||
'time',
|
||||
'Time',
|
||||
'The time of the chooser',
|
||||
GObject.ParamFlags.READWRITE,
|
||||
0,
|
||||
24,
|
||||
0
|
||||
),
|
||||
},
|
||||
}, this);
|
||||
}
|
||||
static {
|
||||
GObject.registerClass(
|
||||
{
|
||||
GTypeName: "TimeChooser",
|
||||
Template: "resource:///org/gnome/Shell/Extensions/nightthemeswitcher/preferences/ui/TimeChooser.ui",
|
||||
InternalChildren: [
|
||||
"clock_format_stack",
|
||||
"hours_12",
|
||||
"minutes_12",
|
||||
"hours_24",
|
||||
"minutes_24",
|
||||
"am_toggle_button",
|
||||
"pm_toggle_button",
|
||||
],
|
||||
Properties: {
|
||||
time: GObject.ParamSpec.double(
|
||||
"time",
|
||||
"Time",
|
||||
"The time of the chooser",
|
||||
GObject.ParamFlags.READWRITE,
|
||||
0,
|
||||
24,
|
||||
0,
|
||||
),
|
||||
},
|
||||
},
|
||||
this,
|
||||
);
|
||||
}
|
||||
|
||||
constructor({ ...params } = {}) {
|
||||
super(params);
|
||||
this.#interfaceSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' });
|
||||
this.#interfaceSettings.connect('changed::clock-format', this.#onClockFormatChanged.bind(this));
|
||||
this.#onClockFormatChanged();
|
||||
}
|
||||
constructor({ ...params } = {}) {
|
||||
super(params);
|
||||
this.#interfaceSettings = new Gio.Settings({ schema: "org.gnome.desktop.interface" });
|
||||
this.#interfaceSettings.connect("changed::clock-format", this.#onClockFormatChanged.bind(this));
|
||||
this.#onClockFormatChanged();
|
||||
}
|
||||
|
||||
#onClockFormatChanged(_settings) {
|
||||
this.#clockFormat = this.#interfaceSettings.get_enum('clock-format');
|
||||
this.#syncClockFormatStack();
|
||||
}
|
||||
#onClockFormatChanged(_settings) {
|
||||
this.#clockFormat = this.#interfaceSettings.get_enum("clock-format");
|
||||
this.#syncClockFormatStack();
|
||||
}
|
||||
|
||||
#syncClockFormatStack() {
|
||||
this._clock_format_stack.set_visible_child_name(this.#clockFormat === GDesktopEnums.ClockFormat['12H'] ? '12h' : '24h');
|
||||
}
|
||||
#syncClockFormatStack() {
|
||||
this._clock_format_stack.set_visible_child_name(
|
||||
this.#clockFormat === GDesktopEnums.ClockFormat["12H"] ? "12h" : "24h",
|
||||
);
|
||||
}
|
||||
|
||||
#convertTimeTo24hFormat(time) {
|
||||
const hours = Math.trunc(time);
|
||||
const minutes = Math.round((time - hours) * 60);
|
||||
return { hours, minutes };
|
||||
}
|
||||
#convertTimeTo24hFormat(time) {
|
||||
const hours = Math.trunc(time);
|
||||
const minutes = Math.round((time - hours) * 60);
|
||||
return { hours, minutes };
|
||||
}
|
||||
|
||||
#convertTimeTo12hFormat(time) {
|
||||
const { hours: hours24, minutes } = this.#convertTimeTo24hFormat(time);
|
||||
const hours = hours24 === 0 ? 12 : hours24 % 12;
|
||||
const isPm = hours24 >= 12;
|
||||
return { hours, minutes, isPm };
|
||||
}
|
||||
#convertTimeTo12hFormat(time) {
|
||||
const { hours: hours24, minutes } = this.#convertTimeTo24hFormat(time);
|
||||
const hours = hours24 === 0 ? 12 : hours24 % 12;
|
||||
const isPm = hours24 >= 12;
|
||||
return { hours, minutes, isPm };
|
||||
}
|
||||
|
||||
#convert24hFormatToTime({ hours, minutes }) {
|
||||
return hours + minutes / 60;
|
||||
}
|
||||
#convert24hFormatToTime({ hours, minutes }) {
|
||||
return hours + minutes / 60;
|
||||
}
|
||||
|
||||
#convert12hFormatToTime({ hours, minutes, isPm }) {
|
||||
let hours24 = hours + Number(isPm) * 12;
|
||||
if (hours === 12)
|
||||
hours24 = isPm ? 12 : 0;
|
||||
return this.#convert24hFormatToTime({ hours: hours24, minutes });
|
||||
}
|
||||
#convert12hFormatToTime({ hours, minutes, isPm }) {
|
||||
let hours24 = hours + Number(isPm) * 12;
|
||||
if (hours === 12) hours24 = isPm ? 12 : 0;
|
||||
return this.#convert24hFormatToTime({ hours: hours24, minutes });
|
||||
}
|
||||
|
||||
onTimeChanged(_chooser) {
|
||||
const time = this.time;
|
||||
onTimeChanged(_chooser) {
|
||||
const time = this.time;
|
||||
|
||||
const clock12 = this.#convertTimeTo12hFormat(time);
|
||||
this._hours_12.value = clock12.hours;
|
||||
this._minutes_12.value = clock12.minutes;
|
||||
this._am_toggle_button.active = !clock12.isPm;
|
||||
this._pm_toggle_button.active = clock12.isPm;
|
||||
const clock12 = this.#convertTimeTo12hFormat(time);
|
||||
this._hours_12.value = clock12.hours;
|
||||
this._minutes_12.value = clock12.minutes;
|
||||
this._am_toggle_button.active = !clock12.isPm;
|
||||
this._pm_toggle_button.active = clock12.isPm;
|
||||
|
||||
const clock24 = this.#convertTimeTo24hFormat(time);
|
||||
this._hours_24.value = clock24.hours;
|
||||
this._minutes_24.value = clock24.minutes;
|
||||
}
|
||||
const clock24 = this.#convertTimeTo24hFormat(time);
|
||||
this._hours_24.value = clock24.hours;
|
||||
this._minutes_24.value = clock24.minutes;
|
||||
}
|
||||
|
||||
onValueChanged(_widget) {
|
||||
this.time = this.#clockFormat === GDesktopEnums.ClockFormat['12H']
|
||||
? this.#convert12hFormatToTime({ hours: this._hours_12.value, minutes: this._minutes_12.value, isPm: this._pm_toggle_button.active })
|
||||
: this.#convert24hFormatToTime({ hours: this._hours_24.value, minutes: this._minutes_24.value });
|
||||
}
|
||||
onValueChanged(_widget) {
|
||||
this.time =
|
||||
this.#clockFormat === GDesktopEnums.ClockFormat["12H"]
|
||||
? this.#convert12hFormatToTime({
|
||||
hours: this._hours_12.value,
|
||||
minutes: this._minutes_12.value,
|
||||
isPm: this._pm_toggle_button.active,
|
||||
})
|
||||
: this.#convert24hFormatToTime({ hours: this._hours_24.value, minutes: this._minutes_24.value });
|
||||
}
|
||||
|
||||
onOutputChanged(spin) {
|
||||
spin.text = spin.value.toString().padStart(2, '0');
|
||||
return true;
|
||||
}
|
||||
onOutputChanged(spin) {
|
||||
spin.text = spin.value.toString().padStart(2, "0");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+45
-47
@@ -1,60 +1,58 @@
|
||||
// SPDX-FileCopyrightText: Night Theme Switcher Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
import Gdk from 'gi://Gdk';
|
||||
import Gio from 'gi://Gio';
|
||||
import GLib from 'gi://GLib';
|
||||
import GObject from 'gi://GObject';
|
||||
import Gtk from 'gi://Gtk';
|
||||
|
||||
import { ExtensionPreferences } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
|
||||
import Gdk from "gi://Gdk";
|
||||
import Gio from "gi://Gio";
|
||||
import GLib from "gi://GLib";
|
||||
import GObject from "gi://GObject";
|
||||
import Gtk from "gi://Gtk";
|
||||
|
||||
import { ExtensionPreferences } from "resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js";
|
||||
|
||||
export default class NightThemeSwitcherPreferences extends ExtensionPreferences {
|
||||
/**
|
||||
* Fill the PreferencesWindow.
|
||||
*
|
||||
* @param {Adw.PreferencesWindow} window The PreferencesWindow to fill.
|
||||
*/
|
||||
async fillPreferencesWindow(window) {
|
||||
// Load resources
|
||||
const resource = Gio.Resource.load(GLib.build_filenamev([this.path, 'resources', 'preferences.gresource']));
|
||||
Gio.resources_register(resource);
|
||||
/**
|
||||
* Fill the PreferencesWindow.
|
||||
* @param {import("gi://Adw").default.PreferencesWindow} window The PreferencesWindow to fill.
|
||||
*/
|
||||
async fillPreferencesWindow(window) {
|
||||
// Load resources
|
||||
const resource = Gio.Resource.load(GLib.build_filenamev([this.path, "resources", "preferences.gresource"]));
|
||||
Gio.resources_register(resource);
|
||||
|
||||
// Load icons
|
||||
const iconTheme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default());
|
||||
iconTheme.add_resource_path('/org/gnome/Shell/Extensions/nightthemeswitcher/preferences/icons');
|
||||
// Load icons
|
||||
const iconTheme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default());
|
||||
iconTheme.add_resource_path("/org/gnome/Shell/Extensions/nightthemeswitcher/preferences/icons");
|
||||
|
||||
// Set window properties
|
||||
window.search_enabled = true;
|
||||
window.set_default_size(500, 630);
|
||||
// Set window properties
|
||||
window.search_enabled = true;
|
||||
window.set_default_size(500, 630);
|
||||
|
||||
// Dynamically import all classes
|
||||
const { BackgroundButton } = await import('./preferences/BackgroundButton.js');
|
||||
const { BackgroundsPage } = await import('./preferences/BackgroundsPage.js');
|
||||
const { CommandsPage } = await import('./preferences/CommandsPage.js');
|
||||
const { ContributePage } = await import('./preferences/ContributePage.js');
|
||||
const { SchedulePage } = await import('./preferences/SchedulePage.js');
|
||||
const { ShortcutButton } = await import('./preferences/ShortcutButton.js');
|
||||
const { TimeChooser } = await import('./preferences/TimeChooser.js');
|
||||
// Dynamically import all classes
|
||||
const { BackgroundButton } = await import("./preferences/BackgroundButton.js");
|
||||
const { BackgroundsPage } = await import("./preferences/BackgroundsPage.js");
|
||||
const { CommandsPage } = await import("./preferences/CommandsPage.js");
|
||||
const { ContributePage } = await import("./preferences/ContributePage.js");
|
||||
const { SchedulePage } = await import("./preferences/SchedulePage.js");
|
||||
const { ShortcutButton } = await import("./preferences/ShortcutButton.js");
|
||||
const { TimeChooser } = await import("./preferences/TimeChooser.js");
|
||||
|
||||
// Make sure all GObjects are registered
|
||||
GObject.type_ensure(BackgroundButton);
|
||||
GObject.type_ensure(BackgroundsPage);
|
||||
GObject.type_ensure(CommandsPage);
|
||||
GObject.type_ensure(ContributePage);
|
||||
GObject.type_ensure(SchedulePage);
|
||||
GObject.type_ensure(ShortcutButton);
|
||||
GObject.type_ensure(TimeChooser);
|
||||
// Make sure all GObjects are registered
|
||||
GObject.type_ensure(BackgroundButton);
|
||||
GObject.type_ensure(BackgroundsPage);
|
||||
GObject.type_ensure(CommandsPage);
|
||||
GObject.type_ensure(ContributePage);
|
||||
GObject.type_ensure(SchedulePage);
|
||||
GObject.type_ensure(ShortcutButton);
|
||||
GObject.type_ensure(TimeChooser);
|
||||
|
||||
// Add all pages
|
||||
[
|
||||
new SchedulePage({ settings: this.getSettings(`${this.metadata['settings-schema']}.time`) }),
|
||||
new BackgroundsPage(),
|
||||
new CommandsPage({ settings: this.getSettings(`${this.metadata['settings-schema']}.commands`) }),
|
||||
new ContributePage(),
|
||||
].forEach(page => window.add(page));
|
||||
}
|
||||
// Add all pages
|
||||
[
|
||||
new SchedulePage({ settings: this.getSettings(`${this.metadata["settings-schema"]}.time`) }),
|
||||
new BackgroundsPage(),
|
||||
new CommandsPage({ settings: this.getSettings(`${this.metadata["settings-schema"]}.commands`) }),
|
||||
new ContributePage(),
|
||||
].forEach((page) => window.add(page));
|
||||
}
|
||||
}
|
||||
|
||||
+20
-8
@@ -6,25 +6,37 @@ if reuse_exe.found()
|
||||
test(
|
||||
'reuse',
|
||||
reuse_exe,
|
||||
args: [
|
||||
'--root',
|
||||
meson.project_source_root(),
|
||||
'lint'
|
||||
],
|
||||
args: ['--root', meson.project_source_root(), 'lint'],
|
||||
suite: 'licensing',
|
||||
)
|
||||
endif
|
||||
|
||||
eslint_exe = find_program(
|
||||
'eslint', 'eslint.js',
|
||||
'eslint',
|
||||
'eslint.js',
|
||||
required: false,
|
||||
dirs: [ meson.project_source_root() / 'node_modules' / 'eslint' / 'bin' ]
|
||||
dirs: [meson.project_source_root() / 'node_modules' / 'eslint' / 'bin'],
|
||||
)
|
||||
if eslint_exe.found()
|
||||
test(
|
||||
'eslint',
|
||||
eslint_exe,
|
||||
args: [ meson.project_source_root() / 'src' ],
|
||||
args: [meson.project_source_root()],
|
||||
suite: 'code',
|
||||
)
|
||||
endif
|
||||
|
||||
prettier_exe = find_program(
|
||||
'prettier',
|
||||
'prettier.cjs',
|
||||
required: false,
|
||||
dirs: [meson.project_source_root() / 'node_modules' / 'prettier' / 'bin'],
|
||||
)
|
||||
if prettier_exe.found()
|
||||
test(
|
||||
'prettier',
|
||||
prettier_exe,
|
||||
args: ['--check', meson.project_source_root()],
|
||||
suite: 'code',
|
||||
)
|
||||
endif
|
||||
|
||||
+24
-22
@@ -1,28 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<!--
|
||||
SPDX-FileCopyrightText: Night Theme Switcher Contributors
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
-->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Night Theme Switcher</title>
|
||||
<meta name="description" content="A GNOME Shell extension to make your desktop easy on the eye, day and night.">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
|
||||
</head>
|
||||
<body>
|
||||
<main class="content">
|
||||
<h1 class="title">Night Theme Switcher</h1>
|
||||
<p class="description">A GNOME Shell extension to make your desktop easy on the eye, day and night.</p>
|
||||
<a href="https://extensions.gnome.org/extension/2236/night-theme-switcher/" class="button">Download</a>
|
||||
<ul class="links">
|
||||
<li><a href="https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension" class="link">Code & issues</a></li>
|
||||
<li><a href="https://hosted.weblate.org/engage/night-theme-switcher/" class="link">Translate</a></li>
|
||||
<li><a href="https://liberapay.com/rmnvgr/donate" class="link">Donate</a></li>
|
||||
</ul>
|
||||
</main>
|
||||
</body>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Night Theme Switcher</title>
|
||||
<meta name="description" content="A GNOME Shell extension to make your desktop easy on the eye, day and night." />
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<main class="content">
|
||||
<h1 class="title">Night Theme Switcher</h1>
|
||||
<p class="description">A GNOME Shell extension to make your desktop easy on the eye, day and night.</p>
|
||||
<a href="https://extensions.gnome.org/extension/2236/night-theme-switcher/" class="button">Download</a>
|
||||
<ul class="links">
|
||||
<li>
|
||||
<a href="https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension" class="link">Code & issues</a>
|
||||
</li>
|
||||
<li><a href="https://hosted.weblate.org/engage/night-theme-switcher/" class="link">Translate</a></li>
|
||||
<li><a href="https://liberapay.com/rmnvgr/donate" class="link">Donate</a></li>
|
||||
</ul>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+171
-190
@@ -3,256 +3,237 @@ SPDX-FileCopyrightText: Night Theme Switcher Contributors
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
@font-face
|
||||
{
|
||||
font-family: 'Cantarell';
|
||||
src: url('fonts/Cantarell-Regular.woff2') format('woff2'),
|
||||
url('fonts/Cantarell-Regular.woff') format('woff');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
@font-face {
|
||||
font-family: "Cantarell";
|
||||
src:
|
||||
url("fonts/Cantarell-Regular.woff2") format("woff2"),
|
||||
url("fonts/Cantarell-Regular.woff") format("woff");
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face
|
||||
{
|
||||
font-family: 'Cantarell';
|
||||
src: url('fonts/Cantarell-Bold.woff2') format('woff2'),
|
||||
url('fonts/Cantarell-Bold.woff') format('woff');
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
@font-face {
|
||||
font-family: "Cantarell";
|
||||
src:
|
||||
url("fonts/Cantarell-Bold.woff2") format("woff2"),
|
||||
url("fonts/Cantarell-Bold.woff") format("woff");
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
|
||||
html,
|
||||
body,
|
||||
h1,
|
||||
p,
|
||||
ul,
|
||||
li
|
||||
{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
li {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
a
|
||||
{
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
|
||||
@keyframes background {
|
||||
from, 20% {
|
||||
background: #020417;
|
||||
}
|
||||
80%, to {
|
||||
background: #4995eb;
|
||||
}
|
||||
from,
|
||||
20% {
|
||||
background: #020417;
|
||||
}
|
||||
80%,
|
||||
to {
|
||||
background: #4995eb;
|
||||
}
|
||||
}
|
||||
|
||||
html
|
||||
{
|
||||
height: 100%;
|
||||
background: #020417;
|
||||
font: 1em/1em sans-serif;
|
||||
animation: background 20s linear infinite alternate -2s;
|
||||
html {
|
||||
height: 100%;
|
||||
background: #020417;
|
||||
font: 1em/1em sans-serif;
|
||||
animation: background 20s linear infinite alternate -2s;
|
||||
}
|
||||
|
||||
html::before,
|
||||
html::after
|
||||
{
|
||||
content: '';
|
||||
display: block;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
html::after {
|
||||
content: "";
|
||||
display: block;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
@keyframes background-night
|
||||
{
|
||||
from, 10%
|
||||
{
|
||||
background-position-y: bottom;
|
||||
opacity: 0;
|
||||
}
|
||||
@keyframes background-night {
|
||||
from,
|
||||
10% {
|
||||
background-position-y: bottom;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
30%
|
||||
{
|
||||
opacity: 1;
|
||||
}
|
||||
30% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
60%, to
|
||||
{
|
||||
background-position-y: top;
|
||||
}
|
||||
60%,
|
||||
to {
|
||||
background-position-y: top;
|
||||
}
|
||||
}
|
||||
|
||||
html::before
|
||||
{
|
||||
z-index: -2;
|
||||
background: radial-gradient(ellipse 200% 100% at 50% 100%, #8d092c, #221a52 50%, #162171) center;
|
||||
background-size: 100% 200%;
|
||||
animation: background-night 20s linear infinite alternate -2s;
|
||||
html::before {
|
||||
z-index: -2;
|
||||
background: radial-gradient(ellipse 200% 100% at 50% 100%, #8d092c, #221a52 50%, #162171) center;
|
||||
background-size: 100% 200%;
|
||||
animation: background-night 20s linear infinite alternate -2s;
|
||||
}
|
||||
|
||||
@keyframes background-day
|
||||
{
|
||||
from, 35%
|
||||
{
|
||||
background-position-y: bottom;
|
||||
opacity: 0;
|
||||
}
|
||||
@keyframes background-day {
|
||||
from,
|
||||
35% {
|
||||
background-position-y: bottom;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
65%
|
||||
{
|
||||
opacity: 1;
|
||||
}
|
||||
65% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
to
|
||||
{
|
||||
background-position-y: top;
|
||||
}
|
||||
to {
|
||||
background-position-y: top;
|
||||
}
|
||||
}
|
||||
|
||||
html::after
|
||||
{
|
||||
z-index: -1;
|
||||
background: radial-gradient(ellipse 200% 100% at 50% 100%, #c79edd, #5a8ae4 50%, #4995eb) center;
|
||||
background-size: 100% 200%;
|
||||
animation: background-day 20s linear infinite alternate -2s;
|
||||
html::after {
|
||||
z-index: -1;
|
||||
background: radial-gradient(ellipse 200% 100% at 50% 100%, #c79edd, #5a8ae4 50%, #4995eb) center;
|
||||
background-size: 100% 200%;
|
||||
animation: background-day 20s linear infinite alternate -2s;
|
||||
}
|
||||
|
||||
body
|
||||
{
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100%;
|
||||
body {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
@keyframes content {
|
||||
from, 50% {
|
||||
border-color: rgba(255, 255, 255, 0.1);
|
||||
background: #000;
|
||||
color: #fcfcfc;
|
||||
--test: #fcfcfc;
|
||||
}
|
||||
51%, to {
|
||||
border-color: rgba(0, 0, 0, 0.2);
|
||||
background: #fefefe;
|
||||
color: #000;
|
||||
}
|
||||
from,
|
||||
50% {
|
||||
border-color: rgba(255, 255, 255, 0.1);
|
||||
background: #000;
|
||||
color: #fcfcfc;
|
||||
--test: #fcfcfc;
|
||||
}
|
||||
51%,
|
||||
to {
|
||||
border-color: rgba(0, 0, 0, 0.2);
|
||||
background: #fefefe;
|
||||
color: #000;
|
||||
}
|
||||
}
|
||||
|
||||
.content
|
||||
{
|
||||
max-width: 20em;
|
||||
padding: 4em 2em 2em;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
border-radius: 0.5em;
|
||||
background: #000;
|
||||
color: #fcfcfc;
|
||||
font: 1rem/1.2em Cantarell, sans-serif;
|
||||
text-align: center;
|
||||
box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);
|
||||
animation: content 20s linear infinite alternate -2s;
|
||||
.content {
|
||||
max-width: 20em;
|
||||
padding: 4em 2em 2em;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
border-radius: 0.5em;
|
||||
background: #000;
|
||||
color: #fcfcfc;
|
||||
font:
|
||||
1rem/1.2em Cantarell,
|
||||
sans-serif;
|
||||
text-align: center;
|
||||
box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);
|
||||
animation: content 20s linear infinite alternate -2s;
|
||||
}
|
||||
|
||||
.title
|
||||
{
|
||||
margin: 0 0 2.5rem;
|
||||
font-weight: bold;
|
||||
font-size: 1.4em;
|
||||
line-height: 1.2em;
|
||||
.title {
|
||||
margin: 0 0 2.5rem;
|
||||
font-weight: bold;
|
||||
font-size: 1.4em;
|
||||
line-height: 1.2em;
|
||||
}
|
||||
|
||||
@keyframes icon {
|
||||
from, 50% {
|
||||
background: #fcfcfc;
|
||||
}
|
||||
51%, to {
|
||||
background: #000;
|
||||
}
|
||||
from,
|
||||
50% {
|
||||
background: #fcfcfc;
|
||||
}
|
||||
51%,
|
||||
to {
|
||||
background: #000;
|
||||
}
|
||||
}
|
||||
|
||||
.title::before
|
||||
{
|
||||
content: '';
|
||||
display: block;
|
||||
width: 4em;
|
||||
height: 4em;
|
||||
margin: 0 auto 2em;
|
||||
background: #fcfcfc;
|
||||
font-size: 1rem;
|
||||
-webkit-mask: url(icon.svg) no-repeat center;
|
||||
-webkit-mask-size: 100%;
|
||||
mask: url(icon.svg) no-repeat center;
|
||||
mask-size: 100%;
|
||||
animation: icon 20s linear infinite alternate -2s;
|
||||
.title::before {
|
||||
content: "";
|
||||
display: block;
|
||||
width: 4em;
|
||||
height: 4em;
|
||||
margin: 0 auto 2em;
|
||||
background: #fcfcfc;
|
||||
font-size: 1rem;
|
||||
-webkit-mask: url(icon.svg) no-repeat center;
|
||||
-webkit-mask-size: 100%;
|
||||
mask: url(icon.svg) no-repeat center;
|
||||
mask-size: 100%;
|
||||
animation: icon 20s linear infinite alternate -2s;
|
||||
}
|
||||
|
||||
.description
|
||||
{
|
||||
margin-bottom: 2.5rem;
|
||||
font-size: 0.9em;
|
||||
line-height: inherit;
|
||||
.description {
|
||||
margin-bottom: 2.5rem;
|
||||
font-size: 0.9em;
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
.button
|
||||
{
|
||||
display: inline-block;
|
||||
padding: 0.5em 1em;
|
||||
border: 0.15em solid;
|
||||
border-radius: 0.4em;
|
||||
font-size: 1.2em;
|
||||
font-weight: bold;
|
||||
.button {
|
||||
display: inline-block;
|
||||
padding: 0.5em 1em;
|
||||
border: 0.15em solid;
|
||||
border-radius: 0.4em;
|
||||
font-size: 1.2em;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.button:hover,
|
||||
.button:focus
|
||||
{
|
||||
text-decoration: underline;
|
||||
.button:focus {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.links
|
||||
{
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
gap: 1em 2em;
|
||||
margin-top: 4rem;
|
||||
font-size: 0.8em;
|
||||
text-align: center;
|
||||
list-style: none;
|
||||
.links {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
gap: 1em 2em;
|
||||
margin-top: 4rem;
|
||||
font-size: 0.8em;
|
||||
text-align: center;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.link
|
||||
{
|
||||
opacity: 0.5;
|
||||
.link {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.link:hover,
|
||||
.link:focus
|
||||
{
|
||||
text-decoration: underline;
|
||||
opacity: 1;
|
||||
.link:focus {
|
||||
text-decoration: underline;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
@media (max-width: 26em) {
|
||||
body {
|
||||
display: block;
|
||||
padding: 2em 2em;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 26em)
|
||||
{
|
||||
body
|
||||
{
|
||||
display: block;
|
||||
padding: 2em 2em;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.links
|
||||
{
|
||||
display: block;
|
||||
}
|
||||
.links {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user