I am trying to use xprintidle
to get the X (Unity) idle time so that I can put my monitor to sleep after a certain time. (I have to use xset dpms force off
because my monitor will not come back on when using normal Ubuntu power/suspend settings. Different problem...) But xprintidle
will reset to 0 ms every 30 seconds whether I am using my machine or not. i.e., whether I am moving the mouse/clicking/scrolling or typing on the keyboard. I suspect that something is causing Unity to think that I'm not idle, but I can't figure out what that might be.
Here is an output showing the problem:
x-pc-linux% while [[ $(xprintidle) -lt 60000 ]]; do
echo "$(date +%T) $(xprintidle)" && sleep 1;
done
13:24:47 12
13:24:48 917
13:24:49 1924
13:24:50 2933
13:24:51 3940
13:24:52 4946
13:24:53 5955
13:24:54 6963
13:24:55 7969
13:24:56 8976
13:24:57 9982
13:24:58 10990
.
. # snip
.
13:25:08 21061
13:25:09 22069
13:25:10 23078
13:25:11 24085
13:25:12 342
13:25:13 1350
13:25:14 2358
13:25:15 3364
13:25:16 4372
13:25:17 5380
13:25:18 6388
13:25:19 7395
13:25:20 8402
13:25:21 9409
13:25:22 10417
.
. # snip
.
13:25:35 23511
13:25:36 24519
13:25:37 25525
13:25:38 26532
13:25:39 27540
13:25:40 28549
13:25:41 29556
13:25:42 551
13:25:43 1559
13:25:44 2566
^C%
Notice how the idle time resets at the 12 second and 42 second mark. (Ok, so I have the ultimate answer, but not to this question!)
I have also tried running w
(What does idle time output from "w" command tell?), but unfortunately it shows "?xdm?" for X idle time.
x-pc-linux% w
13:37:47 up 2 days, 3:28, 4 users, load average: 1.76, 2.04, 2.07
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
*** :0 :0 Sat10 ?xdm? 4days 0.59s /sbin/upstart --user
*** pts/1 :0 Sat10 2:09m 0.39s 0.30s zsh
*** pts/4 :0 Sun14 0.00s 5:34 0.00s w
*** pts/12 192.168.1.144 11:20 20:11 13.41s 13.32s zsh
[Edit] I've also tried getting the idle time directly from the XScreenSaver extension as done here in Andrey Sidorov's answer, but I get the same timer reset every 30 seconds.
The x.org documentation only mentions
The idle field specifies the number of milliseconds since the last input was received from the user on any of the input devices.
xprintidle
is triggered by keyboard- and mouse events (not screen events). Something must simulate either one of those. Any background script or process running that could be doing that? Terrible job, but looking through your processes should include the one. Starting withps -u <username>
– Jacob Vlijm Oct 20 '15 at 05:43xprintidle
works as expected. I had restarted before and the problem was still there. I'll keep track of what processes I start per @JacobVlijm's suggestion in case it comes back... – SO_fix_the_vote_sorting_bug Oct 20 '15 at 22:37XScreenSaverAllocInfo()
every 30 seconds. – SO_fix_the_vote_sorting_bug Oct 26 '15 at 00:51