Permalink
Browse files

Support custom notification commands

1 parent 84a6e5d commit 980e4da2c98755deda5e0ad82e13494fe27698e0 @sickill committed Nov 5, 2011
Showing with 30 additions and 9 deletions.
  1. +6 −0 README.md
  2. +24 −9 git-dude
View
@@ -99,6 +99,12 @@ Set path to icon used by desktop notifications (default: none):
$ git config --global dude.icon ~/.git-dude/github_32.png
+Set custom notification command (`$TITLE`, `$DESCRIPTION` and `$ICON_PATH`
+environment variables are set when invoking notification command):
+
+ $ git config --global dude.notify-command 'gntp-send "$TITLE" "$DESCRIPTION" "$ICON_PATH"'
+ $ git config --global dude.notify-command 'echo -e "$TITLE\n\n\n$DESCRIPTION" | espeak --stdin -k20 -ven+12'
+
### Per-repository
Set path to icon used by desktop notifications for this repository (default:
View
@@ -28,20 +28,35 @@ interval=${interval:-60}
export LC_ALL=C # make sure git talks english
-[[ -d $1 ]] && cd $1
+if [[ $(git config dude.notify-command) ]]; then
+ notify_cmd=$(git config dude.notify-command)
+elif [ $(which notify-send 2>/dev/null) ]; then
+ notify_cmd='notify-send -i "$ICON_PATH" "$TITLE" "$DESCRIPTION"'
+elif [ $(which growlnotify 2>/dev/null) ]; then
+ notify_cmd='growlnotify --image "$ICON_PATH" -m "$DESCRIPTION" "$TITLE"'
+elif [ $(which kdialog 2>/dev/null) ]; then
+ notify_cmd='kdialog --icon $ICON_PATH --title "$TITLE" --passivepopup "$DESCRIPTION"'
+fi
function notify() {
- if [ $(which notify-send 2>/dev/null) ]; then
- notify-send -i "$1" "$2" "$3"
- elif [ $(which growlnotify 2>/dev/null) ]; then
- growlnotify --image "$1" -m "$3" "$2"
- elif [ $(which kdialog 2>/dev/null) ]; then
- kdialog --icon $1 --title "$2" --passivepopup "$3"
- else
- echo $2; echo $3
+ local ICON_PATH="$1"
+ local TITLE="$2"
+ local DESCRIPTION="$3"
+
+ if [ -n "$notify_cmd" ]; then
+ eval $notify_cmd
+ fi
+
+ date "+%T %D"
+ echo "$TITLE"
+ if [ -n "$DESCRIPTION" ]; then
+ echo "$DESCRIPTION"
fi
+ echo
}
+[[ -d $1 ]] && cd $1
+
while true; do
for dir_name in *; do
if [[ -d "$dir_name" && $(cd "$dir_name"; git rev-parse --git-dir 2>/dev/null) ]]; then

0 comments on commit 980e4da

Please sign in to comment.