-
Notifications
You must be signed in to change notification settings - Fork 754
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
Showing
5 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
files/usr/share/cinnamon/applets/[email protected]/applet.js
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,51 @@ | ||
const Applet = imports.ui.applet; | ||
const Gio = imports.gi.Gio; | ||
const PopupMenu = imports.ui.popupMenu; | ||
const Util = imports.misc.util; | ||
const St = imports.gi.St; | ||
|
||
class NightLightSwitch extends Applet.IconApplet { | ||
constructor(metadata, orientation, panelHeight, instance_id) { | ||
super(orientation, panelHeight, instance_id); | ||
|
||
this.gsettings = Gio.Settings.new("org.cinnamon.settings-daemon.plugins.color"); | ||
this.nightLightEnabled = this.gsettings.get_boolean("night-light-enabled"); | ||
this.connectColorID = this.gsettings.connect("changed", () => this.set_icon()); | ||
this.set_icon(); | ||
|
||
let items = this._applet_context_menu._getMenuItems(); | ||
if (this.context_menu_item_configure == null) { | ||
this.context_menu_item_configure = new PopupMenu.PopupIconMenuItem(_("Configure..."), | ||
"system-run", | ||
St.IconType.SYMBOLIC); | ||
this.context_menu_item_configure.connect('activate', | ||
() => { Util.spawnCommandLineAsync("cinnamon-settings nightlight"); } | ||
); | ||
} | ||
if (items.indexOf(this.context_menu_item_configure) == -1) { | ||
this._applet_context_menu.addMenuItem(this.context_menu_item_configure); | ||
} | ||
} | ||
|
||
on_applet_clicked() { | ||
this.gsettings.set_boolean("night-light-enabled", !this.nightLightEnabled); | ||
this.set_icon(); | ||
} | ||
|
||
set_icon() { | ||
this.nightLightEnabled = this.gsettings.get_boolean("night-light-enabled"); | ||
if (this.nightLightEnabled) { | ||
this.set_applet_icon_symbolic_name("night-light"); | ||
} else { | ||
this.set_applet_icon_symbolic_name("night-light-disabled"); | ||
} | ||
} | ||
|
||
on_applet_removed_from_panel() { | ||
this.gsettings.disconnect(this.connectColorID); | ||
} | ||
} | ||
|
||
function main(metadata, orientation, panel_height, instance_id) { | ||
return new NightLightSwitch(metadata, orientation, panel_height, instance_id); | ||
} |
Binary file added
BIN
+24.6 KB
files/usr/share/cinnamon/applets/[email protected]/icons/icon_OLD.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions
4
...innamon/applets/[email protected]/icons/night-light-disabled-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions
4
...r/share/cinnamon/applets/[email protected]/icons/night-light-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions
8
files/usr/share/cinnamon/applets/[email protected]/metadata.json
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,8 @@ | ||
{ | ||
"description": "Activate/deactivate Night Light mode.", | ||
"icon": "cs-nightlight", | ||
"max-instances": "1", | ||
"hide-configuration": true, | ||
"uuid": "[email protected]", | ||
"name": "Night Light" | ||
} |