Getting user uptime in bash script

I'm trying to write a bash script and need to learn how many seconds past since user logged in(xsession). I'm searching for hours and i couldn't find a solution for that. I found only uptime command but i think it's only get computers running time.

To be more clear... I'm writing gui with gtkdialog and i have "hide gui on startup" option. I can start program when user login and if user check that option i can hide gui. But if user wants to configure options and open the gui again??? My only solution for that. I can write the condition if user logged in 30 sec ago or if not checked "hide gui on startup" option than show gui. So if user click program in xsession can see gui again.

Upvotes: 1

Views: 1224

Answers (1)

You can get information about users currently logged in with te w and the who commands. If you would like to see a log about recent sessions (with login and logout time, etc) use the last command.

Upvotes: 1

Related Questions