Repository navigation
omamobile-keys: put the brightness back only after the panel is off - #640
Conversation
A Power press on the unlocked desktop set the brightness to 0, locked, asked Hyprland to switch the display off, and put the saved brightness back straight away. Hyprland reports the display off at once, but the panel only goes off when the compositor commits it, 0.3 s later on the Pixel 8 Pro, and bl_power is not writable by the user there, so the panel showed the lock screen at full brightness for a moment before it went black. Wait, at most 2 s, until the panel itself reads as off (bl_power, or the internal connector's dpms) before the brightness goes back; Hyprland's answer is used only on a machine with neither file. Test: the stand-in flips Hyprland's state at once and the panel 0.4 s later, and the brightness must come back after that; a panel that never goes off still ends the wait.
|
@Somnius thank you, this is a well-found bug and a well-measured one: the 20 ms sampler showing the brightness back at 749.139 with the panel still on until 749.458, the second probe that showed Hyprland's own answer comes too early to use, and the before and after traces make the cause and the fix easy to follow. I also like that the wait reads what the panel reports and only falls back to Hyprland where there is nothing else, that an unconnected connector can't end it, and that you ran the new test against the old script to see it fail. I read it against the other phones. On the Pixel 7 Pro and 6 Pro nothing changes: their device packages make One thing to fix before I merge: The 2 s limit depends on the locale. bash writes When the panel goes off the loop still ends at once, so the normal press is fine; it's the "never reads off" limit that becomes random, with an error in the journal. The script already has Two questions, neither blocks:
Could you also add the kernel ( |
The 2 s limit read bash's microsecond clock variable, which is written with the locale's decimal separator; under a comma locale the arithmetic turned into the comma operator and the limit became random, with an error in the journal. Use now (milliseconds from date) like the rest of the script, and shorten the limit to 1 s: the panel took 0.35 s on the Pixel 8 Pro. The test also checks that the script no longer reads that variable.
|
@Somnius thank you, that settles it. The limit now comes from I'm setting the package version on your branch (omamobile-shell 0.2.119) and merging. I'll press the power key a few times on my Pixel 7 Pro once it is installed and note the result here. Two things stay open, neither for this PR:
|
…ey-as-android One panel_dark, main's, with the backlight device, defined with wait_screen_off above the switch so both modes share them; the Android short_press waits with wait_screen_off instead of its own loop on the real /sys, so main's flash check passes with the switch on too. The quick wake check falls back to screen_off, as the Android press's did. test/all keeps main's new lines and runs keys.sh with the switch off and on. I used AI help (Claude) to work on this.
|
@derekross, the two things you left open here. The traces were taken with I haven't tried a udev rule for |
…after the panel is off (derekross#640) A Power press on the unlocked desktop set the backlight to 0, locked, asked Hyprland for DPMS off and restored the saved brightness at once. Hyprland reports the display off before the panel is (0.3 s later on the Pixel 8 Pro, where the user can't write `bl_power`), so the lock screen flashed at full brightness. omamobile-keys now waits, at most 1 s by `date`'s clock, until the backlight's `bl_power` or a connected internal connector's `dpms` reads off, and uses Hyprland's answer only where neither file exists. Measured on a Pixel 8 Pro; on the Pixel 7 Pro and 6 Pro the first read is already off.
@derekross, small one, found while I was testing suspend on the 8 Pro: when you press Power on the unlocked desktop the screen flashes the lock screen at full brightness for a moment and then goes black. It's in omamobile-keys.
What happens in short_press: it sets the backlight to 0, locks, asks Hyprland to switch the display off with
omarchy-brightness-display off, and then puts the saved brightness back straight away so the next wake isn't dark. The catch is that Hyprland says the display is off right away (dpmsStatus is false about 0.09 s after the call), but the panel only goes off when the compositor commits it, a bit later. On the 8 Pro bl_power is root-only, so the script's ownpanel_power 4does nothing for the user and the panel follows only when the kernel commits the DPMS. So the brightness comes back while the panel is still on and showing the lock screen.I logged it on the phone with a loop sampling bl_power, brightness and the DSI connector's dpms every 20 ms. Before the change, one press (seconds, epoch):
748.018 brightness 0
749.139 brightness back to 2083, bl_power 0, dpms On
749.458 bl_power 4
749.678 dpms Off
So about 0.3 to 0.5 s with the panel lit at full brightness. The first thing I tried was waiting for Hyprland's own answer (screen_off), and that still flashed, because Hyprland answers early. I confirmed that with a second probe: dpmsStatus false at +0.085 s, bl_power 4 and dpms Off at +0.35 s.
The change: after
omarchy-brightness-display offthe key handler waits, at most 2 s by the clock, until the panel itself reads as off before it restores the brightness. "Off" means the backlight's bl_power is not 0, or a connected internal connector (DSI, eDP or LVDS) says dpms Off. Only on a machine with neither file does it use Hyprland's answer, so the old behaviour stays there. If nothing ever says off, it still restores the brightness and asks for sleep after 2 s, same as before.With the change, same logger, one press from the unlocked desktop:
141.105 brightness 0
142.457 bl_power 4
142.488 brightness back to 2083 (31 ms after the panel went off)
142.678 dpms Off
I watched it too and there's no flash anymore, and the next wake felt a bit quicker too, but I didn't measure that.
Tests: test/keys.sh passes (8 of 8, about 40 s). The new block uses a fake sysfs (OMAMOBILE_KEYS_SYSFS) and a stand-in where Hyprland's state flips at once and the panel 0.4 s later, and checks the brightness only goes back after the panel is off, that sleep is asked for after that, that a panel that never goes off still ends the wait in about 2 s, that with no panel files Hyprland's word ends it at once, and that an unconnected connector saying Off doesn't end the wait. I also ran the same test against the old omamobile-keys and it fails on the "goes back only after the panel is off" check, so it does catch the flash.
Not done: I only tried this on my Pixel 8 Pro. I haven't checked how the DRM dpms file behaves on tegu or other devices (the comment on screen_off says tegu keeps bl_power at 0 under DPMS-off), so there the wait could end at the 2 s limit and the flash behaviour is unknown. Also left alone: omamobile-sleepd notices a wake by polling suspend_stats (5 s with the sleep toggle off, 2 s on), which is where some of the slow wake I saw comes from. That's a separate thing and I'd do it as its own PR.