Replies: 1 comment
-
So I did the following: #!/bin/bash
pattern="/var/run/xrdp/sockdir/*/xrdp_display*"
#30min timeout to shutdown when idle
timeout=1800000
#wait 15min after startup
sleep 900
while true; do
suspend=true
if ls $pattern >/dev/null 2>&1; then
for file in $pattern; do
number=$(basename "$file" | grep -o '[0-9]\+$')
owner=$(stat -c '%U' "$file")
echo "File: $(basename "$file")"
echo "Owner: $owner"
echo "Display-ID: $number"
export DISPLAY=:$number
idle=`sudo -u $owner xprintidle`
echo "Idle: $idle"
echo "----------------"
if [ $idle -lt $timeout ]; then
suspend=false
break
fi
done
else
echo "No xrdp sessions found."
fi
if [ $suspend == true ]; then
echo suspend
pm-suspend
sleep 120
fi
sleep 60
done
At the moment it only checks xrdp sessions which is relevant for me at the moment. If all idle times are above a given threshold, the machine suspends. Maybe I'll adjust later to include other interactive sessions if there is a need. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a machine that is started on request via wake on lan and used by multiple users via xrdp. I want the machine to suspend to ram after nobody has been active for some amount of time. I think this works correctly as long as only one person has an active xrdp session.
From what I can observe, if there are multiple xrdp sessions, the machine suspends to ram as soon as one of the sessions reaches its inactivity timeout as set in the gnome power management settings.
I could not find any information online about this topic and my hunch is that it's not really an xrdp bug. But it's related to it's use.
Has anybody confronted this problem or does anybody know if there is a way to propagate user activity to get the wanted result (only suspend when all xrdp sessions have been idle)?
Beta Was this translation helpful? Give feedback.
All reactions