Skip to content
Open
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
41 changes: 41 additions & 0 deletions laptop-suspend-inhibitor@carsongfromjpt/applet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const Applet = imports.ui.applet;
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;

class MyTrayApplet extends Applet.IconApplet {
constructor(metadata, orientation, panelHeight, instanceId) {
super(orientation, panelHeight, instanceId);

this.appletPath = metadata.path + "/";

this.set_applet_tooltip("Laptop Suspend Inhibitor: Click to disable suspension when the laptop lid is closed, click again to re-enable. Useful for playing music with the laptop closed.");

// dconf schema and key
this.dconfKey = "/org/cinnamon/settings-daemon/plugins/power/";
this.dconfClient = new Gio.Settings({ schema_id: "org.cinnamon.settings-daemon.plugins.power" });

// Watch dconf for changes
this.dconfClient.connect("changed", () => this.updateIcon());

this.updateIcon();
}

updateIcon() {
let value = this.dconfClient.get_string("lid-close-battery-action");
if (value === "suspend") {
this.set_applet_icon_symbolic_name("suspend");
} else {
this.set_applet_icon_symbolic_name("lock-screen");
}
}

on_applet_clicked(event) {
// Run your script when clicked
GLib.spawn_command_line_async(this.appletPath + "switch-mode.sh");
}
}

function main(metadata, orientation, panelHeight, instanceId) {
return new MyTrayApplet(metadata, orientation, panelHeight, instanceId);
}

Binary file added laptop-suspend-inhibitor@carsongfromjpt/icon.png
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.
60 changes: 60 additions & 0 deletions laptop-suspend-inhibitor@carsongfromjpt/icons/suspend-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions laptop-suspend-inhibitor@carsongfromjpt/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"uuid": "laptop-suspend-inhibitor@carsongfromjpt",
"name": "Laptop Suspend Inhibitor",
"description": "Click to disable suspension when the laptop lid is closed. Click again to re-enable suspension. Useful for playing music with the lid closed.",
"icon": "icon.png"
}

11 changes: 11 additions & 0 deletions laptop-suspend-inhibitor@carsongfromjpt/switch-mode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

if [[ "$(gsettings get org.cinnamon.settings-daemon.plugins.power lid-close-battery-action)" == "'suspend'" ]]
then
action="blank"
else
action="suspend"
fi
gsettings set org.cinnamon.settings-daemon.plugins.power lid-close-ac-action "$action"
gsettings set org.cinnamon.settings-daemon.plugins.power lid-close-battery-action "$action"