Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions files/usr/share/cinnamon/applets/[email protected]/applet.js
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("nightlight-symbolic");
} else {
this.set_applet_icon_symbolic_name("nightlight-disabled-symbolic");
}
}

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);
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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"
}
Loading