Is it possible track user idle time (mouse/keyboard input) in Linux (without external libraries or programs)









up vote
0
down vote

favorite












So far my research has failed me to find a way how to track user activity natively in Python under Linux (gui based) - closest thing i could find is to use the "w | awk 'if (NR!=1) print $1,$5 '" and 'who -u -H' commands and read the context with Popen stdout, however it doesn't seem to work under CentOS 7 - at least not when i try and run it in a loop - it seems something is resetting the timer if that command actually works - strange thing is if that's what's happening is the screen saver works and locks the screen - so the OS certainly doesn't use that to track user activity. I am running centos7 under VM on windows 10 if that matters.



Any suggestions?



Thanks!










share|improve this question























  • w / who measures CPU time used, that has nothing to do w/ interactive or not. If a process runs as the user (even the screensaver will do ;}) the counter is going up.
    – tink
    Nov 12 at 1:36










  • @tink thx for explaining that to me! I thought about it at one point - idk why i dismissed it lol. Thx again!
    – masky007
    Nov 12 at 2:53














up vote
0
down vote

favorite












So far my research has failed me to find a way how to track user activity natively in Python under Linux (gui based) - closest thing i could find is to use the "w | awk 'if (NR!=1) print $1,$5 '" and 'who -u -H' commands and read the context with Popen stdout, however it doesn't seem to work under CentOS 7 - at least not when i try and run it in a loop - it seems something is resetting the timer if that command actually works - strange thing is if that's what's happening is the screen saver works and locks the screen - so the OS certainly doesn't use that to track user activity. I am running centos7 under VM on windows 10 if that matters.



Any suggestions?



Thanks!










share|improve this question























  • w / who measures CPU time used, that has nothing to do w/ interactive or not. If a process runs as the user (even the screensaver will do ;}) the counter is going up.
    – tink
    Nov 12 at 1:36










  • @tink thx for explaining that to me! I thought about it at one point - idk why i dismissed it lol. Thx again!
    – masky007
    Nov 12 at 2:53












up vote
0
down vote

favorite









up vote
0
down vote

favorite











So far my research has failed me to find a way how to track user activity natively in Python under Linux (gui based) - closest thing i could find is to use the "w | awk 'if (NR!=1) print $1,$5 '" and 'who -u -H' commands and read the context with Popen stdout, however it doesn't seem to work under CentOS 7 - at least not when i try and run it in a loop - it seems something is resetting the timer if that command actually works - strange thing is if that's what's happening is the screen saver works and locks the screen - so the OS certainly doesn't use that to track user activity. I am running centos7 under VM on windows 10 if that matters.



Any suggestions?



Thanks!










share|improve this question















So far my research has failed me to find a way how to track user activity natively in Python under Linux (gui based) - closest thing i could find is to use the "w | awk 'if (NR!=1) print $1,$5 '" and 'who -u -H' commands and read the context with Popen stdout, however it doesn't seem to work under CentOS 7 - at least not when i try and run it in a loop - it seems something is resetting the timer if that command actually works - strange thing is if that's what's happening is the screen saver works and locks the screen - so the OS certainly doesn't use that to track user activity. I am running centos7 under VM on windows 10 if that matters.



Any suggestions?



Thanks!







python linux






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 23:59

























asked Nov 11 at 23:17









masky007

126119




126119











  • w / who measures CPU time used, that has nothing to do w/ interactive or not. If a process runs as the user (even the screensaver will do ;}) the counter is going up.
    – tink
    Nov 12 at 1:36










  • @tink thx for explaining that to me! I thought about it at one point - idk why i dismissed it lol. Thx again!
    – masky007
    Nov 12 at 2:53
















  • w / who measures CPU time used, that has nothing to do w/ interactive or not. If a process runs as the user (even the screensaver will do ;}) the counter is going up.
    – tink
    Nov 12 at 1:36










  • @tink thx for explaining that to me! I thought about it at one point - idk why i dismissed it lol. Thx again!
    – masky007
    Nov 12 at 2:53















w / who measures CPU time used, that has nothing to do w/ interactive or not. If a process runs as the user (even the screensaver will do ;}) the counter is going up.
– tink
Nov 12 at 1:36




w / who measures CPU time used, that has nothing to do w/ interactive or not. If a process runs as the user (even the screensaver will do ;}) the counter is going up.
– tink
Nov 12 at 1:36












@tink thx for explaining that to me! I thought about it at one point - idk why i dismissed it lol. Thx again!
– masky007
Nov 12 at 2:53




@tink thx for explaining that to me! I thought about it at one point - idk why i dismissed it lol. Thx again!
– masky007
Nov 12 at 2:53

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254217%2fis-it-possible-track-user-idle-time-mouse-keyboard-input-in-linux-without-ext%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254217%2fis-it-possible-track-user-idle-time-mouse-keyboard-input-in-linux-without-ext%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3

Museum of Modern and Contemporary Art of Trento and Rovereto