Skip to content

Commit

Permalink
[Exit@claudiux] v1.4.0 - Take into account inhibition during automati…
Browse files Browse the repository at this point in the history
…c updates (#6664)

* v1.4.0 - Take into account inhibition during automatic updates

* v1.4.0 - Update fr.po
  • Loading branch information
claudiux authored Dec 4, 2024
1 parent b22a805 commit f6a4d8d
Show file tree
Hide file tree
Showing 13 changed files with 323 additions and 157 deletions.
186 changes: 127 additions & 59 deletions Exit@claudiux/files/Exit@claudiux/5.4/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ const St = imports.gi.St;
const { restartCinnamon } = imports.ui.main;
const Mainloop = imports.mainloop;

// l10n/translation support
const UUID = "Exit@claudiux";
//~ Gettext.bindtextdomain(UUID, GLib.get_home_dir() + "/.local/share/locale");
const SCRIPTS_DIR = GLib.get_home_dir()+"/.local/share/cinnamon/applets/"+UUID+"/scripts";
const CANSHUTDOWN_SCRIPT = SCRIPTS_DIR+"/can-shutdown.sh";

// l10n/translation support
function _(str) {
Gettext.bindtextdomain(UUID, GLib.get_home_dir() + "/.local/share/locale");
let _str = Gettext.dgettext(UUID, str);
Expand Down Expand Up @@ -57,6 +58,8 @@ class ExitApplet extends Applet.IconApplet {

this.isWaylandSession = Meta.is_wayland_compositor();

this.can_shutdown = false;

this._screenSaverProxy = new ScreenSaver.ScreenSaverProxy();

this.set_applet_icon_symbolic_name("system-shutdown");
Expand Down Expand Up @@ -99,6 +102,17 @@ class ExitApplet extends Applet.IconApplet {
this.displaySwitchUserSetting = !this.lockdown_settings.get_boolean('disable-user-switching') && !this.isWaylandSession;
this.displayLogoutSetting = !this.lockdown_settings.get_boolean('disable-log-out');

let subProcess = Util.spawnCommandLineAsyncIO(CANSHUTDOWN_SCRIPT, Lang.bind(this,
function(stdout, stderr, exitCode) {
if (exitCode == 0) {
this.can_shutdown = true;
} else {
this.can_shutdown = false;
}
subProcess.send_signal(9);
})
);

this.loop = Mainloop.timeout_add_seconds(1, () => this.check_system_managed_options());
return false;
}
Expand Down Expand Up @@ -185,32 +199,41 @@ class ExitApplet extends Applet.IconApplet {
}

if (allow_switch_user && this.showSwitchUser) {
if (GLib.getenv("XDG_SEAT_PATH")) {
// LightDM
item = new PopupMenu.PopupIconMenuItem(_("Switch User"), "system-switch-user-symbolic", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function () {
this.menu.close(true);
launcher.spawnv(["cinnamon-screensaver-command", "--lock"]);
launcher.spawnv(["dm-tool", "switch-to-greeter"]);
}));
this.menu.addMenuItem(item);
}
else if (GLib.file_test("/usr/bin/mdmflexiserver", GLib.FileTest.EXISTS)) {
// MDM
item = new PopupMenu.PopupIconMenuItem(_("Switch User"), "system-switch-user-symbolic", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function () {
this.menu.close(true);
launcher.spawnv(["mdmflexiserver"]);
}));
this.menu.addMenuItem(item);
}
else if (GLib.file_test("/usr/bin/gdmflexiserver", GLib.FileTest.EXISTS)) {
// GDM
item = new PopupMenu.PopupIconMenuItem(_("Switch User"), "system-switch-user-symbolic", St.IconType.SYMBOLIC);
if (this.can_shutdown) {
if (GLib.getenv("XDG_SEAT_PATH")) {
// LightDM
item = new PopupMenu.PopupIconMenuItem(_("Switch User"), "system-switch-user-symbolic", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function () {
this.menu.close(true);
launcher.spawnv(["cinnamon-screensaver-command", "--lock"]);
launcher.spawnv(["dm-tool", "switch-to-greeter"]);
}));
this.menu.addMenuItem(item);
}
else if (GLib.file_test("/usr/bin/mdmflexiserver", GLib.FileTest.EXISTS)) {
// MDM
item = new PopupMenu.PopupIconMenuItem(_("Switch User"), "system-switch-user-symbolic", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function () {
this.menu.close(true);
launcher.spawnv(["mdmflexiserver"]);
}));
this.menu.addMenuItem(item);
}
else if (GLib.file_test("/usr/bin/gdmflexiserver", GLib.FileTest.EXISTS)) {
// GDM
item = new PopupMenu.PopupIconMenuItem(_("Switch User"), "system-switch-user-symbolic", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function () {
this.menu.close(true);
launcher.spawnv(["cinnamon-screensaver-command", "--lock"]);
launcher.spawnv(["gdmflexiserver"]);
}));
this.menu.addMenuItem(item);
}
} else {
item = new PopupMenu.PopupIconMenuItem(_("Switch User"), "action-unavailable-symbolic", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function () {
this.menu.close(true);
launcher.spawnv(["cinnamon-screensaver-command", "--lock"]);
launcher.spawnv(["gdmflexiserver"]);
launcher.spawnv(["notify-send", "--icon=mintupdate-installing", _("Performing automatic updates"), _("Please wait")]);
}));
this.menu.addMenuItem(item);
}
Expand All @@ -222,57 +245,102 @@ class ExitApplet extends Applet.IconApplet {
}

if (allow_log_out && this.showLogout) {
item = new PopupMenu.PopupIconMenuItem(_("Log Out"), "system-log-out-symbolic", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function () {
this.menu.close(true);
launcher.spawnv(["cinnamon-session-quit", "--logout", this.logoutMode]);
}));
this.menu.addMenuItem(item);
if (this.can_shutdown) {
item = new PopupMenu.PopupIconMenuItem(_("Log Out"), "system-log-out-symbolic", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function () {
this.menu.close(true);
launcher.spawnv(["cinnamon-session-quit", "--logout", this.logoutMode]);
}));
this.menu.addMenuItem(item);
} else {
item = new PopupMenu.PopupIconMenuItem(_("Log Out"), "action-unavailable-symbolic", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function () {
this.menu.close(true);
launcher.spawnv(["notify-send", "--icon=mintupdate-installing", _("Performing automatic updates"), _("Please wait")]);
}));
this.menu.addMenuItem(item);
}
}

if (allow_log_out || allow_lock_screen || allow_switch_user)
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());

if (this.showSuspend) {
item = new PopupMenu.PopupIconMenuItem(_("Suspend"), "system-suspend", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function () {
this.menu.close(true);
launcher.spawnv(["systemctl", "suspend"]);
}));
this.menu.addMenuItem(item);
if (this.can_shutdown) {
item = new PopupMenu.PopupIconMenuItem(_("Suspend"), "system-suspend", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function () {
this.menu.close(true);
launcher.spawnv(["systemctl", "suspend"]);
}));
this.menu.addMenuItem(item);
} else {
item = new PopupMenu.PopupIconMenuItem(_("Suspend"), "action-unavailable-symbolic", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function () {
this.menu.close(true);
launcher.spawnv(["notify-send", "--icon=mintupdate-installing", _("Performing automatic updates"), _("Please wait")]);
}));
this.menu.addMenuItem(item);
}
}

if (this.showHibernate) {
item = new PopupMenu.PopupIconMenuItem(_("Hibernate"), "system-suspend-hibernate", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function () {
this.menu.close(true);
if (this.hibernateNeedsSudo)
launcher.spawnv(["pkexec", "sudo", "systemctl", "hibernate"]);
else
launcher.spawnv(["systemctl", "hibernate"]);
}));
this.menu.addMenuItem(item);
if (this.can_shutdown) {
item = new PopupMenu.PopupIconMenuItem(_("Hibernate"), "system-suspend-hibernate", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function () {
this.menu.close(true);
if (this.hibernateNeedsSudo)
launcher.spawnv(["pkexec", "sudo", "systemctl", "hibernate"]);
else
launcher.spawnv(["systemctl", "hibernate"]);
}));
this.menu.addMenuItem(item);
} else {
item = new PopupMenu.PopupIconMenuItem(_("Hibernate"), "action-unavailable-symbolic", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function () {
this.menu.close(true);
launcher.spawnv(["notify-send", "--icon=mintupdate-installing", _("Performing automatic updates"), _("Please wait")]);
}));
this.menu.addMenuItem(item);
}
}

if (this.showSuspend || this.showHibernate)
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());

if (this.showRestart) {
item = new PopupMenu.PopupIconMenuItem(_("Restart"), "view-refresh", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function () {
this.menu.close(true);
launcher.spawnv(["systemctl", "reboot"]);
}));
this.menu.addMenuItem(item);
if (this.can_shutdown) {
item = new PopupMenu.PopupIconMenuItem(_("Restart"), "view-refresh", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function () {
this.menu.close(true);
launcher.spawnv(["systemctl", "reboot"]);
}));
this.menu.addMenuItem(item);
} else {
item = new PopupMenu.PopupIconMenuItem(_("Restart"), "action-unavailable-symbolic", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function () {
this.menu.close(true);
launcher.spawnv(["notify-send", "--icon=mintupdate-installing", _("Performing automatic updates"), _("Please wait")]);
}));
this.menu.addMenuItem(item);
}
}

if (this.showPowerOff) {
item = new PopupMenu.PopupIconMenuItem(_("Power Off"), "system-shutdown-symbolic", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function () {
this.menu.close(true);
launcher.spawnv(["systemctl", "poweroff"]);
}));
this.menu.addMenuItem(item);
if (this.can_shutdown) {
item = new PopupMenu.PopupIconMenuItem(_("Power Off"), "system-shutdown-symbolic", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function () {
this.menu.close(true);
launcher.spawnv(["systemctl", "poweroff"]);
}));
this.menu.addMenuItem(item);
} else {
item = new PopupMenu.PopupIconMenuItem(_("Power Off"), "action-unavailable-symbolic", St.IconType.SYMBOLIC);
item.connect('activate', Lang.bind(this, function () {
this.menu.close(true);
launcher.spawnv(["notify-send", "--icon=mintupdate-installing", _("Performing automatic updates"), _("Please wait")]);
}));
this.menu.addMenuItem(item);
}
}

}
Expand Down
4 changes: 4 additions & 0 deletions Exit@claudiux/files/Exit@claudiux/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### v1.4.0~20241204

* Take into account inhibition during automatic updates.

### v1.3.0~20241114

* New option: Screen Off. You can also set the mouse deactivation time to prevent the screen from turning on too soon after you've turned it off.
Expand Down
2 changes: 1 addition & 1 deletion Exit@claudiux/files/Exit@claudiux/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"description": "Restart Cinnamon, turn off the screen, lock the screen, switch users, log out, suspend, hibernate, reboot or shut down the computer",
"uuid": "Exit@claudiux",
"name": "Exit",
"version": "1.3.0",
"version": "1.4.0",
"max-instances": -1,
"author": "claudiux"
}
32 changes: 21 additions & 11 deletions Exit@claudiux/files/Exit@claudiux/po/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Exit@claudiux 1.3.0\n"
"Project-Id-Version: Exit@claudiux 1.4.0\n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-applets/"
"issues\n"
"POT-Creation-Date: 2024-11-14 23:59+0100\n"
"POT-Creation-Date: 2024-12-04 14:43+0100\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
Expand All @@ -17,39 +17,49 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#. 5.4/applet.js:126
#. 5.4/applet.js:140
msgid "Restart Cinnamon"
msgstr ""

#. 5.4/applet.js:138
#. 5.4/applet.js:152
msgid "Screen Off"
msgstr ""

#. 5.4/applet.js:163
#. 5.4/applet.js:177
msgid "Lock Screen"
msgstr ""

#. 5.4/applet.js:190 5.4/applet.js:200 5.4/applet.js:209
#. 5.4/applet.js:205 5.4/applet.js:215 5.4/applet.js:224 5.4/applet.js:233
msgid "Switch User"
msgstr ""

#. 5.4/applet.js:225
#. 5.4/applet.js:236 5.4/applet.js:259 5.4/applet.js:280 5.4/applet.js:301
#. 5.4/applet.js:322 5.4/applet.js:340
msgid "Performing automatic updates"
msgstr ""

#. 5.4/applet.js:236 5.4/applet.js:259 5.4/applet.js:280 5.4/applet.js:301
#. 5.4/applet.js:322 5.4/applet.js:340
msgid "Please wait"
msgstr ""

#. 5.4/applet.js:249 5.4/applet.js:256
msgid "Log Out"
msgstr ""

#. 5.4/applet.js:237
#. 5.4/applet.js:270 5.4/applet.js:277
msgid "Suspend"
msgstr ""

#. 5.4/applet.js:246
#. 5.4/applet.js:288 5.4/applet.js:298
msgid "Hibernate"
msgstr ""

#. 5.4/applet.js:261
#. 5.4/applet.js:312 5.4/applet.js:319
msgid "Restart"
msgstr ""

#. 5.4/applet.js:270
#. 5.4/applet.js:330 5.4/applet.js:337
msgid "Power Off"
msgstr ""

Expand Down
30 changes: 20 additions & 10 deletions Exit@claudiux/files/Exit@claudiux/po/ca.po
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-applets/"
"issues\n"
"POT-Creation-Date: 2024-11-14 23:59+0100\n"
"POT-Creation-Date: 2024-12-04 14:43+0100\n"
"PO-Revision-Date: 2024-11-20 02:06+0100\n"
"Last-Translator: Odyssey <[email protected]>\n"
"Language-Team: \n"
Expand All @@ -19,39 +19,49 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.4.2\n"

#. 5.4/applet.js:126
#. 5.4/applet.js:140
msgid "Restart Cinnamon"
msgstr "Reiniciar Cinnamon"

#. 5.4/applet.js:138
#. 5.4/applet.js:152
msgid "Screen Off"
msgstr "Apagar la pantalla"

#. 5.4/applet.js:163
#. 5.4/applet.js:177
msgid "Lock Screen"
msgstr "Bloquejar la pantalla"

#. 5.4/applet.js:190 5.4/applet.js:200 5.4/applet.js:209
#. 5.4/applet.js:205 5.4/applet.js:215 5.4/applet.js:224 5.4/applet.js:233
msgid "Switch User"
msgstr "Canviar d'usuari"

#. 5.4/applet.js:225
#. 5.4/applet.js:236 5.4/applet.js:259 5.4/applet.js:280 5.4/applet.js:301
#. 5.4/applet.js:322 5.4/applet.js:340
msgid "Performing automatic updates"
msgstr ""

#. 5.4/applet.js:236 5.4/applet.js:259 5.4/applet.js:280 5.4/applet.js:301
#. 5.4/applet.js:322 5.4/applet.js:340
msgid "Please wait"
msgstr ""

#. 5.4/applet.js:249 5.4/applet.js:256
msgid "Log Out"
msgstr "Tancar la sessió"

#. 5.4/applet.js:237
#. 5.4/applet.js:270 5.4/applet.js:277
msgid "Suspend"
msgstr "Suspendre"

#. 5.4/applet.js:246
#. 5.4/applet.js:288 5.4/applet.js:298
msgid "Hibernate"
msgstr "Hivernar"

#. 5.4/applet.js:261
#. 5.4/applet.js:312 5.4/applet.js:319
msgid "Restart"
msgstr "Reiniciar"

#. 5.4/applet.js:270
#. 5.4/applet.js:330 5.4/applet.js:337
msgid "Power Off"
msgstr "Apagar"

Expand Down
Loading

0 comments on commit f6a4d8d

Please sign in to comment.