Script Fix: automatically set Steam status to Away while inactive
kon14 Oct 13, 2015
So I'm not even sure whether this was due to steam lacking the feature on linux or op's system being somehow misconfigured, yet I noticed a post in /r/linux_gaming explaining how steam's status wouldn't automatically be set to Away after the user left his computer for a while, resulting in the op's friends holding a grudge on him for not replying.

Now, I've never truly had a mind to test whether that was the case on any of my systems and I probably wouldn't care to fix it either if that was the case, but after noticing the thread on reddit (yeah, don't judge by by the way, it's only 2 linux subreddits :P) I got anxious and decided to write a fix for it, so [here](http://hastebin.com/ohidagulap.vhdl)'s my script for anyone that might possibly need it.

How it works: It's basically a while loop checking whether the inactivity time of the user in the current Xsession exceeds a set amount of milliseconds (which can be easily modified to suit the user's needs in the beginning of the file among other settings). If that's the case it will set the steam user's status to Away using steam's protocol. When the Xsession wakes up it will set the status back to Online.

There's a sleep delay (in seconds) in the end of the loop included in order to minimize system usage due to countless useless repetitions of the loop. You could modify it to whatever you like, just make sure it's lower than the inactivity setting value and not too big either (if the while loop isn't repeating fast enough it will also increase the delay between your getting back to the desktop and your steam status being set back to Online), default value is 15 (secs). Additionally, the script will check whether there's an instance of steam running before it tries to do anything so steam won't automagically launch on its own (cause it likes to launch itself whether the action recuested justifies it or not...).

There's a status flag variable meant to deter the script from repetitively setting the same setting while there's no alteration in the user's activity in the x session.

In order for the script to work you should have a version of xprintidle installed. One that's not bundled with a while loop and outputting to stdout that is... had some bad lack with downstream in gentoo (wirelay overlay). xprintidle's upstream is dead so those things happen... Well, if executing xprintidle returns a single int value you should be good to go.

The script is a config/executable hybrid since there's not enough variations of the desired outcome to justify a separate config file or shell parameter arguments, meaning that there are 2 (actually 3) things you might have a mind to change in the script without modifying it and they're both defined as variables in the top of the file. Just place it somewhere, chmod +x it and launch it on startup through a startup script file or however you wish.

I'd appreciate any feedback regarding it :)

edit: While the script is only meant to switch steam's status to the appropriate mode, by default, it could easily be modified to include other cron-like jobs based on a single Xsession inactivity status.
This is precisely why I'm utilizing a flag, executing an if/else block bundled with everything on each repetion would be both resource consuming and problematic for a lot of cases.
StianTheDark Oct 13, 2015
That "friend" sounds like an asshole. Just saying.

Cool! I didn't know this was a thing, but at least we've fixed the thing that I didn't know was a thing! :)
kon14 Oct 13, 2015
Quoting: StianTheDarkThat "friend" sounds like an asshole. Just saying.

Couldn't agree more, though it's usually both easier and less frustrating to fix the cause of your issue than argue regarding the issues of others, including whatever mental disorders they might "feature".
wolfyrion Oct 29, 2015
I think is something wrong with the script :o

The away mode is working fine but it doesnt bring me back to online mode when I start typing on my computer...

EDIT:

ok got it, the script kicks me out when it put me on away status

some requests :

1. can you make it infinite loop ?
2. if I am idle for X Minutes put me away but if I am idle 2*X minutes put me offline
3. if I use the keyboard again or mouse put me online.
or
4. Popup a window to ask me if I want to put steam Online.
5. Systray Icon with right click options to setup Mins etc a

I know I am asking a lot but since I fall asleep last night and got like a flood of msgs from my friends I understand the importance of this script :P

Thanks!



Xpander Oct 29, 2015
it crashes steam for me :D
kon14 Oct 31, 2015
I must have missed the email notification checkbox this time, soz for letting you guys wait.

Quoting: wolfyrionI think is something wrong with the script :o

The away mode is working fine but it doesnt bring me back to online mode when I start typing on my computer...

EDIT:

ok got it, the script kicks me out when it put me on away status

You confused me, how does it kick you out? Does steam log you out of it or does it crash?

The script should set your status back to online as soon as the else block underneath xprintidle > MAXIDLE is executed, however as already documented in the script a big LOOP_DELAY value won't just omit unnecessary repetitions when it comes to setting your user status to Away but it will also increase the time before the script is aware of your coming back.

Technically speaking, in order for the execution of anything inside the else block where your user is set to Online the while loop must be repeated and before this can happen the delay must be over. What is your current LOOP_DELAY setting inside the script? Is it the default one (15)? Are you sure it's not setting you to online after 15 secs? You could lower the delay if you need the script to realize you're back earlier. We can try debugging it further if none of these helped.

Quoting: wolfyrionsome requests :

1. can you make it infinite loop ?
2. if I am idle for X Minutes put me away but if I am idle 2*X minutes put me offline
3. if I use the keyboard again or mouse put me online.
or
4. Popup a window to ask me if I want to put steam Online.
5. Systray Icon with right click options to setup Mins etc a

1. it is an infinite loop
2. will work on this
3. already the case, see above
4. might implement this at some point but can't promise anything at this point
5. same with 4, if there's need for extending the script I'll start working on it further and upload it to github
kon14 Oct 31, 2015
Quoting: Xpanderit crashes steam for me :D

hmm maybe whatever you have as "steam" in your path is a modified downstream/custom launcher script?
As long as it calls steam and passes its own arguments (append $@) to it you should be fine.
Try launching steam and then run this: steam steam://friends/status/away

Does executing the above manually still crash steam for you? does it set you to Away?

I'll ping you on freenode.
wolfyrion Nov 1, 2015
ok I have fixed your script, it seams the exec was kicking me out from the script
for example

exec steam steam://friends/status/online >/dev/null

Replaced with

steam steam://friends/status/online >/dev/null
Xpander Nov 1, 2015
yeah same. now it works, thanks wolfyrion :)
exec was kicking me out of script and also crashing steam :)
While you're here, please consider supporting GamingOnLinux on:

Reward Tiers: Patreon. Plain Donations: PayPal.

This ensures all of our main content remains totally free for everyone! Patreon supporters can also remove all adverts and sponsors! Supporting us helps bring good, fresh content. Without your continued support, we simply could not continue!

You can find even more ways to support us on this dedicated page any time. If you already are, thank you!
Login / Register


Or login with...
Sign in with Steam Sign in with Google
Social logins require cookies to stay logged in.