https://bugs.kde.org/show_bug.cgi?id=464119

--- Comment #4 from Victor J. Orlikowski <vjorlikow...@gmail.com> ---
Right - I was trying to make the point that the python code wasn't doing
*quite* what I expected, either.

Basis for this issue...

I often have to ssh into remote systems while on battery power, but might have
to be talking to a colleague (I work in higher ed).
I have, in my ~/.ssh/config:

LocalCommand ~/scripts/ssh_prevent_linux_idle_sleep.sh

Which looks like this:

#!/bin/sh
# Prevent a Linux box from sleeping while an SSH session is live.
#
# This is intended to be run using the LocalCommand function of ssh.
#
# It is recommended that this command only be used for hosts
# from which you do not desire to be disconnected, in the interest
# of power savings.

SSH_PID=$PPID
SSH_STARTTIME="$(ps -p $PPID -o lstart | grep -v '^.*STARTED')"

# Start a background child process that:
# 1) Starts "sleep infinity" in the background under systemd-inhibit
# 2) Monitors for the exit of the ssh parent process
# 3) Kills the "sleep" it started upon ssh parent exit
#
# We avoid a race condition that might prevent the systemd-inhibit process
# from being killed by starting it within the child.
(
systemd-inhibit --who="ssh" --what="sleep" --why="connected to remote host"
sleep infinity &
INHIBITOR_PID=$!
while true
do
    checkstarttime="$(ps -p $SSH_PID -o lstart | grep -v '^.*STARTED')"
    rc=$?
    if [ ! \( $rc -eq 0 -a "$checkstarttime" = "$SSH_STARTTIME" \) ]; then
        kill $INHIBITOR_PID
        exit 0
    fi
    sleep 15
done
) &

In that case - and in the version of KDE present in KUbuntu 20.04 - what I want
is for the system to *not* suspend, but be able to auto-lock (and, preferably,
dim +/- turn off the screen, after the appropriate duration).

In the version of KDE in KUbuntu 22.04, the above script keeps the machine from
suspending - and from auto-locking, and from dimming or powering off the
screen, if I'm ssh'd into a host to which that LocalCommand applies.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to