Skip to content
Notify when a terminal task is done/ Terminal task notifier https://kaustubhhiware.github.io/NotiFyre/
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
CNAME Create CNAME Nov 1, 2018
CONTRIBUTING.md
LICENSE.md
README.md Added sanity checks in README, clarification of language in places Nov 25, 2017
Slick.ogg Add fish compatibility Feb 10, 2017
_config.yml Set theme jekyll-theme-cayman Apr 20, 2017
bash-preexec.sh Add installation instructions, alternate image and describe functions… Jul 14, 2017
nf.fish Add installation instructions, alternate image and describe functions… Jul 14, 2017
notifyre.fish
notifyre.sh
prompt_pwd.fish
refer.md
terminal.png
thumbnail.png
thumbnail_fish.png Make repo PR-friendly Nov 23, 2017

README.md

NotiFyre

MIT Licence Bash Shell PRs Welcome

It's lit 🔥

Notify when a terminal task is done

Image could not be displayed

Sample working video, sped up at x2.

Install dependencies first :

  • For Mac OS - brew install terminal-notifier
  • For Ubuntu - sudo apt-get install notify-osd pulseaudio-utils libnotify-bin

Note: The above dependencies are generally installed on most systems.

Notifyre has been tested on a fresh install of Ubuntu 16.04 running bash, zsh or fish. If you have managed to port this script to another shell or another OS, please open a pull request with the instructions for the same and we will update the README! Got some coverage here.

Table of Contents

Bash / ZSH

(Back to top)

Setup

  • Place notifyre.sh & bash-preexec.sh in your home folder

    git clone https://github.com/kaustubhhiware/NotiFyre.git
    cd NotiFyre
    cp notifyre.sh bash-preexec.sh ~
  • ⚡️ Lightning fast alternative: Pull only these two files from GitHub!

    curl https://raw.githubusercontent.com/kaustubhhiware/NotiFyre/master/notifyre.sh -o ~/notifyre.sh
    curl https://raw.githubusercontent.com/rcaloras/bash-preexec/master/bash-preexec.sh -o ~/bash-preexec.sh
    
  • Add the following lines to the end of ~/.bashrc or ~/.zshrc:

    # as close to the end as possible
    source ~/notifyre.sh
    source ~/bash-preexec.sh

    Note: These 2 lines should be added as close to the end of the file as possible.

  • If you do not want to be notified for each command, then add only this to the end of your rc file:

    source ~/notifyre.sh

    To get a notification for a command in this case, you need to run it as nf <command>

Configuration

(Back to top)

SOUND=1
SOUND_MIN=10
ALERT=/usr/share/sounds/ubuntu/notifications/Slick.ogg
MIN_INTERVAL=4

There are four configurable options in NotiFyre:

  1. SOUND

    Options: 0 or 1

    Utility: SOUND=1 will play an alert sound for each notification that takes more time than SOUND_MIN seconds. This value is a boolean.

  2. SOUND_MIN

    Valid values: 1, 2, 3 ...

    Utility: Let's you configure the minimum amount of time a command must take for it to trigger a sound notification. (If SOUND=0, then no sound notification will be played) This value is in seconds.

  3. ALERT

    Options: Path to a sound file

    Utility: The sound file will be played whenever SOUND=1 and a command has taken more time than SOUND_MIN seconds. If the sound file does not exist, it plays an audible-bell sound (varies by terminal) as a fallback.

  4. MIN_INTERVAL

    Options: 1, 2, 3, ...

    Utility: An option to configure the minimum amount of time that a command must take in order to trigger a notification. This value is in seconds.

Fish shell

(Back to top)

Setup

  • Place the prompt_pwd.fish, notifyre.fish and nf.fish in your ~/.config/fish/functions/ folder.

    git clone https://github.com/kaustubhhiware/NotiFyre.git
    cd NotiFyre
    cp prompt_pwd.fish notifyre.fish nf.fish ~/.config/fish/functions/
    
  • ⚡️ Lightning fast alternative:

    # Pull the files from Github
    curl https://raw.githubusercontent.com/kaustubhhiware/NotiFyre/master/prompt_pwd.fish -o ~/.config/fish/functions/prompt_pwd.fish
    curl https://raw.githubusercontent.com/kaustubhhiware/NotiFyre/master/notifyre.fish -o ~/.config/fish/functions/notifyre.fish
    curl https://raw.githubusercontent.com/kaustubhhiware/NotiFyre/master/nf.fish -o ~/.config/fish/functions/nf.fish
  • To be notified for each process, add this to your functions/fish_prompt.fish file just before the end :

     function fish_prompt
        ...
    
        eval (notifyre)  # at the very end
     end

    This method works pretty well with my bobthefish theme and no theme as well. Let me know if it doesn't work out for you.

  • If you want to be notified only for select commands, you do not need to modify the fish_prompt.fish file.

    Run with nf command

    [This might take slightly more time than the process itself to complete execution.]

You can learn to write your own functions in fish with this as a starting point.

Configuration

(Back to top)

set -x timeout 1
set -x ring_timeout 2
set -x ALERT /usr/share/sounds/ubuntu/notifications/Slick.ogg

There are three available options:

  1. timeout : Same as option MIN_INTERVAL in the Bash / ZSH section above
  2. ring_timeout : Same as option SOUND_MIN in the Bash / ZSH section above
  3. ALERT : Same as option ALERT in the Bash / ZSH Section above

Note: The notifications appear in a queue, and cannot be implemented parallely (known bug in notify-send)

Why This?

(Back to top)

I had to reinstall Ubuntu quite a number of times thanks to how awesome Windows messed up my laptop. This script seeks to help anyone who multi-tasks, or does not constantly check their terminals. ntfy wasn't consistent always, so made this.

Tested on fresh install of Ubuntu 16.04, Arch Linux and Mac. Ubuntu 14 may require Slick.ogg whose path must be changed before usage.

Contributing

(Back to top)

Your contributions are always welcome 😄 ! Please have a look at the contribution guidelines first.

Discussion Group: https://www.facebook.com/groups/552015885141292/

You can use refer.md for some previous work I've referred to while making this.

Have a suggestion? Make an issue about it.

Debugging

(Back to top)

Not working/ Message not displayed

check if notify-osd is working with this - notify-send "hi"

If no message pops up, it means notify-osd has stopped working. Reinstall some dependencies and try again:

sudo apt-get --reinstall install libnotify-bin notify-osd

For further customizations, you can use NotifyOSD config

Acknowledgements

(Back to top)

License

(Back to top)

The MIT License (MIT) 2017 - Kaustubh Hiware. Please have a look at the LICENSE.md for more details.

You can’t perform that action at this time.