I’ve coded a simple screen lock and power-saving service for uConsole.
TL;DR
It detects power key events to turn the screen on and off. Initially, I used a polling loop for event detection, but to reduce CPU load, I switched to using epoll.
Whenever the screen turns off for any reason (e.g., screensaver, desktop lock, sleep mode),
the service detects the screen-off state and lowers the CPU’s maximum frequency to the minimum while also turning off the built-in keyboard’s power and wakeup trigger.
(I also tried changing the CPU governor to powersave, but I noticed a slight delay when switching.)
Similarly, I initially used a polling loop to detect screen-off events, but to reduce CPU load, I switched to using inotify.
The service consists of two background processes:
sleep-remap-powerkey /usr/local/bin/sleep_remap_powerkey
Detects power key events and controls the screen power.
sleep-power-control /usr/local/bin/sleep_power_control
Manages power-saving operations based on screen status.
In some cases, User input (mouse, keyboard) is required after pressing the power key in any S2Idle state. - fixed in v0.3
Keyboard turn-off only works with QMK custom firmware. - fixed in v1.0 (not confirmed)
Sometimes, sleep-power-control unable to detect the screen off of the desktop environment - fixed in v1.0
The display mode does not recover when the screen is turned off and on, on specific distribution. - fixed in v1.2 (disable turn off drm feature in /etc/uconsole-sleep/config)
I’m using @Rex’s bookworm lite image with Xfce.
When I installed the image and turned on uConsole, the screen rotated, so I had to rotate it 90 degrees using the display setting.
Similarly, when I use your program and wake up my uConsole, the screen rotated with the display setting pops up.
Is there anything I should check before using your program? Because every time uConsole wakes up, the same thing happens.
Sorry for asking the same thing, but is there any way to fix the screen going 90 when coming back from sleep in the Xfce environment? I really want to use your program, but I can’t because the screen rotating problem. Thanks.
Hi, I will release feature user can customize config (disable or set value/feature) in v1.2.
or, You can try to set fbcon=rotate:? proper value in /boot/firmware/cmdline.txt
My display setting in Xfce environment is the screenshot above.
When my uconsole wakes up, the screen rotates back, and the Rotation setting in the Display setting goes back to ‘none’ state, but fbcon=rotate is still ‘1’.
Do you think fbcon=rotate is related to the screen rotation setting in Xfce?
Thanks again!
When the DRM panel power is forcibly turned off and detected again, compositor the desktop environment will initialize to draw the screen.
If you have the default rotation setting at the initialization stage, it will remain in the original state even if you turn off and on the screen.
You can try taking reference to the following and search for relevant information.