Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration to Never suspen when plugged in have no effect #9

Open
snaggen opened this issue Nov 6, 2024 · 15 comments
Open

Configuration to Never suspen when plugged in have no effect #9

snaggen opened this issue Nov 6, 2024 · 15 comments

Comments

@snaggen
Copy link

snaggen commented Nov 6, 2024

Using latest Fedora packages from copr (should be nightly built), and I have configured "Automatic suspend when plugged in: Never" in cosmic-settings. The laptop is still suspended. I don't know how long it did idle before it got suspended, since I wasn't in the room. But the journalctl clearly shows that it suspended:

nov 06 09:50:35 locke systemd[1]: Starting systemd-suspend.service - System Suspend...
@snaggen
Copy link
Author

snaggen commented Nov 6, 2024

Looking at the code, I don't understand how we get to the suspend.... I'm trying to set the on battery suspend to never and see if that will prohibit the suspention... but that is also not very likely if I look at the code... but hey, it seems we are in the unlikely territory here...

@snaggen
Copy link
Author

snaggen commented Nov 6, 2024

upower reports on-battery: no, so the battery setting shouldn't have any effect.... but we will see anyway...

@snaggen
Copy link
Author

snaggen commented Nov 6, 2024

@ids1024 Looking at the code i notice that the initial state will have on_battery = false. In the case where I start my laptop on battery, will it get an OnBattery notification or how does that work?

Note: Not relevant to my issue here really, since it would ensure that it uses the on ac settings... just something I noticed and got a bit confused about.

@l-const
Copy link

l-const commented Nov 6, 2024

@snaggen
Copy link
Author

snaggen commented Nov 6, 2024

I don't know since there aren't really any logs for those events from what I can see

@snaggen
Copy link
Author

snaggen commented Nov 6, 2024

I have added some debug to clearly see what is happening, and also commented out the 'systemctl suspend' call. And I still get suspends. I have changed the timing of the screen blanking, and it seems that when ever the screen is fading to black the system also goes to suspend. This is not explicitly done by cosmic-idle. I can see that the code path is that it will correctly get a idle notification and run the

            state.update_screen_off_idle(is_idle);

as expected.

Still , the system goes to suspend.
So, I wonder if there is some DPMS issue causing the FadeBlackSurface to trigger a suspend. Not sure if this would be a bug in the DPMS code, or just some magic Fedora suspend handling...

@ids1024
Copy link
Member

ids1024 commented Nov 6, 2024

Looking at the code i notice that the initial state will have on_battery = false. In the case where I start my laptop on battery, will it get an OnBattery notification or how does that work?

Yes, if the UPower daemon is running when cosmic-idle starts, it will get an initial event and update that based on whether or not UPower says the device is on battery. If UPower isn't running, it will stick with the default and assume it's on AC (or has no battery).

I have added some debug to clearly see what is happening, and also commented out the 'systemctl suspend' call. And I still get suspends. I have changed the timing of the screen blanking, and it seems that when ever the screen is fading to black the system also goes to suspend.

Huh. So it doesn't suspend if you remove the .set_mode(zwlr_output_power_v1::Mode::Off); line?

If so, yeah, that's pretty odd. I guess it could be some firmware/driver weirdness. But I guess then Gnome would have the same issue?

@snaggen
Copy link
Author

snaggen commented Nov 6, 2024

I will try to remove that line and see... but that will be tomorrow

@l-const
Copy link

l-const commented Nov 6, 2024

doesn't on_battery variable change for laptops when plugged in and out of AC? if the var is set only on startup, maybe an enhancement is needed??

@snaggen
Copy link
Author

snaggen commented Nov 6, 2024

It is set on events. I just didn't know that you would get an on battery event when you initially connect to the upowerd. So, the code looked strange to me...

@l-const
Copy link

l-const commented Nov 6, 2024

Still, it is probably wrong the way it is because there are two different timeouts and the state of the machine whether it is on power or not should adhear to the different timeout, for example when you connect your laptop to AC you would want to suspend/blank the screen at a greater timeout than when on battery, but if you laptop was running on battery on startup that won't happen. And to be honest, when the on_battery changes that means that we had an interaction with the system so the notification timer should reset.

@snaggen
Copy link
Author

snaggen commented Nov 6, 2024

Looking at the code i notice that the initial state will have on_battery = false. In the case where I start my laptop on battery, will it get an OnBattery notification or how does that work?

Yes, if the UPower daemon is running when cosmic-idle starts, it will get an initial event and update that based on whether or not UPower says the device is on battery. If UPower isn't running, it will stick with the default and assume it's on AC (or has no battery).

I have added some debug to clearly see what is happening, and also commented out the 'systemctl suspend' call. And I still get suspends. I have changed the timing of the screen blanking, and it seems that when ever the screen is fading to black the system also goes to suspend.

Huh. So it doesn't suspend if you remove the .set_mode(zwlr_output_power_v1::Mode::Off); line?

If so, yeah, that's pretty odd. I guess it could be some firmware/driver weirdness. But I guess then Gnome would have the same issue?

If I remove the line above it doesn't go to suspend. Then it just fades to black, and go to the lock screen. So that line triggers something causing a suspend.
I see the line

nov 06 21:31:15 locke systemd-logind[1145]: Suspending...

in the journalctl logs. It is the first suspend related log after the cosmic idle log line I have added. So it seems that it might be logind that reacts to something... not sure. This is a bit outside my expertise.

@ids1024
Copy link
Member

ids1024 commented Nov 6, 2024

Logind might suspend because another program has instructed it to. Or logind can do some things automatically, configured in /etc/systemd/logind.conf. But I don't think DPMS off should be a condition it handles...

@snaggen
Copy link
Author

snaggen commented Nov 6, 2024

I did check the /etc/systemd/logind.conf, but that is blank so it just uses default and then the idle action should be nothing. Also, it doesn't have its own timer (which would be the case if it was logind acting on its own), it reacts to the cosmic-idle dpms... so it is just weird.

@snaggen
Copy link
Author

snaggen commented Nov 15, 2024

Just switched back to Gnome to test this, and there my laptop doesn't suspend when the screens are turned off.
The screens report "No Signal" and say that it will go to energy saving mode in one minute. Not sure if that is any indication that Gnome isn't fully turning off the screen... this is out of my expertise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants