Undistract-me Sends An Alert For Time-Consuming Commands in Linux

In Linux, some commands executed in the terminal such as make, wget, dd may take a while, so usually you’d just let them run in the background, and do some other work, drink tea, go for nap… while they are running, and come to check from time to time if the command has completed. Sometimes I even forget I run a particular command, and realize it has completed a few hours ago… It’s possible to add some command at the end of your command line, but it can be cumbersome, and you may forget to do it. The best would be automatic alerts for commands that take a long time, and undistract-me just takes care of that by sending an alert for commands that take more than 10 seconds (by default).

In Ubuntu 12.04 and 12.10, you can install undistract-me as follows:


Undistract-me is part of Ubuntu 13.04 or greater repository, so you can just use apt-get install directly.

For other Linux based operating systems, you should be able to use it by installing the source (bash scripts), and manually running the commands below:


One easy way to test it, is to simply run “sleep 11“, and make sure your terminal window is in the background, or the notification won’t show up. The first time I tried, it failed, and found out on webupd8, that “Run command as a login shell” must be enabled in your terminal. In Ubuntu 12.04, go to “Edit->Profile Preferences”, and enable the option.

undistract-me_configuration
Click on Close, exit your terminal window, and restart it to enable it.

Now you can run “Sleep 11“, go to another program such as you web browser, and you’ll see a notification with the time it took once the command completes.
undistract-me_notification

if the 10 seconds delay is not suitable for you, you can simply edit the script (/usr/share/undistract-me/long-running.bash), and change LONG_RUNNING_COMMAND_TIMEOUT default, or export your preferred value in ~/bashrc.

The script uses “notify-send” to show the message above, and this is fine as long as you are in front of your computer, but if you want to be informed while you are away, you can also use your own command to send an SMS or a tweet to your phone for example. Simply export LONG_RUNNING_COMMAND_CUSTOM and LONG_RUNNING_COMMAND_CUSTOM_TIMEOUT with respectively your chosen command and your chosen “long command” time.

Share this:

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK 5 ITX RK3588 mini-ITX motherboard
Subscribe
Notify of
guest
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
1 Comment
oldest
newest
Sander
Sander
11 years ago

Cool, it works! As I use Ubuntu 13.04, “sudo apt-get install undistract-me” was sufficient

Boardcon Rockchip and Allwinner SoM and SBC products