Backstory
I finally made the switch to Sxmo a month ago and immediately fell in love with it. But what has been bothering me is that auto suspend had stopped working soon after, which can’t entirely be compensated with manual suspend since it will automatically wake up sooner or later and then not automatically suspend again. This wasted a lot of battery power and forced me to charge a lot more often. But now that my PPKB endeavours had reached a dead end due to the userspace inputd being broken with newer kernel versions, I decided to take the time to customise and explore Sxmo. And after a lot of digging around in the code, I believe I’ve found the culprit and fix for my broken automatic suspend.
The Issue
Disclaimer: I have no idea what I’m doing, so this might be wrong. It also looks like the on-locked-screenoff-suspend mechanic has been reworked entirely in the repo, so I assume this issue won’t be present anymore in sxmo-utils 1.9+. Edit: It’s indeed fixed.
Automatic suspend works perfectly fine when both it and auto-screen-off are enabled. Only when auto-screen-off is disabled, it causes not only the screen to not automatically shut off, but also automatic suspend to not work. In my case, journalctl was spamming Jun 03 19:09:04 tatl tinydm-run-session[314889]: 19:09:04 is_idle: auto_screenoff_off when the screen was off. But is_idle is the condition that has to be fulfilled for auto-screen-off, which I have disabled, as the _off in the log indicates. So why does suspend complain about auto_screen_off being off? The reason is as follows: There is one hook / list of conditions that checks if the screen may shut off, is_idle, and one that checks if the device may suspend, can_suspend. The screenoff hook that is activated when the screen is off executes sxmo_screenlock_deeper.sh. That script querys for the current state (on, locked, screen off, suspended) and, as the name implies, will attempt to make the device go into the next deeper state. If the next state is suspend, it checks if suspend is allowed according to can_suspend. If the next state is screen off, it performs no check by default. The is_idle check is only performed when the script is called with the argument --idle. Now, back to the screenoff hook. When it calls sxmo_screenlock_deeper.sh, it uses the --idle flag. That means that the script checks the conditions for both suspend and screen off. Auto-screen-off having been deactivated in the menu is a condition that prevents screen off (the is_idle: auto_screenoff_off log message). And since it is queried, it will now also prevent automatic suspension as called by screenoff, the hook that is called when the screen is already off and that is responsible for initiating automatic suspension. To my understanding, performing the check for screen off is not necessary. If any of those conditions should also apply to suspend, then they should be included in the suspend conditions as to not break suspend with the auto-screen-off menu setting (which is very important to me, when the screen is on I’m using the device, I don’t want the screen to shut off).
The Solution
First, copy the original hook to your home folder. If that folder doesn’t exist, create it first with mkdir -p ~/.config/sxmo/hooks/.
Now edit the file with a text editor of your choice, e.g. nano ~/.config/sxmo/hooks/screenoff and remove both --idle flags in lines 19 and 25. Automatic suspend should now work again!
Side Effects
Disclaimer: The following is just a theory and untested.
The conditions that prevent the screen from shutting off include ongoing_call, so the device might suspend while a call is active when the screen is shut off with the above fix that removes the checks intended for shutting the screen off from automatic suspension. The suspend checks include modem_use though, that might also be active during a call, I have no idea. If this is an actual issue and it happens to you and bothers you, simply add that condition, or any other of the auto screen off conditions, to the auto suspend conditions.
Copy the original hook that gets activated when the screen is off to your home folder:
Then edit it with a text editor of your choice, e.g. nano ~/.config/sxmo/hooks/can_suspend and add any condition to the existing ones at the bottom of the file. These are the conditions from is_idle:
proximity_lock_on
waiting_rtcwake
camera_open
auto_screenoff # don't add this or the original issue is back again