Undgå Pauseskærm / Dvale via musemarkørbevægelse
Source: Download script
Last Updated: 11. September 2025 by Agnete Moos (agms@sonderborg.dk)
Parameters:
Navn | Type | Standardværdi | Påkrævet |
---|---|---|---|
Click to see the source code
#! /usr/bin/env sh
# ...As a workaround to prevent suspend.
# Restart not necessary, crontab should detect that its config was updated.
#
# Arguments:
# 1: Enable/Disable the program?
# 2: Interval to run at.
#
# Author: mfm@magenta.dk
set -ex
ACTIVATE=$1
INTERVAL=$2 # Example: 10 for every 10 minutes
SCRIPT_PATH="/usr/share/os2borgerpc/bin/move-mouse-continuously.sh"
USER=chrome
# Take the current crontab, remove the line matching SCRIPT_PATH,
# make the result the new crontab
# When using a nonstandard character as delimiter (,) it must be escaped the
# first time:
# https://stackoverflow.com/a/25173311/1172409
delete_entry_crontab() {
(crontab -u $USER -l || true ) | sed "\,$SCRIPT_PATH,d" | crontab -u $USER -
}
mkdir --parents "$(dirname "$SCRIPT_PATH")"
if [ "$ACTIVATE" = "True" ]; then
export DEBIAN_FRONTEND=noninteractive
apt-get install -y xdotool
cat << EOF > $SCRIPT_PATH
#! /usr/bin/env sh
DISPLAY=:0 xdotool mousemove_relative 1 1
sleep 2
DISPLAY=:0 xdotool mousemove_relative -- -1 -1
EOF
chmod +x $SCRIPT_PATH
chown $USER:$USER $SCRIPT_PATH
delete_entry_crontab # In case it's already there, for idempotency
# Append to crontab: Take the current crontab, add the new line, make that
# the new crontab
# "|| true" is there if crontab is empty
# as otherwise set -e, if enabled, will stop execution there
(crontab -u $USER -l || true; echo "*/$INTERVAL * * * * $SCRIPT_PATH") | crontab -u $USER -
else
delete_entry_crontab
fi
Beskrivelse
Hvis man har problemer med at en skærm går i dvale anbefaler vi først at kigge på
- Scriptet “Juster skærmdvale” eller
- At kigge på hvad der er muligt at indstille direkte på skærmen.
MEN hvis den derefter stadig går i dvale, kan dette script afprøves. Scriptet fungerer på den måde, at det bevæger musemarkøren et par pixels efter et interval.
Dette script er blevet testet og virker på Ubuntu 22.04.
Parametre
1: Aktiver: ja/sandt slår det til nej/falsk slår det fra. 2: Interval: Hvor ofte scriptet skal bevæge musen, angivet i minutter. Maks er 59 minutter.