Keep Presence

repository·master·Indexed 43 days ago

https://github.com/carrot69/keep-presence

A utility that prevents a computer from entering idle mode by simulating mouse movement, keyboard presses, or scrolling when user inactivity is detected. It supports X11 environments and provides a CLI with configurable modes including keyboard, mouse, both, and scroll, as well as random interval execution.

Tokens
1.4K
Snippets
9
Records
11
Agent score
6%

What's inside Keep Presence

  1. Use the Keep Presence CLI to simulate activity

    master

    Keep Presence is a CLI tool that prevents your computer from going idle by simulating mouse movement, keyboard presses, or mouse wheel scrolling. It only executes these actions when it detects that the mouse has not moved (i.e., the user is away).

    To use the tool, run the script via Python and provide arguments to customize the behavior.

    python src/keep-presence.py --mode mouse --seconds 60
  2. Manual installation from source

    master

    If you prefer to install from the source code, clone the repository and install the pynput dependency manually.

    git clone https://github.com/carrot69/keep-presence.git
    cd keep-presence
    python3 -m pip install pynput
    python3 src/keep-presence.py
  3. Launch Keep Presence on startup

    master

    To ensure keep-presence runs automatically when you log in, you can add it to your desktop environment's startup applications.

    GNOME / KDE Plasma

    1. Open Startup Applications Preferences (GNOME) or Startup Applications (KDE).
    2. Click Add to create a new entry.
    3. In the Command field, enter the command with your desired options. Example: keep-presence --circular --seconds 180 --pixels 1

    Systemd

    You can also use Systemd to manage keep-presence as a startup service. Refer to official Systemd documentation for setup details.

  4. Reference: `--mode` options

    master

    The --mode (or -m) flag determines which hardware simulation is performed when the user is detected as idle:

    • keyboard: Presses the Shift key.
    • mouse: Moves the mouse by the specified number of pixels.
    • both: Performs both the keyboard (Shift) and mouse movement actions.
    • scroll: Performs a mouse wheel scroll action.
    Available options: keyboard, mouse, both (mouse & keyboard) and scroll
  5. Keep Presence CLI arguments reference

    master

    Use these flags to customize how keep-presence behaves when it detects user inactivity.

    FlagLong FlagDescription
    -h--helpShow this help message and exit
    -s--seconds SECONDSSeconds to wait after user is idle. Default: 300
    -p--pixels PIXELSNumber of pixels to move the mouse. Default: 1
    -c--circularMove mouse in a circle. Default: diagonal move
    -m--mode MODEAction to execute: keyboard, mouse, both, or scroll. Default: mouse
    -r--random START STOPExecute actions based on a random interval between start and stop seconds. Overwrites --seconds

    Note on --mode:

    • keyboard: Presses the shift key.
    • mouse: Moves the mouse.
    • both: Performs both actions.
    • scroll: Performs scrolling action.
    # Example: Move mouse in a circle every 180 seconds by 1 pixel
    keep-presence --circular --seconds 180 --pixels 1
    
    # Example: Use a random interval between 3 and 10 seconds
    keep-presence -r 3 10
  6. Configure Keep Presence CLI arguments

    master

    The following command-line arguments are available to control how Keep Presence simulates activity:

    FlagLong FormDescription
    -s--secondsTime in seconds to wait after user is considered idle. Default is 300.
    -p--pixelsNumber of pixels the mouse should move. Default is 1.
    -c--circularIf set, the mouse moves in a circle. Otherwise, it moves diagonally.
    -m--modeThe action to execute. Options: keyboard, mouse, both (mouse & keyboard), or scroll. Default is mouse.
    -r--randomTakes two integers (e.g., -r 3 10) to execute actions at a random interval between the start and stop seconds. Note: This overwrites the --seconds argument.
    # Example: Move mouse 10 pixels in a circle every 5 to 15 seconds
    python src/keep-presence.py --mode mouse --pixels 10 --circular --random 5 15
    
    # Example: Press the shift key every 120 seconds
    python src/keep-presence.py --mode keyboard --seconds 120
    
    # Example: Scroll the mouse wheel every 300 seconds
    python src/keep-presence.py --mode scroll