undistract me!

Well, I really really have to tell you about this cool application that I’ve found.

Lately, I’ve done lots of things in parallel (I know, not ideal), and one of the patterns is that I start a command in a terminal window (say, a compile or a deploy to a remote server), and then switch to other thing. Ten minutes late… I remember, and switch back to the terminal. Or ten minutes late, somebody asks ‘hey… is the new build deployed?’ Or thirty minutes… Well… you get the point!

So, I’ve started to look for ways to alert me when a long running command finishes. I’ve seen that on macs they have iTerm2 which has that function, but on Ubuntu there’s no iTerm2.

So, I’ve crafted up a script that does this, and saved it to ~/bin/notify.

#!/bin/bash

notify-send ‘Done!’ ‘Terminal command is done!’
mpg123 -q ~/bin/dingling.mp3

(I’ve found a nice and short ding sound on http://soundjax.com/ding-1.html).

And then, I can simply do:

long-running-command ; notify

That’s cool, as it provides both visual and audio notification. However, I have to remember to always add it after long running commands. Also, I only know that a command is done, but I don’t know which.

So, imagine my surprise and instant happiness when I found a tool called ‘undistract-me’ (https://github.com/jml/undistract-me) , readily available to install in Ubuntu (sudo apt install undistract-me) which does everything automatically!

It even displays the command that ran, and the time it took it to complete!

Undistract-me uses only visual cues though, so I had to fiddle with it a bit to see how I can integrate audio notifications as well.

It turns out it’s really simple. First, create a script that does the audio notification

In my case, I’ve saved this to ~/bin/notify-audio

#!/bin/bash

mpg123 -q ~/bin/dingling.mp3

Then, add these 3 lines to .profile:

# for undistract-me
export LONG_RUNNING_COMMAND_CUSTOM_TIMEOUT=10
export LONG_RUNNING_COMMAND_CUSTOM=notify-audio

That’s it. Next time you run a long command (for instance… sleep 15), and switch the window, you’ll get a visual and audio notification when the command finishes.

undistract-me

Hope you find it useful.

Advertisements

2 thoughts on “undistract me!

    • Well.. please consider that Bash is pretty stable, so they don’t need to update the project that often. If it works, it works. And it works. Still, the last commit is 7 months ago, so I wouldn’t call it abandoned.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s