Log in

No account? Create an account
entries friends calendar profile Elf Sternberg's Pendorwright Projects Previous Previous Next Next
Making peace with your partner, when you share an office - Elf M. Sternberg
Making peace with your partner, when you share an office

I have a bad habit.  I leave the music playing on my desktop all the time.  My wife shares the office, and she’s a professional podcaster, so this habit does not please her in the least.  Fortunately, I have found a technological solution.

This solution is for Linux and Audacity.  You may be able to adapt it to other music programs, but as it exploits a feature of X Windows, using it on non-X distros might be tricky.  The secret is to exploit the X-MIT-SCREEN-SAVER hook in X.  This is the published X atom to notify various listening programs when the mouse and keyboard have been idle for a set amount of time, which, as you might imagine, is pretty useful for the screensaver.  But the value is published locally to any subscribed program being run by the current user, and there’s a command-line tool that allows you to run any arbitrary program after a given period of time, xidle.

Xidle is simple, but it needs help.  If you just put audacious into its command line, it’ll start audacious when you’re not listening to it.  That’s not good.  So you need a script:

PIDS=`/bin/ps cax | /bin/grep audacious | /bin/grep -o '^[ ]*[0-9]*'`
if [ -n "$PIDS" ]; then
    /usr/bin/audacious -u > /dev/null 2>&1

I named this “audi-pip,” so it wouldn’t conflict with the grep string. Make sure to chmod it to 0755 so it’ll run. Then configure xidle:

xidle -program /home/<you>/bin/audi-pip -timeout 300

If you’re really old-school, like me, you could put this line above your window manager in .xinitrc, but don’t forget to put an & at the end. Now, if you’re idle for more than five minutes and you’ve left audacious running, it will be paused. And audacious is pretty smart; it’ll automatically restart when you un-idle.

2 comments or Leave a comment
resonant From: resonant Date: March 5th, 2013 12:23 pm (UTC) (Link)
Or as a hardware alternative, wireless headphones. No bleedover noise to your officemates/spouse (unless the volume is so high your ears are bleeding).
omahas From: omahas Date: March 6th, 2013 05:03 pm (UTC) (Link)
Hmmm....someone's birthday is coming up. ;)
2 comments or Leave a comment