Home

Amir Charif

ruby-xidle
This module defines only one function: xidle(). This function returns the user's idle time, i.e., the number of milliseconds elapsed since the last event triggered by the user (Mouse motion, click, key press... etc) in an X session. The module itself uses functions from xprintidle.

Here's a usage example:
:::ruby

require 'xidle'

def work
    p 'Working...'
    sleep 1
end

# This loop will stop running if you stay idle for 1 minute
while true
    work
    if xidle > 60000
        p 'User has been idle for more than one minute !'
        break
    end
end