Closed lukefromdc closed 1 year ago
As usual, this is a wayland-only change and should have no effect on x11 behavior.
The wayland shutdown button works by trying system("shutdown now")
first for shutdown and system ("reboot now")
first for reboot, then systemd's versions of those commands if that fails. We do not have "suspend" as a low level system command, so we are forced to rely on systemd (or logind if anyone will write support for it) for suspend.
Logind support is welcome if anyone wants to code it up! I do not have the bandwidth to experiment with multiple distros so cannot code on or test logind. Suspend (and shutdown or reboot with root logged in ) should silently fail if systemd is not installed, with no other adverse effects.
A lot of the action button functions (logout, force-quit) are not easy to implement in wayland as using system, systemd, or logind commands are not enough.
Note that logging in/out under wayland works differently than in x11 but there are a number of standalone logout managers available for wayland. A panel launcher for one could perhaps be offered for one with very little effort if it is installed
Request for more Travis credits submitted
Suspend-disk or hibernate button is missing. Command is systemctl hibernate
.
I have that configured on my system and i can test it.
I can add that button easily enough. It should be either not added or greyed out when hibernation is not available, but to do that I need to find a way to detect that in the absence of a session manager. If that turns into a no-go, we could simply have a dialog message come up when an unsupported button is clicked.
On systemd boxes shutdown, reboot and halt commands are implemented by systemd, see manpages.
Are they SysV
systems nowadays which use the old start system?
With logind
support you mean systemd-logind or the elogind project? https://github.com/elogind/elogind
Systemd-logind provides the loginctl
command. Not tested with wayland session but maybe loginctl lock-session [ID...]
or loginctl lock-sessions
can be used for lock the session?
See man loginctl for options.
Edit: loginctl doesn't work with my wayfire session. So this can't be used.
I can add that button easily enough. It should be either not added or greyed out when hibernation is not available, but to do that I need to find a way to detect that in the absence of a session manager.
With X11 and systemd /etc/systemd/sleep.conf is used.
Without AllowHibernation=yes
the button isn't visible if i recall correctly.
I use this config:
[Sleep]
AllowSuspend=yes
AllowHibernation=yes
AllowSuspendThenHibernate=yes
AllowHybridSleep=yes
#SuspendMode=
#SuspendState=mem standby freeze
HibernateMode=platform shutdown
from this guide https://www.ctrl.blog/entry/fedora-hibernate.html
The existing x11 code makes some dbus calls to connect to systemd, which I am not familiar with writing new code for yet.
Tells me out to set up hibernation (this is an encrypted machine with 40G RAM so not practical) but not how to determine via systemd if it is enabled. The system() call lets me execute a command, but I would need to be able to tell from inside the C binary whether cat /sys/power/disk | grep "hibernate" returns a zero or non-zero length string at the least.
I have the button working but on my machine w/o hiberation support clicking it does nothing
Forget about loginctl. This doesn't work with wayfire.
Just forced-pushed the code as it sits now, the hibernate button is shown unconditionally.
I have the button working but on my machine w/o hiberation support clicking it does nothing
Sure you need a swap disk
the resume modul needs to be added as dracut modul to dracut config
initramfs needs to be rebuild
A grub entry GRUB_CMDLINE_LINUX="[…] resume=UUID=your-swap-identifier"
If encrypted GRUB_CMDLINE_LINUX="[…] rd.luks.uuid=your-swap-identifier"
and an upddated /etc/systemd/sleep.conf
See my link.
But i am sure they are ToDo's for debian :)
I am using a customized unlocking system inside Dracut, a very non-stock setup. At any rate between us we have the hiberation supported and hiberation not supported test cases.
I considered just waiting a few seconds, then popping up a "hibernation not supported" dialog, but then realized that would come up on resume
offtopic on
Without this PR.
During the last 3-4 month the lock screen
, logout
and shutdown
entrys in menu aren't translated anymore.
They simply displayed in english. With 1.26 everything is fine.
But i have forgotten which commit in a package did caused this issue.
Any idea which package provide those entries?
offtopic off
Not sure of that BUT if the shutdown button is disabled from being added to the panel (w/o my code due to lack of a connection to a session manager,) it also does not appear in the menus
They might be from gsm-logout-dialog.c in mate-session-manager, that's where I got the matching icon names from
Just got an error dialog working for unsupported cases, it's used for all cases but cancel if the commands fail.
There is the --dry-run
option in systemd but it does not work with-i
or --check-inhibitors=no
which are necessary to overrride cases of a display manager logged in as root. Also the --dry-run
option has been buggy and there have been versions of systemd that ignored it. That could cause someone getting a bad systemd update to get a machine that suspends (first button added) as soon as the panel shut down button is pressed.
Finally found a way to hide unsupported buttons, at least when systemd is present and /sys/power/disk exists and lists the supported shutdown/suspend/reboot/hibernate options. When that does not work the buttons are shown unconditionally and an error dialog pops up if an unsupported button is clicked.
The new gui is working in wayfire session but i do not have the hibernate button. It seems the checks for hibernate is different in fedora.
[rave@mother ~]$ cat /sys/power/disk
[platform] shutdown reboot suspend test_resume
From a terminal in wayfire session i can hibernate the system with systemctl hibernate
I think this file is responsible for enable power states with systemd.
[rave@mother ~]$ cat /etc/systemd/sleep.conf
# This file is part of systemd.
<cut>
# See systemd-sleep.conf(5) for details.
[Sleep]
AllowSuspend=yes
AllowHibernation=yes
AllowSuspendThenHibernate=yes
AllowHybridSleep=yes
#SuspendMode=
#SuspendState=mem standby freeze
HibernateMode=platform shutdown
#HibernateState=disk
#HybridSleepMode=suspend platform shutdown
#HybridSleepState=disk
#HibernateDelaySec=180min
Power management code is actually something I know little about. I can try looking for the strings in sleep.conf and calling the button supported if either check works perhaps? If that isn't reliable we can show the buttons unconditionally and let the error dialog handle the unsupported cases
I do not know nothing about power states, same like you. I only read https://docs.kernel.org/admin-guide/pm/sleep-states.html#basic-sysfs-interfaces-for-system-suspend-and-hibernation Please read kernel docs The file /sys/power/disk is the right place. On a system w hibernate it looks like this
[root@mother rave]# cat /sys/power/disk
[platform] shutdown reboot suspend test_resume
On a system w/o hibernate like yours it look like this
[rave@satellite ~]$ cat /sys/power/disk
[disabled]
First output shows only what happens after the hibernate image was writen. So your checks are wrong.
Thanks, I will redo those
Also seeing /sys/power/disk controls hibernation ONLY, others are (as seems rational) checked elsewhere
Also seeing /sys/power/disk controls hibernation ONLY, others are (as seems rational) checked elsewhere
yes, that`s the point.
grep disabled /sys/power/disk
[disabled]
Than we know the system doesn't support hibernation.
The output I get from cat/sys/power/disk
is
[platform] shutdown reboot suspend test_resume
on a machine not supporting hibernation. On my system disabled
does not show up.
if look at /sys/power/state I get freeze mem disk
as the KERNEL supports hibernation. Note that this is NOT a Debian kernel but a local build.
Might have to use the systemd method for this. This is probably because it's the OS not the hardware that does not support hiberation here. It's even possible we might have to show hiberation anytime the kernel and hardware support it, and use the error dialog (which shows if the command fails) to catch cases where the OS is not set up to support hibernation.
Looks like your machine should support hibernation.
I have other results on fedora 38
with hibernation
[platform] shutdown reboot suspend test_resume
w/o hibernation
[disabled]
Any way, i don't want to look why we have different results from /sys/power/disk
For me an error message is OK when hibernation isn't suported
OK, I will show the buttons unconditionally. I am not going to try to set up hibernation on a machine with 48G ram and custom code in dracut. This will also simplify the code
The main reason for hibernation is a security one. With hibernation support i can unplug the whole current circuit (system, routers, monitors, etc) from power grid when i am not at home ;) And i save power.
I rarely suspend-and never if I am going to be out of the house, always a full shutdown for that. Real point is we need to support many use cases, and our different configurations allow testing two right here
Latest force-push shows all buttons unconditionally. Error dialogs for suspend and hiberation failures are now more informative, and they are removed from the shutdown and reboot cases as these should always work unless logout is disabled in gsettings. In that case, the shutdown button cannot be added to the panel and is unresponsive if already there, same behavior as in x11.
About the other panel action buttons: connect to server works without any changes at all search for files and run application also work w no changes lock screen and logout depend on session management and do not work as of now
in wayland screen locking and logout are usually controlled by separate programs. To support these would require an optional build time dependency on a wayland screenlocker and logout manager, or possibly importing code from them to build MATE wayland backends. Simplest way to use such programs though would be a panel launcher for them put in the panel by a user. That would allow user to install any logout manager and screenlocker they want, which may vary with the choice of compositor.
The compositor does a lot of the work in wayland. In my wayfire sessions, wayfire is doing the work of compiz/marco, mate-session-manager, and possibly even some portions of mate-settings-daemon. I have created a local test session that runs from SDDM using just two text files and the edited wayfire.ini file. There might be other compositors more easily integrated into a session now or in the future plus that in no way would harm the ability to use MATE components in any wlroots-based wayland session. That last part is the same modularity we now have in Xorg where the panel, caja, etc can be used outside of MATE
This works fine. The hibernate button is there and hibernation process works as expected. But the suspend button is enabled as default. Can this be change to shutdown, same as in x11?
Can you please add the .linked style class to GtkButtonBox, which is the parent of the buttons? Menta and Submarine themes use that style class to theme the logout dialog.
Done and done: GtkInspector shows the .linked style class, and the subtle squaring of the inside corners in those themes now works. Also used gtk_widget_grab_focus
to make the shutdown button the default. Click the panel button, hit return, and the machine shuts down
Note that when I used GtkInspector to change the theme of the dialog (and the whole panel as it's part of the panel), the buttons did NOT become connected, just had square inside corners with the .linked style class added to buttonbox. Do I need to add it to the buttons too?
No, .linked button
is the right syntax in themes. But i see the gap between the buttons too. Also the corner-radius from
left and right buttons will be ignored. It looks better than before. I need to think about..... This can be done later, ihmo.
What we really need is to center the buttonbox. In Gtk-inspector i choose halign=GTK_ALIGN_CENTER
In fact, I get identical style classes between x11 and wayland with this
I actually GOT the corner radius, this is what setting the theme for the dialog in GtkInspector to green-submarine looked like. This is a photo as I haven't set up a wayland screenshooter yet.
Adding the .text-button style class to the buttons had no effect. I am going to have to find the code in the themes and have another look at this.
Problem is in the theme and a rendering difference between x11 and wayland: you have
* {
padding: 0;
background-clip: padding-box;
-GtkDialog-button-spacing: 4; /* ie. logout dialog */
-GtkDialog-action-area-border: 10; /* ie. logout dialog */
in green-submarine, changing the button spacing to zero aligns the buttons. I am guessing in x11 the .linked style class overrides that and in wayland it doesn't-or that there is some special way to create linked buttons.
Centering works fine applying halign=GTK_ALIGN_CENTER to the buttonbox BTW.
Refactoring a bit to split out creating the buttons so this is easier to work on
This is what I've got the dialog looking like in wayfire with green-submarine. Again, we have
-GtkDialog-action-area-border: 10; /* ie. logout dialog */
as a default in green-submarine and probably most of the other themes. It is somehow overridden for linked buttons in x11 but now wayland. Since it is not the default behavior for linked buttons, the .linked style class should set a spacing of zero in themes. I tested that, got a perfect rendering of linked buttons, and centered as well from setting gtk_widget_set_halign(buttonbox,GTK_ALIGN_CENTER);
also tested a build with --enable-wayland=no
to make sure I didn't mess up the selectors for that, build went fine and ran on x11 as expected. Does not render on wayland w/o wayland support of course. Then rebuilt with wayland support, no surprises.
Problem is in the theme and a rendering difference between x11 and wayland: you have
* { padding: 0; background-clip: padding-box; -GtkDialog-button-spacing: 4; /* ie. logout dialog */ -GtkDialog-action-area-border: 10; /* ie. logout dialog */
in green-submarine, changing the button spacing to zero aligns the buttons. I am guessing in x11 the .linked style class overrides that and in wayland it doesn't-or that there is some special way to create linked buttons.
Centering works fine applying halign=GTK_ALIGN_CENTER to the buttonbox BTW.
Good analyses, i am sure i can find out in submarine and menta themes why the linked
style class doesn't override the button-spacing. Dialog looks fine now.
We have some new build warnings. https://app.travis-ci.com/github/mate-desktop/mate-panel/jobs/610742722#L5291
CC mate_panel-panel-action-button.o
panel-action-button.c:251:19: warning: comparison of integers of different signs: 'guint' (aka 'unsigned int') and 'int' [-Wsign-compare]
if (response_id == GTK_RESPONSE_CANCEL)
~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~
panel-action-button.c:257:19: warning: comparison of integers of different signs: 'guint' (aka 'unsigned int') and 'int' [-Wsign-compare]
if (response_id == GTK_RESPONSE_OK)
~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~
panel-action-button.c:272:19: warning: comparison of integers of different signs: 'guint' (aka 'unsigned int') and 'int' [-Wsign-compare]
if (response_id == GTK_RESPONSE_ACCEPT)
~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~
panel-action-button.c:284:19: warning: comparison of integers of different signs: 'guint' (aka 'unsigned int') and 'int' [-Wsign-compare]
if (response_id == GTK_RESPONSE_REJECT)
~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~
panel-action-button.c:303:19: warning: comparison of integers of different signs: 'guint' (aka 'unsigned int') and 'int' [-Wsign-compare]
if (response_id == GTK_RESPONSE_APPLY)
~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~
5 warnings generated.
panel-action-button.c:275:4: warning: Value stored to 'ret' is never read [deadcode.DeadStores]
ret = system ("reboot now");
^ ~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
Just force-pushed again after fixing the missing spaces and both build warnings, One warning was from a leftover, one from a cut and paste from mate-session-manager's logout dialog where an unsigned integer was used. All the GTK builtin responses are negative numbers so that should not even work unless the compiler fixes that in the binary.
Got this line in failed Travis builds:
The command "./docker-build --name ${DISTRO} --config .build.yml --install" failed and exited with 1 during .
Looks like Travis is temporarily unable to install the distros to build against
Found a fast way to find ALL instances of no space between a letter and a ( bracket: pluma search for each of the 26 letters followed by an opening bracket with no space. Fixed the ones that were mine, left the ones in code I did not change
Still getting the failed distro setup for builds from travis:
install:
- sudo apt-get install -y python3-pip python3-setuptools
- sudo pip3 install --upgrade pip
- sudo pip install PyGithub
- ./docker-build --name ${DISTRO} --config .travis.yml --install
The command "./docker-build --name ${DISTRO} --config .build.yml --install" failed and exited with 1 during .
Your build has been stopped.
I now have a working, installable mate-wayland session, for now in my own repo at https://github.com/lukefromdc/mate-wayland-session can import it to mate-desktop if desired or work on it there
This uses systemd to be able to shutdown when root is logged in anywhere, possibly including display managers If user login is only login shutdown and reboot work w/o systemd Suspend requires systemd at this point Logind support would be welcome