Closed RedBearAK closed 2 years ago
Hey, thanks for the PR, I appreciate the changes. Just one recommendation - Remove the extra commands comments, if I ever need to reference them then I will look up the PR. Once done, I will merge the changes. Thanks for your work!
@Aryan20
Cleaned up the extra comments as requested, leaving only the dbus-send
versions. Thanks!
Thanks!
Replaces non-interactive immediate actions for the restart, shutdown, lock screen and logout menu options with interactive
dbus-send
commands that trigger the standard user-confirmation dialogs for these functions (except lock screen function).Why: The usual UI expectation in macOS, GNOME or most other full desktop environments is for Restart, Shutdown and Logout commands to trigger the display of a confirmation dialog, to allow the user to cancel an accidental triggering of the command that may interrupt the use of the desktop in an unwanted way.
I can confirm that both the current Restart (
systemctl reboot
) and Shut Down (systemctl poweroff -prompt
) menu options take immediate action without producing any prompts on Ubuntu 22.04. These replacement commands will fix that.Two menu option labels (Restart, Shutdown) are changed here to add ellipsis "..." to show that the command will now open a window/dialog or has a second step of some kind before it takes action.
Some alternative commands are left here in commented-out lines, which should bring up the same interactive user-confirmation dialogs. These use CLI arguments to the
gnome-session-quit
command instead ofdbus-send
. They seem to do exactly the same thing, just in a different way. (There is nognome-session-quit
CLI option for locking the screen, only for restart, shutdown and logout.)The original commands that implemented the restart, shutdown, lock screen and logout functions are also left here in commented-out lines for reference.
The full
dbus-send
(and alternatively thegnome-session-quit
) commands are:Restart...: gnome-session-quit --reboot dbus-send --session --type=method_call --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.Reboot
Shut Down...: gnome-session-quit --power-off dbus-send --session --type=method_call --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.Shutdown
Lock screen: dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock
Log Out...: gnome-session-quit --logout (seems to work the same way with or without the "--logout" option) dbus-send --session --type=method_call --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.Logout uint32:0
References:
https://itectec.com/ubuntu/ubuntu-reboot-without-sudoer-privileges/ https://github.com/collinss/Session-Manager/blob/master/commands https://gitlab.gnome.org/GNOME/gnome-session/-/blob/main/gnome-session/org.gnome.SessionManager.xml