-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 42649cc
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import Gio from 'gi://Gio'; | ||
import GLib from 'gi://GLib'; | ||
import GObject from 'gi://GObject'; | ||
import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js'; | ||
|
||
import * as Main from 'resource:///org/gnome/shell/ui/main.js'; | ||
import * as QuickSettings from 'resource:///org/gnome/shell/ui/quickSettings.js'; | ||
|
||
|
||
const TemperatureItem = GObject.registerClass( | ||
class TemperatureItem extends QuickSettings.QuickSlider { | ||
_init() { | ||
super._init({ | ||
iconName: 'weather-clear-night', | ||
}); | ||
|
||
this.minimum = 1500; | ||
this.maximum = 6500; | ||
|
||
this._settings = new Gio.Settings({schema_id: "org.gnome.settings-daemon.plugins.color"}); | ||
|
||
this.slider.accessible_name = _('NightLightTemperature'); | ||
|
||
this.slider.value = (this._settings.get_uint('night-light-temperature') - this.minimum) / (this.maximum - this.minimum); | ||
|
||
this._sliderChangedId = this.slider.connect('notify::value', | ||
this._sliderChanged.bind(this)); | ||
|
||
} | ||
|
||
_changeSlider(value) { | ||
this.slider.block_signal_handler(this._sliderChangedId); | ||
this.slider.value = value; | ||
this.slider.unblock_signal_handler(this._sliderChangedId); | ||
} | ||
|
||
|
||
_sliderChanged() { | ||
this._settings.set_uint('night-light-temperature', this.slider.value * (this.maximum - this.minimum) + this.minimum); | ||
} | ||
|
||
|
||
}); | ||
|
||
export const ExampleIndicator = GObject.registerClass( | ||
class ExampleIndicator extends QuickSettings.SystemIndicator { | ||
_init() { | ||
super._init(); | ||
|
||
this.quickSettingsItems.push(new TemperatureItem()); | ||
} | ||
}); | ||
|
||
|
||
export default class SimpleNightLightSlider extends Extension { | ||
enable() { | ||
this._indicator = new ExampleIndicator(this); | ||
Main.panel.statusArea.quickSettings.addExternalIndicator(this._indicator, 2); | ||
} | ||
|
||
disable() { | ||
this._indicator.quickSettingsItems.forEach(item => item.destroy()); | ||
this._indicator.destroy(); | ||
this._indicator = null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "Simple Night Light Slider", | ||
"description": "Change Night Light", | ||
"uuid": "[email protected]", | ||
"shell-version": [ | ||
"45" | ||
], | ||
"version": 1 | ||
} |