This post will detail how to simulate activity on your computer in order to prevent it from auto-locking or going into sleep mode. Note that this will usually also prevent the "auto-away" functionality of various chat programs from ever marking you as "away".
Generally you should change your operating system's settings to disable sleeping and auto-locking if possible instead. These methods are for when you don't have the access or permission to change those settings (ie. locked-down devices).
Windows
This method runs a Powershell script on login that toggles scroll lock on/off every minute.
Since scroll lock mostly doesn't do anything on modern systems and the script will press it twice to
immediately unlock/relock it, this is basically unnoticeable to the user. However, if you have
issues simply swap the two {SCROLLLOCK}
s in the below command to something else. A full list of
special keys can be found here.
- Open Explorer (shortcut:
Win+E
) - Paste
%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup
into the location bar and hit enter to navigate there. - Right click in the folder and click
New > Shortcut
to open the shortcut creation wizard. -
Paste the following as the shortcut's location:
1
powershell.exe -windowstyle hidden -command "$myshell=New-Object -com \"Wscript.Shell\";while(1){$myshell.SendKeys(\"{SCROLLLOCK}{SCROLLLOCK}\");Start-Sleep -Seconds 60}"
-
Give it any name you like and hit
Finish
macOS
This method runs a shell script on login that uses a tool called cliclick
to move the
mouse one pixel left and right every minute. This is such a small and fast movement that it's
usually not noticeable unless you're really looking for it.
- Install
cliclick
from the project website or via brew (brew install cliclick
) - Create a script called
jiggle
with the following contents:
1 2 3 4 5 |
|
- Make the script executable (
chmod +x jiggle
) - Open System Preferences, search for "login items" and hit enter.
- Click the
+
button, select thejiggle
script and hit "Add". You should see it appear in the list of programs as a "Unix executable". Check the "Hide" checkbox beside it and exit.
Xorg-based Linux
Much like the macOS version above, this moves the mouse one pixel left and right every minute. If
you would prefer to instead use a keyboard-based method like the above Windows version, use xdotool
key Scroll_Lock
twice instead of the xdotool mousemove_relative *
commands in the following
script. More special key names for xdotool
can be found here.
- Install
xdotool
(usually available via your package manager) - Create a script called
jiggle
with the following contents:
1 2 3 4 5 6 |
|
- Make the script executable (
chmod +x jiggle
) - Configure your OS to run the script at login. Usually this would be done through the desktop
environment's settings or via something like
systemd
.
Wayland-based Linux
Some preliminary research suggests that this is possible on Wayland using ydotool
as a
replacement for xdotool
. I don't currently run a Wayland-based setup so I can't test it. If you
manage to find a solution for Wayland feel free to send it to me and I'll update the post.