Created
September 8, 2016 10:39
-
-
Save siers/3b97d3f84347e8600985ce19bf5fb35b to your computer and use it in GitHub Desktop.
Wait while xprintidle increases predictably thereby waiting until activity has been observed in the xorg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
if %x{type xprintidle &> /dev/null; echo $?}.strip == '1' | |
raise 'xprintidle not found' | |
end | |
def idle | |
%x{xprintidle}.to_i | |
end | |
t = Time.now | |
i = idle - 100 | |
wait = (ENV['IDLE_POLL'] || 100).to_i / 1000.0 | |
loop do | |
sleep wait | |
prediction = (Time.now - t) * 1000.0 + i | |
break if prediction > idle | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment