Skip to content
/ NoSleepR Public

❗ This is a read-only mirror of the CRAN R package repository. NoSleepR — Prevent System Sleep During Long R Tasks. Homepage: https://github.com/hetalang/NoSleepR Report bugs for this package: https://github.com/hetalang/NoSleepR/issues

License

Notifications You must be signed in to change notification settings

cran/NoSleepR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NoSleepR

Continuous Integration GitHub issues License CodeQL

Prevent your computer from entering sleep mode while long-running R tasks are running — and automatically restore normal system behavior when they finish or fail.

  • Cross-platform backend
    • Windows: PowerRequest
    • macOS: caffeinate
    • Linux: systemd-inhibit
  • Simple API: block-style or manual on/off.
  • Safe by design: resets on exit or error.
  • Optional keep_display mode to prevent screen from turning off.

Installation

Install the development version directly from GitHub:

# install.packages("devtools")
devtools::install_github("hetalang/NoSleepR")
library(NoSleepR)

Usage

Basic usage

nosleep_on()
# long-running R code here
nosleep_off()

Block-style usage

You can wrap a code block using with_nosleep() to ensure sleep-prevention is enabled only for the duration of the block:

with_nosleep({
  # long-running R code here
})

Options

keep_display

Prevents the display from turning off (default is FALSE):

nosleep_on(keep_display = TRUE)

Or in block mode:

with_nosleep(keep_display = TRUE, {
  # long-running code
})

Known limitations and recommendations

Some sleep behaviors are enforced by the operating system and cannot be overridden by NoSleepR or any similar tools.

  1. Closing the laptop lid or pressing the power button will force the system into sleep regardless of active sleep-prevent requests of NoSleepR.

  2. On Windows devices with Modern Standby (S0ix) running on battery power (DC mode) the OS may ignore sleep prevention signals after a 5 minutes of inactivity if the screen is turned off.

    • Connect charger (AC mode) to avoid this.
    • OR use keep_display=TRUE to keep the screen awake.

Remote sessions (SSH, Posit/RStudio Server)

NoSleepR only affects the machine where R actually runs. If your code runs on a remote server, the package has no effect on your local computer — and it won't prevent disconnects in remote IDEs.

Most "remote sleep" problems are actually connection timeouts, not the server going to sleep. This is normal: NoSleepR is designed for local laptops/desktops, not for managing network sessions.

For reliable long runs on a remote server, use tools like tmux, screen, or built-in session-recovery mechanisms of your IDE. There's usually no need to keep your local machine awake.

Related packages

  • lareshttps://github.com/laresbernardo/lares
    Provides a dont_sleep() helper with similar purpose, but relies on simulating mouse activity and depends on external tools.
    It does not use system-level sleep-inhibit mechanisms

  • NoSleep.jlhttps://github.com/hetalang/NoSleep.jl
    Julia implementation of the same concept, using native OS sleep-inhibition backends (Windows/macOS/Linux).
    For Julia developers

Author

License

MIT (see LICENSE.md).

About

❗ This is a read-only mirror of the CRAN R package repository. NoSleepR — Prevent System Sleep During Long R Tasks. Homepage: https://github.com/hetalang/NoSleepR Report bugs for this package: https://github.com/hetalang/NoSleepR/issues

Resources

License

Stars

Watchers

Forks

Packages

No packages published