omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Screensaver starts and aborts immediately with display scaling set to 1.2 or 1.33

Open chriso0710 opened this issue 11 months ago • 19 comments

System details

Thinkpad X270, Omarchy 3.2.3

What's wrong?

I have an issue with the screensaver. Searched github but was not able to find any other issues regarding this. So I assume this might be a bug.

My monitor settings:

# 1920x1080 @ 1.2x in 13", 60 Hz [Built-in]
env = GDK_SCALE,1
monitor=,preferred,auto,1.2

With these settings the screensaver tries to start, screen goes blank but aborts immediately and returns. When I set the scaling to 1 or 1.5 or 2 the screensaver works fine.

chriso0710 avatar Dec 17 '25 21:12 chriso0710

i got a similar issue, but sporadically, at some point i had my laptop afk but doing something else away from it, and i noticed some "flashing" and the screensaver never started, so i assume it was the screensaver trying to start

felixzsh avatar Dec 18 '25 02:12 felixzsh

With these settings the screensaver tries to start, screen goes blank but aborts immediately and returns. When I set the scaling to 1 or 1.5 or 2 the screensaver works fine.

Huh, interesting.

Can you check something: with your normal monitor setting, change a value in ~/.local/share/omarchy/bin/omarchy-cmd-screensaver (line 17): while read -rsn1 -t 0.1; do :; done # Flush any pending input Change -t 0.1 to -t 0.5 - different behaviour or same?

wolfgangw avatar Dec 18 '25 05:12 wolfgangw

Same issue over here with different scaling settings even.

env = GDK_SCALE,1.75
monitor=,preferred,auto,1.666667

Performing the change from @wolfgangw above is fixing the issue.

mrtreg avatar Dec 18 '25 12:12 mrtreg

@mrtreg thanks for checking. This is the 3rd feedback to confirm that there is a timing problem with the flush on some systems.

I don't get, at all, how changing the scaling factor makes a difference. Not doubting. I'm just clueless as to how that would leak into screensaver terminal activity and, thus, affect the screensaver launch. lol and wow :)

wolfgangw avatar Dec 18 '25 12:12 wolfgangw

fyi, the mouse activity thing will be gone in the next release. See https://github.com/basecamp/omarchy/commit/d2ea6ad18394e6fee4a25c7450bfd48dad5d9f50. Bluetooth devices, apparently, are handled on a different layer and their motion data would not reach a terminal (clicks yes). Unclear if this could be "fixed" at all.

wolfgangw avatar Dec 18 '25 13:12 wolfgangw

The screensaver stopped working on my box since last update or maybe the one before, the -t 0.5 trick fixed it. Thanks! I didn't touch the scaling in a while but it's 2 on one monitor and 1 on the others...

Ventajou avatar Dec 19 '25 08:12 Ventajou

This may be related.

I have a fresh install on a 2013 13" MacBook Pro (iCore5). I had not changed any base system settings. No bluetooth or external devices connected.

  • the flicker I observe: -- the open windows disappear -- a new terminal opens, then closes, I can briefly see an input before its closed. -- the original screen windows would re-appear as if nothing had happened.
  • All of this would take roughly 400ms to 600ms. If I watch it, I can see the above happen. If don't actively watch, then in my peripheral vision, It appears as a screen flicker
  • This would only happen if I left the computer idol, and would continue to happen every 2mins or so. Very rarely would the screen saver actually start.
  • with the activity monitor open, I can see a large spike in CPU and GPU after the event ended.

I have disabled the screensaver and this has resolved the flickering issue.

CodeVachon avatar Dec 19 '25 17:12 CodeVachon

I don't get, at all, how changing the scaling factor makes a difference.

It might or it might not be. Have you considered that mouse reporting is not the only thing that causes the terminal to write escape sequences into the input? Really the only right way to do this is to examine the input and parse the escape sequences, or at least match against them to ignore the ones not related to the mouse.

db48x avatar Dec 20 '25 09:12 db48x

Had not considered, no. I agree, picking exactly what we would want to act on, would do a better job.

Still, wondering how the original reporter has a scaling factor in place (breaks launch) and when they change that factor, it fixes launch. Seems weird, doesn't it?

wolfgangw avatar Dec 20 '25 10:12 wolfgangw

For me the screensaver stopped working when I connected an external monitor through HDMI to my laptop and I observe the behavior that @CodeVachon mentioned. My laptop monitor has 1.6 scaling and the external monitor has 1.0. When I use my laptop screen only there are no problems.

Implementing what @wolfgangw suggested appears to fix the issue, at least while I'm using both monitors. Dunno whether it'll get messed up once I unplug the external monitor though.

Update: There have been no problems since, both with one and two monitors. Since this apparently might be terminal-specific I thought I'd add that I'm using Ghostty.

Head-Scratches avatar Dec 20 '25 13:12 Head-Scratches

Still, wondering how the original reporter has a scaling factor in place (breaks launch) and when they change that factor, it fixes launch. Seems weird, doesn't it?

A little, but it could easily be behavior specific to a single terminal emulator. He didn’t say which he’s using, but I’ll note that I get the same basic behavior in WezTerm regardless of scaling. It immediately reads something or other and then exits.

I tried debugging it but of course tte gets in the way of printing out anything useful. And if you don’t run tte then it exits instantly anyway because tte isn’t running. When I woke up this morning I had the brilliant idea to just write it out to a file for later inspection, so I’ll let you know what I find.

Edit:

I just remembered another thing. I’ve recommended before (well, a couple of weeks ago) to go back to using a single fixed terminal emulator in the screensaver. There’s really no need for the user’s choice of terminal emulator to be used here, since the user isn’t using the thing in the normal sense. At most they’re just looking at the pretty lights; doing anything else causes the light show to end. We could probably fix this by picking a single terminal emulator whose behavior is well known and predictable and just using that.

db48x avatar Dec 20 '25 22:12 db48x

Thanks guys. Just two quick comments regarding this:

  • the quick fix from @wolfgangw works for me too
  • I am using ghostty as a terminal

chriso0710 avatar Dec 22 '25 09:12 chriso0710

Do you get the same bug with other terminals like Alacritty?

db48x avatar Dec 22 '25 17:12 db48x

I ran into this same issue with Ghostty. After some debugging, I found the root cause is a race condition between when the window opens and when it receives focus.

The problem:

  1. Mouse tracking is enabled immediately
  2. Input buffer is flushed
  3. Window opens but focus takes ~500ms to arrive
  4. Mouse events queue up during this window
  5. First read in the main loop detects these queued events and exits

My fix adds a focus wait loop and a second input flush before the main loop in omarchy-cmd-screensaver:

# Add this before the 'while true; do' loop:

# Wait for focus to arrive (fixes race condition on window open)
for _ in {1..20}; do
  screensaver_in_focus && break
  sleep 0.1
done

# Flush input buffer again after focus (mouse events may have queued)
while read -rsn1 -t 0.1; do :; done

This waits up to 2 seconds for focus, then flushes any events that queued while waiting. Works reliably for me now.

ianphil avatar Dec 26 '25 04:12 ianphil

Can confirm that only changing this, allowed my multi-monitor setup to start the screensaver

--- a/.local/share/omarchy/bin/omarchy-cmd-screensaver
+++ b/.local/share/omarchy/bin/omarchy-cmd-screensaver
@@ -14,7 +14,7 @@
# Exit the screensaver on signals and input from keyboard and mouse
trap exit_screensaver SIGINT SIGTERM SIGHUP SIGQUIT
printf '\e[?1000h\e[?1003h' # Enable mouse tracking (clicks: 1000, movement: 1003)
-while read -rsn1 -t 0.1; do :; done # Flush any pending input
+while read -rsn1 -t 0.5; do :; done # Flush any pending input

printf '\033]11;rgb:00/00/00\007'  # Set background color to black

The longer flush timeout (0.5s instead of 0.1s) should give the window enough time to receive focus before the input loop starts checking for events.

cicloid avatar Dec 27 '25 06:12 cicloid

With these settings the screensaver tries to start, screen goes blank but aborts immediately and returns. When I set the scaling to 1 or 1.5 or 2 the screensaver works fine.

Huh, interesting.

Can you check something: with your normal monitor setting, change a value in ~/.local/share/omarchy/bin/omarchy-cmd-screensaver (line 17): while read -rsn1 -t 0.1; do :; done # Flush any pending input Change -t 0.1 to -t 0.5 - different behaviour or same?

Thanks! This fixed the issue for me too.

itsbnanw avatar Jan 02 '26 01:01 itsbnanw

FYI: For me the issue is fixed in omarchy 3.3.0 - give it a try

morgoth avatar Jan 08 '26 15:01 morgoth

To be clear: the feature - terminating screensaver through mouse/trackpad action - is gone in 3.3.0 because it did not work with Bluetooth mice. Showstopper kind of thing and unrelated to this issue here.

wolfgangw avatar Jan 08 '26 15:01 wolfgangw

We've changed to -t 1, so all should be good.

dhh avatar Feb 01 '26 10:02 dhh