Hi,
I have a problem with shutdown menu. It used to be different before update. Let me explain. When I press physical button or press Ctrl+Alt+Del it shows a menu with shutdown,restart, sleep and cancel but When I use widget that I have for app Menu it just shows shutdown and cancel. In source code on button press this widget uses ‘requestShutdown’ on powerdevil. I tried to modify plasmoid in /usr/share/plasma/org.kde.plasma.lock_logout but even when I change the operation to requestLogoutPrompt it still shows only 2 buttons. Is there a config file for this menu? So I can just modify it and restart the service or is it some advance dbus magic I need to do to modify it? I know that this is the command I need to replace but don’t know exactly where: qdbus6 org.kde.LogoutPrompt /LogoutPrompt promptShutDown to qdbus6 org.kde.LogoutPrompt /LogoutPrompt promptAll.
That screen with multiple buttons is called “logout screen”
It can be configured to appear when you click on your physical button
You can also show it via a configurable shortcut
That screen is a general page with multiple options, but in the application launcher when you click on an irreversible action like shutdown, restart or logout it means you already selected your action, so the next window appearing should either confirm that action or revert it. That confirmation window will not appear for other actions like lock, sleep or hibernate because they normally don’t kill your apps and are east/fast to revert by user.
For example your press shutdown in application menu
The next window should simply confirm shutdown or revert it
The same applies for logout and restart.
If you want another easy way to access that “logout screen”, you can add a widget called “Lock/Logout” to your panel or desktop
Then configure to show that window
When Plasma 6 landed, I didn’t like the fact that the default for the leave session menu was always shutdown rather than my preferred logout and I couldn’t find a way to change it.
My solution was a quick and dirty Perl script which gave me the options I wanted, along with setting logout to be the default.
#!/usr/bin/perl
use strict;
use warnings;
no warnings qw(uninitialized);
use utf8;
use open ':utf8';
binmode STDOUT, ":utf8";
binmode STDERR, ":utf8";
use lib "/usr/local/perl/lib/perl5";
use Glib qw(TRUE FALSE);
use Gtk3 "-init";
$SIG{'INT'} = sub{print("interrupt\n");exit(999)};
# Create Gtk window
my $window = Gtk3::Window->new("toplevel");
$window->set_position("center");
$window->set_title("Shutdown / closeSession menu");
$window->set_border_width(5);
$window->set_size_request(400,100);
# Make the [x] button exit the script
$window->signal_connect(delete_event=> \&finish);
# Add horizontal button box
my $buttonBox = Gtk3::Box->new("horizontal",5);
$window->add($buttonBox);
$buttonBox->pack_start($buttonBox, TRUE, TRUE, 0);
# Add cancel button
my $cancel = Gtk3::Button->new_with_label("Cancel");
$cancel->signal_connect(clicked=>\&finish);
$buttonBox->pack_start($cancel,TRUE,TRUE,0);
# Add logout button
my $closeSession = Gtk3::Button->new_with_label("Logout");
$closeSession->signal_connect(clicked=>\&closeSession);
$buttonBox->pack_start($closeSession,TRUE,TRUE,0);
# Make logout button the default
$closeSession->grab_focus;
# Add reboot button
my $reboot = Gtk3::Button->new_with_label("Reboot");
$reboot->signal_connect(clicked=>\&reboot);
$buttonBox->pack_start($reboot,TRUE,TRUE,0);
# Add shutdown button
my $shutdown = Gtk3::Button->new_with_label("Shutdown");
$shutdown->signal_connect(clicked=>\&shutdown);
$buttonBox->pack_start($shutdown,TRUE,TRUE,0);
# This will be used to close the window with the <esc> key
$window->signal_connect('key-press-event' => \&keypress);
# Show the window
$window->show_all;
Gtk3->main;
# This intercepts keyboard events and picks up the <esc> key
# to force quit
sub keypress
{
my ($widget, $event) = @_;
my $keyval = $event->keyval;
my $key = Gtk3::Gdk::keyval_name($keyval);
if($key eq "Escape")
{
finish();
}
}
# Handle window close and cancel buttons
sub finish
{
$window->destroy();
Gtk3->main_quit;
exit;
}
# Just log out
sub closeSession
{
$window->destroy();
Gtk3->main_quit;
tidyClose1();
tidyClose2();
system("qdbus6 org.kde.Shutdown /Shutdown logout");
exit
}
# Log out then reboot
sub reboot
{
$window->destroy();
Gtk3->main_quit;
tidyClose1();
system("qdbus6 org.kde.Shutdown /Shutdown logoutAndReboot");
exit
}
# Log out then power down
sub shutdown
{
$window->destroy();
Gtk3->main_quit;
tidyClose1();
system("qdbus6 org.kde.Shutdown /Shutdown logoutAndShutdown");
exit
}
sub tidyClose1
{
# Shell script to tidy up session before logout
system("tidyClose1 > /var/tmp/tidyClose.log 2>&1");
}
sub tidyClose2
{
# Shell script to run ONLY before logout, not
# before reboot or shutdown. Because there's no
# point in it unless it's only a logout
system("tidyClose2 >> /var/tmp/tidyClose.log 2>&1");
}
Requires perl, perl-gtk3 and glib-perl. You probably don’t need the tidyClose1 and tidyClose2 subroutines, which I just use to tidily shut all my applications down. Just comment out the calls to them.
If you want a button other than logout to be the default, change
$closeSession->grab_focus;
to refer to the button you want.
Ok, I already knew this all but I thought I can somehow override it. So I think I will have to download the source of this widget and modify the system call it’s using. Thank you.