Skip to content

feat: add daemon mode for faster startup …#358

Open
rualss wants to merge 4 commits intoSatty-org:mainfrom
rualss:feat/daemon-mode
Open

feat: add daemon mode for faster startup …#358
rualss wants to merge 4 commits intoSatty-org:mainfrom
rualss:feat/daemon-mode

Conversation

@rualss
Copy link
Copy Markdown

@rualss rualss commented Dec 20, 2025

feat: add daemon mode for faster startup

  Add daemon mode that keeps GTK4 initialized between screenshot
  annotation calls, reducing window creation time from ~250ms to ~25ms.

  Features:
  - `--daemon` flag to start background daemon
  - `--show` flag to send images to running daemon
  - Per-window configuration to avoid race conditions
  - Signal handling (SIGTERM/SIGINT) for graceful shutdown
  - Unix socket IPC with length-prefixed JSON protocol
  - Security: socket permissions 0600, path validation

  Usage:
    satty --daemon &
    satty --show -f /tmp/screenshot.png --fullscreen

      Add daemon mode that keeps GTK4 initialized between screenshot
      annotation calls, reducing window creation time from ~250ms to ~25ms.

      Features:
      - `--daemon` flag to start background daemon
      - `--show` flag to send images to running daemon
      - Per-window configuration to avoid race conditions
      - Signal handling (SIGTERM/SIGINT) for graceful shutdown
      - Unix socket IPC with length-prefixed JSON protocol
      - Security: socket permissions 0600, path validation

      Usage:
        satty --daemon &
        satty --show -f /tmp/screenshot.png --fullscreen
@RobertMueller2
Copy link
Copy Markdown
Member

Thank you for picking this up. We'll review the PR when we get a chance, might be in the new year though.

@rualss
Copy link
Copy Markdown
Author

rualss commented Dec 20, 2025

No problem at all. I did it because i was irritated with latency on my pc, now satty shows up instantly after taking screenshots of small areas, and i have a latency around 0.3s when i screenshot my both monitors, and i have a 4k monitor with 1.5 scaling and full hd monitor.

@RobertMueller2
Copy link
Copy Markdown
Member

Thank you for your patience. This is a comprehensive PR so it'll definitely take us a bit longer to review this. Sorry :)

If anyone else (who isn't a maintainer) feels like helping out with a review and test, by all means, please go ahead :)

Just a small thing I thought about at this stage: should we perhaps try something like SATTY_SOCK first before defaulting to the one in this PR? That way, users could decide how to deal with the daemon in e.g. a nested wayland session.

@RobertMueller2
Copy link
Copy Markdown
Member

I've looked through most of it and I'm ok with what I've seen so far. I still need to figure out and test daemon wide vs instance specific configs, that might require a bit more time.

I'm sticking with my remark regarding SATTY_SOCK above. The only thing I'd like to add right now is to use newer version of nix before we merge, but that seems entirely unproblematic.

And finally, just as a heads-up, #376 may clash regarding config use, but maybe I haven't fully understood this yet 😉

@rualss
Copy link
Copy Markdown
Author

rualss commented Jan 3, 2026

Yea, i think it's better to have some way to control the way daemon works with sockets. Also i think it's a good idea to add some random hash to the name of the default socket file to avoid collisions.

@RobertMueller2
Copy link
Copy Markdown
Member

Sorry for the delay in response. I'm going to add a few inline remarks. Can't promise these are going to be the last, it's tricky to find enough time to review this properly.

Overall, I have these remarks:

  • some of the tests looked to me like they were overlapping. I admit I've just had a quick glance so might be mistaken, I'll have a closer look when I get a chance. Either way, I'd prefer if they were either in tests subdirectory or in the files themselves, but not both places unless there is a reason for it?
  • I've not tried to find out why, but when I start satty without daemon mode, the toolbars are dark ish with my current theme and css. When I start it via --show with a daemon present, the toolbars are light.
  • we now have many places carrying a config. This is going to require new additions to consider more places. I suppose the whole thing could do with some deduplication now. That does not necessarily have to take place in this PR, but we'll have to open a followup issue for that.

Lastly, I have a question. GTK itself has a mode where new instances of an app communicate to an existing instance via DBus, this could in principle also be suitable for a daemon mode. There may be additional challenges with this, and perhaps the dependency on working DBus itself for the daemon mode is something we wouldn't want at all. But out of curiosity, have you considered it, and if so, why have you decided against it?

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

Successfully merging this pull request may close these issues.

2 participants