summaryrefslogtreecommitdiffstats
path: root/noter
blob: 99c53e26d4c5660c28808545aa44df312cef30a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/zsh
#ADD scrot
# Pass arguments as is
set -x
root="$HOME/bin"
title=$(xwininfo -id `xdotool getactivewindow` | tr '"' '#' | perl -lne 'if ($_ =~ m/.*#(.*)#$/){ print $1; }' | cut -d ':' -f1,2,4,5)
case $title in
    *firefox*|*Vimper*) bin=fnoter; args=""; ;;
    *uake*|*term*|*)
        bin="generic";
        pid=$(xdotool getactivewindow getwindowpid)
        #pid=$(pgrep $title
        args="${title//\//}:$pid"
        #args="$title"
        ;;
esac

if [[ -z $1 || $1 =~ a.* ]];then
    file=$($root/noters/$bin add $args 2>/tmp/vlog || (notify-send "Error in calling $bin" && kill -9 $$))
    [[ -z $file || ! -f $file ]] && notify-send "FATAL: $file not found" && exit 1
    add_text="$(zenity --text 'Additional tags if any' --entry)"
    [[ ! -z $add_text ]] && echo "CTAGS: $add_text" >> $file || exit 1
    echo -e "====================================End Of note============================\n\n" >> $file || exit 1
    notify-send "Note added at $file  for $title"
else
    $root/noters/$bin "[email protected]"
fi


set +x