summaryrefslogtreecommitdiffstats
authorRaghavendra D Prabhu <[email protected]>2011-04-21 13:10:01 (GMT)
committer Raghavendra D Prabhu <[email protected]>2011-04-21 13:10:01 (GMT)
commit2823fc2cf2eb87f092a6c3051be4b03a43e3ce49 (patch) (unidiff)
tree8ebdd0a56e7492076bac069f604909b21817c7b1
parent755817023ac91292965979cfe64173dabf92c348 (diff)
downloadScripts-2823fc2cf2eb87f092a6c3051be4b03a43e3ce49.zip
Scripts-2823fc2cf2eb87f092a6c3051be4b03a43e3ce49.tar.gz
Scripts-2823fc2cf2eb87f092a6c3051be4b03a43e3ce49.tar.bz2
Updated the scripts
Diffstat (more/less context) (ignore whitespace changes)
-rwxr-xr-xarchievm8
-rwxr-xr-xbldins4
-rwxr-xr-xbrowser3
-rwxr-xr-xdmenu_run2
-rwxr-xr-xdown1
-rwxr-xr-xfixsubject10
-rw-r--r--functions16
-rwxr-xr-xgetimap3
-rwxr-xr-xgitprompt16
-rwxr-xr-xmplayer180
-rw-r--r--mplayer.fns154
-rwxr-xr-xmutt-notmuch189
-rwxr-xr-xwsync3
13 files changed, 403 insertions, 186 deletions
diff --git a/archievm b/archievm
index ff95900..67847b4 100755
--- a/archievm
+++ b/archievm
@@ -2,7 +2,8 @@
2# Virtio somehow broken 2# Virtio somehow broken
3 3
4[[ ! $(whoami) == 'root' ]] && exit 1 4[[ ! $(whoami) == 'root' ]] && exit 1
5modprobe kvm kvm_intel 5#sudo modprobe -a -v kvm kvm_intel virtio virtio_pci virtio_balloon virtio_blk virtio_net virtio_console virtio_rng 9pnet_virtio
6sudo modprobe -a -v kvm kvm_intel
6 7
7debugk=0 8debugk=0
8nographic=1 9nographic=1
@@ -11,7 +12,7 @@ test=0
11runas="raghavendra" 12runas="raghavendra"
12DIR="/home/raghavendra/Arch/qemu" 13DIR="/home/raghavendra/Arch/qemu"
13bzImage="$DIR/kvmImage" 14bzImage="$DIR/kvmImage"
14image="/media/Inkq/Virt/Archie.img" 15image="/media/Sparowes/Virt/Archie.img"
15soutput=1 16soutput=1
16#append="root=/dev/vda3" 17#append="root=/dev/vda3"
17 18
@@ -75,9 +76,10 @@ else
75fi 76fi
76 77
77 #-virtfs local,path=$DIR/module,security_model=passthrough,mount_tag=module \ 78 #-virtfs local,path=$DIR/module,security_model=passthrough,mount_tag=module \
79 #-m 512 $hugearg $snap -smp 2,cores=2,maxcpus=4 \
78 80
79cmdline="qemu-kvm -name Archie -enable-kvm -s -monitor unix:$DIR/archie.sock,server,nowait \ 81cmdline="qemu-kvm -name Archie -enable-kvm -s -monitor unix:$DIR/archie.sock,server,nowait \
80 -m 512 $hugearg $snap -smp 2,cores=2,maxcpus=4 \ 82 -m 512 $hugearg $snap \
81 -net nic,model=virtio,vlan=1 -net user,vlan=1,hostfwd=tcp:127.0.0.1:2222-:22 $=graph \ 83 -net nic,model=virtio,vlan=1 -net user,vlan=1,hostfwd=tcp:127.0.0.1:2222-:22 $=graph \
82 -virtfs local,path=$DIR/share,security_model=passthrough,mount_tag=share -balloon virtio \ 84 -virtfs local,path=$DIR/share,security_model=passthrough,mount_tag=share -balloon virtio \
83 -virtfs local,path=/var/cache/pacman/pkg,security_model=passthrough,mount_tag=pacman \ 85 -virtfs local,path=/var/cache/pacman/pkg,security_model=passthrough,mount_tag=pacman \
diff --git a/bldins b/bldins
index 4f9c2fd..2bcf490 100755
--- a/bldins
+++ b/bldins
@@ -38,13 +38,13 @@ export KCFLAGS=" -march=native -O2 -pipe "
38 38
39if [[ $install == 0 ]];then 39if [[ $install == 0 ]];then
40 40
41 [[ $clean == 0 ]] && make clean 41 [[ $clean == 1 ]] && make clean
42 42
43 if [[ $debug == 1 ]];then 43 if [[ $debug == 1 ]];then
44 44
45 #export BUILDCMD=" make $MAKEFLAGS bzImage " 45 #export BUILDCMD=" make $MAKEFLAGS bzImage "
46 #cp ~/config/kconfig/config.debug .config 46 #cp ~/config/kconfig/config.debug .config
47 KCFLAGS=" -mtune=generic -O -pipe " 47 KCFLAGS=" -mtune=generic -O1 -pipe -g "
48 BUILDCMD=" make $MAKEFLAGS bzImage " 48 BUILDCMD=" make $MAKEFLAGS bzImage "
49 #LDFLAGS_MODULE="" 49 #LDFLAGS_MODULE=""
50 unset INSTALL_MOD_STRIP 50 unset INSTALL_MOD_STRIP
diff --git a/browser b/browser
index ed1a7a1..57ed719 100755
--- a/browser
+++ b/browser
@@ -45,7 +45,8 @@ fi
45#if [[ $URL == http://tinyurl* || $num1 == $num2 || ((! -t 1) && $isrxvt == 0) ]];then 45#if [[ $URL == http://tinyurl* || $num1 == $num2 || ((! -t 1) && $isrxvt == 0) ]];then
46if [[ $URL == http://tinyurl* || $isrxvt == 0 ]];then 46if [[ $URL == http://tinyurl* || $isrxvt == 0 ]];then
47 OB="$BROWSER" 47 OB="$BROWSER"
48 $OB -remote "openurl($URL)" 48 #$OB -remote "openurl($URL)"
49 $OB "$URL"
49 #$OB "$URL" 50 #$OB "$URL"
50else 51else
51 OB="$TBROWSER" 52 OB="$TBROWSER"
diff --git a/dmenu_run b/dmenu_run
index 353fedb..d88cbf0 100755
--- a/dmenu_run
+++ b/dmenu_run
@@ -1,4 +1,4 @@
1#!/bin/zsh 1#!/bin/zsh
2#PATH="/home/raghavendra/bin:/opt/wine/bin:/bin:/usr/bin:/sbin:/usr/sbin" 2#PATH="/home/raghavendra/bin:/opt/wine/bin:/bin:/usr/bin:/sbin:/usr/sbin"
3#exe=`dmenu_path_c | dmenu -i -fa 'xft:Bitstream:pixelsize=14' -nb black -nf white -p : ${1+"[email protected]"}` && exec ${=exe} 3#exe=`dmenu_path_c | dmenu -i -fa 'xft:Bitstream:pixelsize=14' -nb black -nf white -p : ${1+"[email protected]"}` && exec ${=exe}
4exe=`dmenu_path | yeganesh -f -- -i -fn 'xft:Bitstream:pixelsize=19' -m 1 -sb aquamarine4 -nb grey2 -nf grey50 -p : ` && exec ${=exe} 4exe=`dmenu_path | yeganesh -f -- -i -fn 'xft:Bitstream:pixelsize=16' -m 1 -sb aquamarine4 -nb grey2 -nf grey50 -p : ` && exec ${=exe}
diff --git a/down b/down
index a91cf60..ef59b89 100755
--- a/down
+++ b/down
@@ -9,6 +9,5 @@ exit 1
9sync 9sync
10mount | grep loop | grep -v pacman && sudo umount /mnt* 10mount | grep loop | grep -v pacman && sudo umount /mnt*
11unmount-removables || failed 11unmount-removables || failed
12sleep 2
13pidof tmux && ~/bin/tux killall force 12pidof tmux && ~/bin/tux killall force
14sleep 1 13sleep 1
diff --git a/fixsubject b/fixsubject
new file mode 100755
index 0000000..9831d26
--- a/dev/null
+++ b/fixsubject
@@ -0,0 +1,10 @@
1#!/usr/bin/perl
2use utf8;
3use Encode;
4
5binmode(STDOUT,':utf8');
6my $utf8 = "";
7while (<STDIN>){
8 $utf8 = $utf8 . Encode::decode('MIME-Header', $_);
9}
10print $utf8;
diff --git a/functions b/functions
index 7c9bf1a..657214e 100644
--- a/functions
+++ b/functions
@@ -121,9 +121,10 @@ done
121#set +x 121#set +x
122} 122}
123 123
124function gdb(){ 124#function {gdb,cgdb} {
125/usr/bin/gdb --quiet 125#pid=$(pidof -s $1)
126} 126#/usr/bin/$0 -- --quiet --pid=$pid
127#}
127 128
128function genscope(){ 129function genscope(){
129 /usr/bin/cscope -b -R -q 130 /usr/bin/cscope -b -R -q
@@ -280,7 +281,7 @@ webman(){
280man(){ 281man(){
281 if [[ ! -z $2 || -z $TMUX ]];then /usr/bin/man "[email protected]" ; return; fi 282 if [[ ! -z $2 || -z $TMUX ]];then /usr/bin/man "[email protected]" ; return; fi
282 /usr/bin/man -w [email protected] &>/dev/null || return $? 283 /usr/bin/man -w [email protected] &>/dev/null || return $?
283 tmux split-window -p 83 "LC_ALL=C LANG=C exec /usr/bin/man [email protected]" 284 tmux split-window -p 90 "LC_ALL=C LANG=C exec /usr/bin/man [email protected]"
284} 285}
285 286
286 287
@@ -525,7 +526,7 @@ alias lsnew='noglob lsnew'
525#function {news,mutt,ncm,vim,weechat,weechat-curses,newsbeuter,ncmpcpp,atop,rtorrent,torrent} { 526#function {news,mutt,ncm,vim,weechat,weechat-curses,newsbeuter,ncmpcpp,atop,rtorrent,torrent} {
526function {news,mutt,ncm,weechat,weechat-curses,newsbeuter,ncmpcpp,atop,rtorrent,torrent} { 527function {news,mutt,ncm,weechat,weechat-curses,newsbeuter,ncmpcpp,atop,rtorrent,torrent} {
527 : ${(AA)muxaliases:=${(z)MUXAL}} 528 : ${(AA)muxaliases:=${(z)MUXAL}}
528 if [[ -z $TMUX || $1 == -f ]];then 529 if [[ -z $TMUX || $1 == -f || -n $1 ]];then
529 [[ $1 == -f ]] && shift 530 [[ $1 == -f ]] && shift
530 if test $muxaliases[$0];then 531 if test $muxaliases[$0];then
531 =$muxaliases[$0] "[email protected]" 532 =$muxaliases[$0] "[email protected]"
@@ -552,7 +553,7 @@ function {news,mutt,ncm,weechat,weechat-curses,newsbeuter,ncmpcpp,atop,rtorrent,
552 winum=$(~/bin/tux tnum $app) 553 winum=$(~/bin/tux tnum $app)
553 554
554 if [[ -z $winum || $? != 0 ]];then 555 if [[ -z $winum || $? != 0 ]];then
555 print "$0 = Dead | Something ==> recreated in its session" 556 #print "$0 = Dead | Something ==> recreated in its session"
556 return 5 557 return 5
557 fi 558 fi
558 559
@@ -576,6 +577,9 @@ function {reboot,sdown} {
576 eval "$=map[$command]" 577 eval "$=map[$command]"
577 fi 578 fi
578} 579}
580startx(){
581 /usr/bin/startx &>|~/logs/X.log
582}
579 583
580viewjson(){ 584viewjson(){
581 python -mjson.tool < $1 585 python -mjson.tool < $1
diff --git a/getimap b/getimap
index 91835a3..090b1c6 100755
--- a/getimap
+++ b/getimap
@@ -17,7 +17,8 @@ left=$(/bin/df -h | grep home | head -1 | awk '{ print $5 }' | tr -d '%')
17 17
18if [[ $left > 90 ]];then 18if [[ $left > 90 ]];then
19 echo "Low on space -- quitting" >> ~/logs/getmail.log 19 echo "Low on space -- quitting" >> ~/logs/getmail.log
20 exit 1 20 notify-send "========== ALERT ==============" "LOW ON SPACE"
21 exit 1
21fi 22fi
22 23
23notify-send "Mailman" "....Fetching mails." 24notify-send "Mailman" "....Fetching mails."
diff --git a/gitprompt b/gitprompt
index 4636744..f114f91 100755
--- a/gitprompt
+++ b/gitprompt
@@ -2,25 +2,27 @@
2# detect git first 2# detect git first
3 3
4trap 'print -n;exit 1' INT 4trap 'print -n;exit 1' INT
5autoload -U colors && colors 5#autoload -U colors && colors
6 6
7estatus=0 7estatus=0
8 8
9#isgit="$(git rev-parse --is-inside-work-tree 2>/dev/null)" 9#isgit="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
10#isgit="$(git rev-parse --is-inside-work-tree 2>/dev/null)" 10#isgit="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
11if test (../)#.git 2>/dev/null;then 11dir="$(print (../)#.git)"
12if test $dir 2>/dev/null;then
12#if [[ $isgit == "true" ]];then 13#if [[ $isgit == "true" ]];then
13 local gprompt="(" 14 local gprompt="("
14 gprompt+="$(git branch | grep '*'| cut -d ' ' -f 2 | tr -d '\n')" 15 gprompt+="${${$(<$dir/HEAD)[(ws| |)2]}[(ws:/:)-1]}"
15 #timeout 3 git status -s 16 #gprompt+="$(git branch | grep '*'| cut -d ' ' -f 2 | tr -d '\n')"
16 if [[ -n $(timeout -s KILL 2 git status -s) ]];then 17 #timeout 3 git status -s
17 gprompt+="⚡"; 18 if [[ -n $(timeout -s KILL 2 git status -s) ]];then
19 gprompt+="⚡";
18 estatus=1 20 estatus=1
19 else 21 else
20 gprompt+="ʃ"; 22 gprompt+="ʃ";
21 fi 23 fi
22 gprompt+=")" 24 gprompt+=")"
23 printf " %s%s" "%{${fg[yellow]}%}" $gprompt "%{$reset_color%}" 25 print -n $gprompt
24fi 26fi
25 27
26exit $estatus 28exit $estatus
diff --git a/mplayer b/mplayer
index 82cad0e..605cf51 100755
--- a/mplayer
+++ b/mplayer
@@ -1,155 +1,5 @@
1#!/bin/zsh 1#!/bin/zsh
2HIST="$HOME/.mplayer.hist" 2source ~/bin/mplayer.fns
3AUX_INVO=0
4POSITION=0
5maxplayers=1
6network=0
7stdin=0
8firstime=0
9randnum=$((${RANDOM}%${maxplayers}))
10mkdir -p /tmp/mplayer
11MPSOCKET="/tmp/mplayer/$randnum.fif"
12fixedvo=1
13typeset -A vo_map
14vo_map=(1 fixed-vo 0 nofixed-vo)
15
16pecho(){
17 msg="$1"
18 file="$2"
19 /bin/echo "$msg" >| $file &
20 sleep 0.1
21 echo < $file
22}
23
24# curl for non-strict url parsing ;)
25isurl () {
26 url="[email protected]"
27 curl -I -s "$url" &>/dev/null || return 1
28 return 0
29}
30
31
32check_pattern(){
33 pecho "get_property filename" $1
34 if tail -2 /tmp/mplayer.log | /bin/grep 'ANS_filename' | /bin/grep -v grep ;then
35 pecho "get_property pause" $1
36 if tail -2 /tmp/mplayer.log | /bin/grep 'ANS_pause=no' | /bin/grep -v grep ;then
37 retval=0
38 return 0
39 fi
40 retval=2
41 fi
42 [[ -z $retval ]] && retval=1
43 return 1
44}
45
46
47parse(){
48if [[ -z "$1" ]];then
49 fnum=$(awk '{ print NR" "$0 }' $HIST | cut -d ":" -f 1 | uniq -f 1 | tac | ${=DMENU})
50 [[ -z "$fnum" ]] && exit
51 num=$(echo "$fnum" | cut -d " " -f 1)
52 FILE=$(head -${num} $HIST | tail -1 | cut -d ":" -f 1)
53
54 if [[ $fnum == *: ]];then
55 name="$(cut -d ' ' -f 1 <<< $FILE)"
56 POSITION="$(grep $name $HIST | tail -1 | cut -d ':' -f 2)"
57 fi
58
59else
60 if [[ $1 == "-" ]];then
61 stdin=1
62 return
63 fi
64 if isurl "$(tr -d '.' <<< $1)";then # Fix /a/b/c/d type
65 FILE="$1"
66 network=1
67 else
68 if [[ "[email protected]" == /* ]];then
69 prefix=
70 else
71 prefix="$pwdir/"
72 fi
73 FILE="${prefix}[email protected]"
74 fi
75fi
76retval=$FILE
77}
78
79preplay(){
80 mpc pause &>/dev/null
81 ln -sf $MPSOCKET /tmp/mplayer.fif || exit 1
82}
83
84check_status(){
85if [[ $fixedvo == 1 ]];then
86 pidof mplayer || return 1
87 echo >>| /tmp/mplayer.log
88 retval=1
89 for ff in /tmp/mplayer/*.fif;do
90 if check_pattern $ff;then
91 return $retval
92 fi
93 done
94 return $retval
95else
96 if xdotool search --class mplayer;then
97 return 1
98 else
99 return 0
100 fi
101fi
102}
103
104aux(){
105case $1 in
106 status)
107 check_status
108 return $?
109 ;;
110 clean)
111 rm /tmp/mplayer/* 2>/dev/null
112 rm /tmp/mplayer.fif 2>/dev/null
113 killall -9 mplayer 2>/dev/null
114 rm /tmp/locks/mplayer* 2>/dev/null
115 mv /tmp/mplayer.log /tmp/.mplayer.log
116 exit
117 ;;
118 pause)
119 pecho 'pause' $MPSOCKET
120 ;;
121 snext)
122 pecho 'seek +10' $MPSOCKET
123 ;;
124 sprev)
125 pecho 'seek -10' $MPSOCKET
126 ;;
127 pnext)
128 pecho "pt_step 1" $MPSOCKET
129 ;;
130 pprev)
131 pecho "pt_step -1" $MPSOCKET
132 ;;
133 stop)
134 wheret
135 echo "$retval" >>| ~/.mplayer.hist
136 pecho 'stop' $MPSOCKET
137 echo "#STOPPED ${file}" >>| /tmp/mplayer.log
138 ;;
139 *)
140 return 1
141esac
142}
143
144wheret(){
145 pecho 'get_time_pos' $MPSOCKET
146 pecho 'get_property path' $MPSOCKET
147 sleep 3
148 LOG="tail -5 /tmp/mplayer.log"
149 position=$(${=LOG} | /bin/grep ANS_TIME_POSITION | head -1 | cut -d "=" -f 2)
150 file=$(${=LOG} | /bin/grep ANS_path | head -1 | cut -d "=" -f 2)
151 retval="$file:$position"
152}
153 3
154if [[ $0 == *mplayeraux ]];then 4if [[ $0 == *mplayeraux ]];then
155 AUX_INVO=1 5 AUX_INVO=1
@@ -160,37 +10,38 @@ if [[ ! -e $MPSOCKET ]] ;then
160 firstime=1 10 firstime=1
161 mkfifo $MPSOCKET 11 mkfifo $MPSOCKET
162 ln -sf $MPSOCKET /tmp/mplayer.fif 12 ln -sf $MPSOCKET /tmp/mplayer.fif
163 #notify-send "Mplayer" "mplayer starting up....." 13 notify-send "Mplayer" "mplayer starting up....."
164fi 14fi
165 15
166exec &>>|/tmp/mplayer.log 16exec &>>|/tmp/mplayer.log
167
168
169pwdir=$(pwd) 17pwdir=$(pwd)
170 18
171 19
172pushd $HOME 20pushd -q $HOME
173${=LOCK}/mplayer.$randnum /usr/bin/mplayer -$vo_map[$fixedvo] -msglevel all=4 -slave -idle -input file=$MPSOCKET -input conf=$HOME/.mplayer/input.conf.mine &! 21if [[ $stdin == 1 ]];then
174popd 22 fd=$(readlink -f /dev/stdin)
23 exec 3<&0
24 exec 0</dev/tty
25 ${=LOCK}/mplayer.$randnum /usr/bin/mplayer -$vo_map[$fixedvo] -msglevel all=4 -slave -idle -input file=$MPSOCKET -input conf=$HOME/.mplayer/input.conf.mine &!
26else
27 ${=LOCK}/mplayer.$randnum /usr/bin/mplayer -$vo_map[$fixedvo] -msglevel all=4 -slave -idle -input file=$MPSOCKET -input conf=$HOME/.mplayer/input.conf.mine &!
28fi
29popd -q
175 30
176parse [email protected] 31parse [email protected]
177FILE=$retval 32FILE=$retval
178preplay 33preplay
179 34
180[[ $firstime == 1 ]] && sleep 2 35[[ $firstime == 1 ]] && sleep 1
181 36
182if [[ $stdin == 1 ]];then 37if [[ $stdin == 1 ]];then
183 fd=$(readlink -f /dev/stdin)
184 exec 3<&0
185 exec 0</dev/tty
186 #${=LOCK}/mplayer.$randnum /usr/bin/mplayer -$vo_map[$fixedvo] -msglevel all=4 -slave -idle -input file=$MPSOCKET -input conf=$HOME/.mplayer/input.conf.mine &!
187 pecho "loadfile $fd " /tmp/mplayer.fif 38 pecho "loadfile $fd " /tmp/mplayer.fif
188 #/usr/bin/mplayer - 39 exit 11
189 exit 110
190else 40else
191 pecho "loadfile \"$FILE\" 2" $MPSOCKET 41 pecho "loadfile \"$FILE\" 2" $MPSOCKET
192fi 42fi
193 43
44(
194check_status 45check_status
195 46
196# Queue or play 47# Queue or play
@@ -206,4 +57,5 @@ else
206 fi 57 fi
207fi 58fi
208/bin/echo "mplayer \"$FILE\"" >>| ~/.current 59/bin/echo "mplayer \"$FILE\"" >>| ~/.current
60) &
209# vim: set foldmethod=marker: 61# vim: set foldmethod=marker:
diff --git a/mplayer.fns b/mplayer.fns
new file mode 100644
index 0000000..772f56c
--- a/dev/null
+++ b/mplayer.fns
@@ -0,0 +1,154 @@
1#!/bin/zsh
2HIST="$HOME/.mplayer.hist"
3AUX_INVO=0
4POSITION=0
5maxplayers=1
6network=0
7stdin=0
8firstime=0
9randnum=$((${RANDOM}%${maxplayers}))
10mkdir -p /tmp/mplayer
11MPSOCKET="/tmp/mplayer/$randnum.fif"
12fixedvo=1
13typeset -A vo_map
14vo_map=(1 fixed-vo 0 nofixed-vo)
15
16pecho(){
17 msg="$1"
18 file="$2"
19 /bin/echo "$msg" >| $file &
20 sleep 0.1
21 echo < $file
22}
23
24# curl for non-strict url parsing ;)
25isurl () {
26 url="[email protected]"
27 curl -I -s "$url" &>/dev/null || return 1
28 return 0
29}
30
31
32check_pattern(){
33 pecho "get_property filename" $1
34 if tail -2 /tmp/mplayer.log | /bin/grep 'ANS_filename' | /bin/grep -v grep ;then
35 pecho "get_property pause" $1
36 if tail -2 /tmp/mplayer.log | /bin/grep 'ANS_pause=no' | /bin/grep -v grep ;then
37 retval=0
38 return 0
39 fi
40 retval=2
41 fi
42 [[ -z $retval ]] && retval=1
43 return 1
44}
45
46
47parse(){
48if [[ -z "$1" ]];then
49 fnum=$(awk '{ print NR" "$0 }' $HIST | cut -d ":" -f 1 | uniq -f 1 | tac | ${=DMENU})
50 [[ -z "$fnum" ]] && exit
51 num=$(echo "$fnum" | cut -d " " -f 1)
52 FILE=$(head -${num} $HIST | tail -1 | cut -d ":" -f 1)
53
54 if [[ $fnum == *: ]];then
55 name="$(cut -d ' ' -f 1 <<< $FILE)"
56 POSITION="$(grep $name $HIST | tail -1 | cut -d ':' -f 2)"
57 fi
58
59else
60 if [[ $1 == "-" ]];then
61 stdin=1
62 return
63 fi
64 if isurl "$(tr -d '.' <<< $1)";then # Fix /a/b/c/d type
65 FILE="$1"
66 network=1
67 else
68 if [[ "[email protected]" == /* ]];then
69 prefix=
70 else
71 prefix="$pwdir/"
72 fi
73 FILE="${prefix}[email protected]"
74 fi
75fi
76retval=$FILE
77}
78
79preplay(){
80 mpc pause &>/dev/null
81 ln -sf $MPSOCKET /tmp/mplayer.fif || exit 1
82}
83
84check_status(){
85if [[ $fixedvo == 1 ]];then
86 pidof mplayer || return 1
87 echo >>| /tmp/mplayer.log
88 retval=1
89 for ff in /tmp/mplayer/*.fif;do
90 if check_pattern $ff;then
91 return $retval
92 fi
93 done
94 return $retval
95else
96 if xdotool search --class mplayer;then
97 return 1
98 else
99 return 0
100 fi
101fi
102}
103
104aux(){
105case $1 in
106 status)
107 check_status
108 return $?
109 ;;
110 clean)
111 rm /tmp/mplayer/* 2>/dev/null
112 rm /tmp/mplayer.fif 2>/dev/null
113 killall -9 mplayer 2>/dev/null
114 rm /tmp/locks/mplayer* 2>/dev/null
115 mv /tmp/mplayer.log /tmp/.mplayer.log
116 exit
117 ;;
118 pause)
119 pecho 'pause' $MPSOCKET
120 ;;
121 snext)
122 pecho 'seek +10' $MPSOCKET
123 ;;
124 sprev)
125 pecho 'seek -10' $MPSOCKET
126 ;;
127 pnext)
128 pecho "pt_step 1" $MPSOCKET
129 ;;
130 pprev)
131 pecho "pt_step -1" $MPSOCKET
132 ;;
133 stop)
134 wheret
135 echo "$retval" >>| ~/.mplayer.hist
136 pecho 'stop' $MPSOCKET
137 echo "#STOPPED ${file}" >>| /tmp/mplayer.log
138 ;;
139 *)
140 return 1
141esac
142}
143
144wheret(){
145 pecho 'get_time_pos' $MPSOCKET
146 pecho 'get_property path' $MPSOCKET
147 sleep 3
148 LOG="tail -5 /tmp/mplayer.log"
149 position=$(${=LOG} | /bin/grep ANS_TIME_POSITION | head -1 | cut -d "=" -f 2)
150 file=$(${=LOG} | /bin/grep ANS_path | head -1 | cut -d "=" -f 2)
151 retval="$file:$position"
152}
153
154# vim: set foldmethod=marker:
diff --git a/mutt-notmuch b/mutt-notmuch
new file mode 100755
index 0000000..e1fe909
--- a/dev/null
+++ b/mutt-notmuch
@@ -0,0 +1,189 @@
1#!/usr/bin/perl -w
2#
3# mutt-notmuch - notmuch (of a) helper for Mutt
4#
5# Copyright: © 2011 Stefano Zacchiroli <[email protected]>
6# License: GNU General Public License (GPL), version 3 or above
7#
8# See the bottom of this file for more documentation.
9# A manpage can be obtained by running "pod2man mutt-notmuch > mutt-notmuch.1"
10
11use strict;
12use warnings;
13
14use File::Path;
15use Getopt::Long;
16use Mail::Internet;
17use Mail::Box::Maildir;
18use Pod::Usage;
19
20
21# create an empty maildir (if missing) or empty an existing maildir"
22sub empty_maildir($) {
23 my ($maildir) = (@_);
24 rmtree($maildir) if (-d $maildir);
25 my $folder = new Mail::Box::Maildir(folder => $maildir,
26 create => 1);
27 $folder->close();
28}
29
30# search($maildir, $query)
31# search mails according to $query with notmuch; store results in $maildir
32sub search($$) {
33 my ($maildir, $query) = @_;
34
35 empty_maildir($maildir);
36 system("notmuch search --output=files $query"
37 . " | xargs --no-run-if-empty ln -s -t $maildir/cur/");
38}
39
40sub search_action([email protected]) {
41 my ($interactive, $results_dir, @params) = @_;
42
43 if (! $interactive) {
44 search($results_dir, join(' ', @params));
45 } else {
46 my $query = "";
47 my $done = 0;
48 while (! $done) {
49 print "search ('?' for man): ";
50 chomp($query = <STDIN>);
51 if ($query eq "?") {
52 system("man notmuch");
53 } elsif ($query eq "") {
54 $done = 1;# quit doing nothing
55 } else {
56 search($results_dir, $query);
57 $done = 1;
58 }
59 }
60 }
61}
62
63sub thread_action(@) {
64 my ($results_dir, @params) = @_;
65
66 my $mail = Mail::Internet->new(\*STDIN);
67 $mail->head->get('message-id') =~ /^<(.*)>$/;# get message-id
68 my $mid = $1;
69 my $tid = `notmuch search --output=threads id:$mid`;# get thread id
70 chomp($tid);
71
72 search($results_dir, $tid);
73}
74
75sub die_usage() {
76 my %podflags = ( "verbose" => 1,
77 "exitval" => 2 );
78 pod2usage(%podflags);
79}
80
81sub main() {
82 my $results_dir = "$ENV{HOME}/.cache/mutt_results";
83 my $interactive = 0;
84 my $help_needed = 0;
85
86 my $getopt = GetOptions(
87 "h|help" => \$help_needed,
88 "o|output-dir=s" => \$results_dir,
89 "p|prompt" => \$interactive);
90 if (! $getopt || $#ARGV < 0) { die_usage() };
91 my ($action, @params) = ($ARGV[0], @ARGV[1..$#ARGV]);
92
93 if ($help_needed) {
94 die_usage();
95 } elsif ($action eq "search" && $#ARGV == 0 && ! $interactive) {
96 print STDERR "Error: no search term provided\n\n";
97 die_usage();
98 } elsif ($action eq "search") {
99 search_action($interactive, $results_dir, @params);
100 } elsif ($action eq "thread") {
101 thread_action($results_dir, @params);
102 } else {
103 die_usage();
104 }
105}
106
107main();
108
109__END__
110
111=head1 NAME
112
113mutt-notmuch - notmuch (of a) helper for Mutt
114
115=head1 SYNOPSIS
116
117=over
118
119=item B<mutt-notmuch> [I<OPTION>]... search [I<SEARCH-TERM>]...
120
121=item B<mutt-notmuch> [I<OPTION>]... thread < I<MAIL>
122
123=back
124
125=head1 DESCRIPTION
126
127mutt-notmuch is a frontend to the notmuch mail indexer capable of populating
128maildir with search results.
129
130=head1 OPTIONS
131
132=over 4
133
134=item -o DIR
135
136=item --output-dir DIR
137
138Store search results as (symlink) messages under maildir DIR. Beware: DIR will
139be overwritten. (Default: F<~/.cache/mutt_results/>)
140
141=item -p
142
143=item --prompt
144
145Instead of using command line search terms, prompt the user for them (only for
146"search").
147
148=item -h
149
150=item --help
151
152Show usage information and exit.
153
154=back
155
156=head1 INTEGRATION WITH MUTT
157
158mutt-notmuch can be used to integrate notmuch with the Mutt mail user agent
159(unsurprisingly, given the name). To that end, you should define the following
160macros in your F<~/.muttrc> (replacing F<~/bin/mutt-notmuch> for the actual
161location of mutt-notmuch on your system):
162
163 macro index <F8> \
164 "<enter-command>unset wait_key<enter><shell-escape>~/bin/mutt-notmuch --prompt search<enter><change-folder-readonly>~/.cache/mutt_results<enter>" \
165 "search mail (using notmuch)"
166 macro index <F9> \
167 "<enter-command>unset wait_key<enter><pipe-message>~/bin/mutt-notmuch thread<enter><change-folder-readonly>~/.cache/mutt_results<enter><enter-command>set wait_key<enter>" \
168 "search and reconstruct owning thread (using notmuch)"
169
170The first macro (activated by <F8>) will prompt the user for notmuch search
171terms and then jump to a temporary maildir showing search results. The second
172macro (activated by <F9>) will reconstruct the thread corresponding to the
173current mail and show it as search results.
174
175To keep notmuch index current you should then periodically run C<notmuch
176new>. Depending on your local mail setup, you might want to do that via cron,
177as a hook triggered by mail retrieval, etc.
178
179=head1 SEE ALSO
180
181mutt(1), notmuch(1)
182
183=head1 AUTHOR
184
185Copyright: (C) 2011 Stefano Zacchiroli <[email protected]>
186
187License: GNU General Public License (GPL), version 3 or higher
188
189=cut
diff --git a/wsync b/wsync
index a868a8b..947f27a 100755
--- a/wsync
+++ b/wsync
@@ -64,6 +64,9 @@ do
64 print "Dirty repo" 64 print "Dirty repo"
65 pread "Commit $proj and then continue" 65 pread "Commit $proj and then continue"
66 fi 66 fi
67 git status
68 git add -A
69 git commit
67 git push --mirror -v ssh://[email protected]/$remotedir:t/$projname.git 70 git push --mirror -v ssh://[email protected]/$remotedir:t/$projname.git
68 fi 71 fi
69 popd 72 popd