How cool is that.

Undistract-me “Terminal Job Notifications”

What if you could get notifications when a task is completed on on your terminal. A small push notification indicating that the command has been executed or a sound would be produced when the terminal has finished a command on Linux. That could end up saving both money and time of yours.texjkdf.jpeg

CHECK Top-Right corner …..Cool right ?

We have all faced one thing while working on something both personally and professionally, that is distractions. Distractions everywhere. A programmer sometimes just needs to be in his/her zone, his/her level of peace to work at a peak level . But a certain YouTube video that you got to check out. Or a Facebook comment that you should reply to takes it away…

Suppose you run a task which gonna take some time on the terminal and now you find this amazing 7 minute Ted talk video ( your brain goes : why not) in the meantime that task has already finished and the terminal is waiting for the next step. The uses of this could be endless.

Installation

So, you sold ? Cool. Now there might be many possibilities to this like NotiFrye, issuing another command after the it’s completion by using ; But here I will give you the simplest way to achieve this without the bells and whistles. Also I will provide links of all other ways to do this on different distros if this doesn’t work out for any reason.

For Linux 16.04, enter in the terminal:

sudo apt-get install undistract-me
For Ubuntu 12.10 or 12.04, use :
sudo add-apt-repository ppa:undistract-me-packagers/daily
sudo apt-get update
sudo apt-get install undistract-me

How to make it work

Add this to ~/.bashrc (refer to the footnote for more information)

if ! [ -z "$BASH_VERSION" -o -z "$PS1" -o -n "$last_command_started_cache" ]; then
  . /usr/share/undistract-me/long-running.bash
  notify_when_long_running_commands_finish_install
fi
 Bashrc is most likely to be located in the Home directory or the Root directory.

Easy enough but one more thing

To get Undistract-me to work, you must enable “Run command as a login shell” so open the terminal you’re using and:
  • for GNOME Terminal: select Edit > Profile Preferences and on the Title and Command tab, check the “Run command as login shell;
  • for Guake Terminal, right click in a terminal, select “Preferences” and on the General tab, check the “Run command as a login shell” box.
If you’re using a different terminal, look through its preferences for the “Run command as a login shell” option and make sure it’s checked.
Once you do this, restart the terminal (make sure you close all open terminal windows) and you’re done.

 Customization

So, you liked how it works. Happy to help. Now in later releases of Undistract-me, they have added the following features and commands.
  • Undistract-me now runs only when the terminal window is not active which is the true purpose of it. Example : It only shows you the notification when the terminal windows is minimized or not active (at top of the screens)
  • Undistract-me doesn’t denote completion notification for small commands like cd or ls which would be quite irritating. Instead **It only shows notification for command longer than 10 seconds only.** To customize this as per your requirement, follow.

 edit the /usr/share/undistract-me/long-running.bash file as root and changing the LONG_RUNNING_COMMAND_TIMEOUT variable value from 10 to whatever you want.

  • It is possible to disable notifications for certain commands by adding them space-separated to LONG_RUNNING_IGNORE_LIST variable.
  • There is a way to play sound on notification in it too. Refer here

One last thing

For sound, I prefer to go the extra mile

sudo sed -i 's/blacklist pcspkr/#blacklist pcspkr/g' /etc/modprobe.d/blacklist.conf
sudo modprobe pcspkr
beep [optional parameters]

job.jpeg

OR

 foo; spd-say done

Replace foo with whatever command you want to use.

and make your day a little more productive. I am gonna go watch my Ted video now.

Other ways and for other environments :-

https://github.com/kaustubhhiware/NotiFyre

Growl for macOS ( untested )

Arch – https://aur.archlinux.org/packages/undistract-me-git/

Tilix – Tilix is an advanced GTK3 tiling terminal emulator that follows the Gnome Human Interface Guidelines.And offers notifications when the screen is not active. Available for most distros.

Sources :

https://github.com/jml/undistract-me

https://launchpad.net/undistract-me

Live in the mix. Subscribe. Share. like. Tell me what else I could write on.

This blog has been written using markdown
Stay tuned to know more #dgplugsummertraing17


Footnote

You put commands here to set up the shell for use in your particular environment, or to customize things to your preferences. A common thing to put in .bashrc are aliases that you want to always be available. We are here putting an alias in the bash file.


Advertisements

4 comments

  1. This is good effort, but the writing itself is confusing.

    Are you arguing for focus or the ability to multitask?
    The post does not make it clear.

    It describes the tool pretty well though.
    I can see it’s value for really long running tasks or when doing shallow work (encoding a video for e.g.)

    But working like this, context switching every 10 mins is not at all conducive to focussed work though.

    Liked by 1 person

    1. I am not arguing anything, Jason. It’s just a tool or utility that I thought was useful and productive for me. As for your question, I do lean over my ability to multitask. And yes the post doesn’t make that clear. I prefer to leave it that way, for the reader to decide how this package helps in their day to day. I like your point though. I didn’t add my views on it, next time, I will for sure.It’s a blog after all. Next would be on Markdown.

      Ps. Can you check if it works for or could be used in Fedora. I didn’t research that.Thanks

      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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s