Skip to content

[FEATURE]: Block suspension/hibernation while processing #13656

Closed as not planned

Description

@monksy

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

While that application is calling and waiting on inferences. Prevent the system from falling asleep. For me, I may have long running local models that continue to run. However, when they're done, I don't mind the system falling asleep. It's unnecessary to completely disable sleep for long periods of time while opencode isn't actively processing.

This should be a configurable option.

Helpful commands:
systemd-inhibit --what=sleep --why="OpenCode is active" sleep 60

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Feb 14, 2026
  2. mmirus commented on Feb 28, 2026

    @mmirus

    For what it's worth, I had OpenCode make a plugin for me to do this. Haven't tested it much yet, but here it is:

    Edit: the code I posted doesn't clean up the block after OpenCode finishes work or exits
    import type { Plugin } from "@opencode-ai/plugin";
    import { spawn, type ChildProcess } from "child_process";
    
    export const SleepInhibitPlugin: Plugin = async () => {
      let inhibitorProcess: ChildProcess | null = null;
    
      function acquire() {
        if (inhibitorProcess) return;
        inhibitorProcess = spawn(
          "systemd-inhibit",
          [
            "--what=sleep",
            "--who=opencode",
            "--why=AI is actively working",
            "sleep",
            "infinity",
          ],
          { stdio: "ignore" },
        );
        inhibitorProcess.on("exit", () => {
          inhibitorProcess = null;
        });
      }
    
      function release() {
        if (!inhibitorProcess) return;
        inhibitorProcess.kill();
        inhibitorProcess = null;
      }
    
      process.on("exit", release);
      process.on("SIGINT", release);
      process.on("SIGTERM", release);
    
      return {
        event: async ({ event }) => {
          if (
            ["message.updated", "tool.execute.before", "session.updated"].includes(
              event.type,
            )
          ) {
            acquire();
          }
          if (event.type === "session.idle") {
            release();
          }
        },
      };
    };

    You can run systemd-inhibit --list --no-pager while OpenCode is working on something, and you'll see an entry in the list for it.

  3. antonio-ivanovski commented on Apr 18, 2026

    @antonio-ivanovski

    Very surprised that there is no such option, especially when codex have had this since first version

    Image

    Personally use caffeinate -d on macos to prevent sleep.

  4. removed
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on May 3, 2026
  5. github-actions commented on Jul 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  6. SirRufo commented on Oct 2, 2026

    @SirRufo

    Personally use caffeinate -d on macos to prevent sleep.

    I prefer caffeinate -i so the display can save energy but the system is still working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions