dont_sleep: Prevent Computer from Sleeping by Simulating Mouse Activity

View source: R/dont_sleep.R

dont_sleepR Documentation

Prevent Computer from Sleeping by Simulating Mouse Activity

Description

Keeps the computer awake by moving the mouse cursor and clicking periodically with a human-like behavior. It automatically detects the operating system (Windows or macOS) and runs the appropriate underlying logic.

Usage

dont_sleep(sec_range = c(20, 60), off_time = 18.5, quiet = FALSE)

dont_sleep_time(quiet = FALSE)

Arguments

sec_range

Numeric vector of length 2. Range (in seconds) of random intervals between mouse movements and clicks. Default is c(20, 60).

off_time

Numeric. Decimal hour (24h format) to stop the function automatically, e.g. 18.5 means 18:30 (6:30 PM). Default is 18.5.

quiet

Logical. If TRUE, suppresses progress messages. Default is FALSE.

Details

The cursor initially moves to the upper-left corner (0,0), then performs small random movements and clicks periodically to avoid system sleep. The function exits if the user moves the mouse away from the corner or when the specified off-time is reached.

Requires cliclick installed on macOS (install via Homebrew: brew install cliclick), and the KeyboardSimulator package on Windows.

Value

Invisibly returns NULL when the function exits.

See Also

Other Tools: autoline(), bind_files(), bring_api(), chr2num(), db_download(), db_upload(), export_plot(), export_results(), files_functions(), font_exists(), formatColoured(), formatHTML(), glued(), grepm(), h2o_selectmodel(), haveInternet(), image_metadata(), importxlsx(), ip_data(), json2vector(), list_cats(), listfiles(), mail_send(), markdown2df(), move_files(), msplit(), myip(), quiet(), read.file(), statusbar(), tic(), try_require(), updateLares(), warnifnot(), what_size()

Examples

## Not run: 
# Keep the computer awake until 8:00 PM, with mouse actions every 30 to 60 seconds
dont_sleep(sec_range = c(30, 60), off_time = 20)
# Summary of amount of daily time running function
dont_sleep_time()

## End(Not run)

laresbernardo/lares documentation built on July 4, 2025, 12:23 p.m.