Skip to content

Commit 393ff18

Browse files
authored
* Add [email protected] applet * Add [email protected] applet - Removes unused icon * Add [email protected] applet - Change icons * nightlight-applet: renaming icons
1 parent 688c936 commit 393ff18

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
const Applet = imports.ui.applet;
2+
const Gio = imports.gi.Gio;
3+
const PopupMenu = imports.ui.popupMenu;
4+
const Util = imports.misc.util;
5+
const St = imports.gi.St;
6+
7+
class NightLightSwitch extends Applet.IconApplet {
8+
constructor(metadata, orientation, panelHeight, instance_id) {
9+
super(orientation, panelHeight, instance_id);
10+
11+
this.gsettings = Gio.Settings.new("org.cinnamon.settings-daemon.plugins.color");
12+
this.nightLightEnabled = this.gsettings.get_boolean("night-light-enabled");
13+
this.connectColorID = this.gsettings.connect("changed", () => this.set_icon());
14+
this.set_icon();
15+
16+
let items = this._applet_context_menu._getMenuItems();
17+
if (this.context_menu_item_configure == null) {
18+
this.context_menu_item_configure = new PopupMenu.PopupIconMenuItem(_("Configure..."),
19+
"system-run",
20+
St.IconType.SYMBOLIC);
21+
this.context_menu_item_configure.connect('activate',
22+
() => { Util.spawnCommandLineAsync("cinnamon-settings nightlight"); }
23+
);
24+
}
25+
if (items.indexOf(this.context_menu_item_configure) == -1) {
26+
this._applet_context_menu.addMenuItem(this.context_menu_item_configure);
27+
}
28+
}
29+
30+
on_applet_clicked() {
31+
this.gsettings.set_boolean("night-light-enabled", !this.nightLightEnabled);
32+
this.set_icon();
33+
}
34+
35+
set_icon() {
36+
this.nightLightEnabled = this.gsettings.get_boolean("night-light-enabled");
37+
if (this.nightLightEnabled) {
38+
this.set_applet_icon_symbolic_name("nightlight-symbolic");
39+
} else {
40+
this.set_applet_icon_symbolic_name("nightlight-disabled-symbolic");
41+
}
42+
}
43+
44+
on_applet_removed_from_panel() {
45+
this.gsettings.disconnect(this.connectColorID);
46+
}
47+
}
48+
49+
function main(metadata, orientation, panel_height, instance_id) {
50+
return new NightLightSwitch(metadata, orientation, panel_height, instance_id);
51+
}
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"description": "Activate/deactivate Night Light mode.",
3+
"icon": "cs-nightlight",
4+
"max-instances": "1",
5+
"hide-configuration": true,
6+
"uuid": "[email protected]",
7+
"name": "Night Light"
8+
}

0 commit comments

Comments
 (0)