Shutdown Script Issue

Because my GPD Pocket 3 loses sound upon resume-from-hibernation, I run a timed shutdown script:

idletime=$((30*120*1000)) # 30 min in milliseconds

while [ $idle -lt $idletime ];do
    sleep 1
sleep 2
sudo shutdown -P now

Word_Shutdown Script:

if test "$(wmctrl -l | grep -c "Microsoft Word" 2>&1)" -eq 1; then
    wmctrl -a "Microsoft Word"
    sleep .2
    xdotool keydown 0xffea + key 4
    sleep .2
    xdotool keyup 0xffea
    sleep .2
   xdotool key y

Everything works fine except for logout. At the logout screen, the machine promptly shuts down unassisted. If I kill the above shutdown script before I logout, logout works appropriately.

For now, I run a keystroked logout script, which kills the shutdown script, then runs the logout command.

Any idea why my shutdown script is shutting down the device upon logout?


You have that running 2 seconds right after the logout script …

Thank you for your reply. The logout script (not listed above) simply kills the shutdown script, then logs out. But if I don’t run the logout script–meaning that the shutdown is still running as a process–logging out somehow invokes sudo shutdown -P now and I can’t figure out why.

I suppose I could abandon the whole thing and return to shallow idle (the Pocket 3 can’t resume with anything deeper) and wait to see if a kernel release will fix s2idle, etc for the Pocket 3. Right now, I’m at 5.18.