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

Are code comments really useless?

Lately I’ve seen and heard different people preaching code without comments. They say that if you write good, clean code that explains itself, there’s no need for comments. They go on to say that comments are useless once you use the right names for variables, functions, classes. They also say that it makes you write smaller functions, and split classes into smaller classes because their names have to say everything Continue reading

Crappy USB Ethernet adapters and Linux

So.. since I was in the need of connecting to Ethernet cable, and I didn’t have a network card, I’ve bought a USB Ethernet Adapter. On the box it even says USB 2.0.

In Ubuntu it gets detected, everything’s fine. Well… until I insert the network cable that is.  At that point I get no connection. So I search the internet and guess what… It seems that the network adapter has a chip which needs custom Linux drivers. In 2015… custom Linux drivers!

Continue reading