You are not logged in.

#1 2023-06-20 15:42:46

meezoarch
Member
Registered: 2022-12-01
Posts: 42

Run a specific script when the system is idle for x minutes

I am on i3wm. (new to i3!)
I would like the system to:

-Lock the screen after 5 min of being idle; but has to run the below script:

#!/bin/bash

#This is the lockscreen.sh to check we are OK to lock.

# Check if anything is running full screen
if xwininfo -root -children | grep -q -i "Full screen"; then
    exit 0
fi

# Check if audio is playing
if pactl list | grep -q -i "state: running"; then
    exit 0
fi

# Check if aria2 is running
if ps -aux | grep -q -i "aria2c"; then
    exit 0
fi

# Check if wget is running
if ps -aux | grep -q -i "wget"; then
    exit 0
fi

# Lock the screen
/path/to/lock.sh

I have the below on my i3 config file:

exec --no-startup-id xautolock -time 5 -locker /path/to/lockscreen.sh &

I also want the system to fully suspend if remains idle for another 10 min. So, I have the below in my i3 config:

exec --no-startup-id xautolock -time 15 -locker i3lock && systemctl suspend

None of the above is working. What am I doing wrong?
I can lock the screen without running the script by just calling i3lock instead of the lockscreen.sh script.
I can also independently call the lock.sh which is the defualt i3lock-color example script.

Offline

Board footer

Powered by FluxBB