How can I use the eOS terminal notification in Ubuntu?
elementaryOS has the following feature to notify the user of a finished terminal process.
Is it possible to use this feature in Ubuntu?
Figure 1: Example of eOS terminal notification
What you want most probably already is available via your ~/.bashrc
courtesy this and this:
Note: this assumes you have libnotify-bin
installed. If it isn't, just run sudo apt-get install libnotify-bin
to get it.
Check that your ~/.bashrc
has lines like this:
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "Task finished" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
Note that "Task finished" isn't present in the original code.
So, in your specific example, you'll run
sudo apt-get update; alert
If you want the notification to remain on-screen a little longer, use -t 3000
(in milliseconds). Or, if you want the notification to display until you dismiss it, use --urgency=critical
.
Here's what I see:
undistract-me provides notifications for terminal commands that take longer than 10 seconds to complete.
sudo apt install undistract-me
echo 'source /etc/profile.d/undistract-me.sh' >> ~/.bashrc
You can set $PROMPT_COMMAND
to trigger a notify-send
command upon a command's completion in ~/.bashrc
:
PROMPT_COMMAND='notify-send --icon=/usr/share/icons/Adwaita/256x256/apps/utilities-terminal.png "Task finished" "$(history | sed -n "\$s/^ [0-9]\+ //p")"'
The caveat is this can become pretty annoying soon, because it will send a notification each time a command is run.