Skip to content

Instantly share code, notes, and snippets.

@rcassani
Created October 29, 2017 16:38
Show Gist options
  • Save rcassani/2fc5224e9be08aec8f220647e7ad12c2 to your computer and use it in GitHub Desktop.
Save rcassani/2fc5224e9be08aec8f220647e7ad12c2 to your computer and use it in GitHub Desktop.
Notify and run a command
#!/bin/bash
# Usage
if [ ${#@} == 0 ]
then
echo "Usage: $0 notification_msg [command] [icon-path]"
echo "* notification: <Mensage for notification>"
echo "* [command] : <Command to execute>"
echo "* [icon-path] : <Path to icon path, Default Star icon>"
fi
# Default icon is a Star
if [ -z $3 ]
then
iconpath="/usr/share/icons/gnome/32x32/status/starred.png"
else
iconpath=$3
fi
# Message to display, minimum expire time
if [ -n "$1" ]
then
notify-send "$1" --expire-time=1 --urgency=normal --icon=$iconpath
fi
# Execute the command
eval $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment