summaryrefslogtreecommitdiffstats
authorRaghavendra D Prabhu <[email protected]>2011-05-08 12:19:29 (GMT)
committer Raghavendra D Prabhu <[email protected]>2011-05-08 12:19:29 (GMT)
commit35f34879f4cb7ffa372640af1694572c85ae5dc8 (patch) (side-by-side diff)
tree183b405ef19b06c8ac66d6f0b04be5c22703dfe2
parent2823fc2cf2eb87f092a6c3051be4b03a43e3ce49 (diff)
downloadScripts-35f34879f4cb7ffa372640af1694572c85ae5dc8.zip
Scripts-35f34879f4cb7ffa372640af1694572c85ae5dc8.tar.gz
Scripts-35f34879f4cb7ffa372640af1694572c85ae5dc8.tar.bz2
Plenty of new members and updates
Diffstat (more/less context) (ignore whitespace changes)
-rwxr-xr-xarchievm18
-rwxr-xr-xbldins14
-rwxr-xr-xdmenu_run2
-rw-r--r--functions42
-rwxr-xr-xgetimap1
-rwxr-xr-xgitscope9
-rwxr-xr-xmailboxes2
-rwxr-xr-xmplayer6
-rw-r--r--mplayer.fns4
-rwxr-xr-xnotify-send2
-rwxr-xr-xsticker83
-rwxr-xr-xtpaste7
-rwxr-xr-xtux10
-rwxr-xr-xwsync52
14 files changed, 203 insertions, 49 deletions
diff --git a/archievm b/archievm
index 67847b4..f03d89f 100755
--- a/archievm
+++ b/archievm
@@ -1,14 +1,15 @@
#!/bin/zsh
# Virtio somehow broken
-[[ ! $(whoami) == 'root' ]] && exit 1
+#[[ ! $(whoami) == 'root' ]] && exit 1
#sudo modprobe -a -v kvm kvm_intel virtio virtio_pci virtio_balloon virtio_blk virtio_net virtio_console virtio_rng 9pnet_virtio
sudo modprobe -a -v kvm kvm_intel
debugk=0
nographic=1
-huge=0
+huge=1
test=0
+ksm=0
runas="raghavendra"
DIR="/home/raghavendra/Arch/qemu"
bzImage="$DIR/kvmImage"
@@ -58,9 +59,9 @@ if [[ $debugk == 1 ]];then
fi
if [[ $huge == 1 ]];then
- echo 296 >| /proc/sys/vm/nr_hugepages
- #hugearg=" -mem-path /media/hugepages -mem-prealloc "
- hugearg=" -mem-path /media/hugepages "
+ echo 296 | sudo tee /proc/sys/vm/nr_hugepages
+ hugearg=" -mem-path /media/hugepages -mem-prealloc "
+ #hugearg=" -mem-path /media/hugepages "
fi
if [[ $nographic == 1 ]];then
@@ -77,11 +78,12 @@ fi
#-virtfs local,path=$DIR/module,security_model=passthrough,mount_tag=module \
#-m 512 $hugearg $snap -smp 2,cores=2,maxcpus=4 \
+ # -balloon virtio
cmdline="qemu-kvm -name Archie -enable-kvm -s -monitor unix:$DIR/archie.sock,server,nowait \
-m 512 $hugearg $snap \
-net nic,model=virtio,vlan=1 -net user,vlan=1,hostfwd=tcp:127.0.0.1:2222-:22 $=graph \
- -virtfs local,path=$DIR/share,security_model=passthrough,mount_tag=share -balloon virtio \
+ -virtfs local,path=$DIR/share,security_model=passthrough,mount_tag=share \
-virtfs local,path=/var/cache/pacman/pkg,security_model=passthrough,mount_tag=pacman \
$external -runas $runas $=EARGS"
@@ -89,7 +91,9 @@ cmdline="qemu-kvm -name Archie -enable-kvm -s -monitor unix:$DIR/archie.sock,ser
#exit
eval $=cmdline
-echo 1 >| /sys/kernel/mm/ksm/run
+if [[ $ksm == 1 ]];then
+ echo 1 | sudo tee /sys/kernel/mm/ksm/run
+fi
echo "sudo -u $runas sshfs -p 2222 [email protected]:/ /mnt-qemu" | xclip -i
#rlwrap -pgreen socat - $DIR/archie.sock
rlwrap socat - $DIR/archie.sock
diff --git a/bldins b/bldins
index 2bcf490..43ad6dd 100755
--- a/bldins
+++ b/bldins
@@ -1,6 +1,6 @@
#!/bin/zsh
-pread (){
+function pread (){
[[ $debug == 0 ]] && {
echo
@@ -14,10 +14,10 @@ pushd $HOME/Arch/Build/torvalds-git
install=${INSTALL:-0}
-
debug=${DEBUG:-0}
export KBUILD_VERBOSE=${VERBOSE:-0}
clean=${CLEAN:-1}
+conf=${CONF:-1}
MAKEFLAGS=${MAKEFLAGS:--j8}
ccache=${CCACHE:-0}
export ARCH=x86_64
@@ -27,6 +27,7 @@ if [[ $ccache == 1 ]];then
export PATH="/usr/lib/ccache/bin/:$PATH"
clean=0
fi
+#export BUILDCMD=" make CC=clang $MAKEFLAGS bzImage modules "
export BUILDCMD=" make $MAKEFLAGS bzImage modules "
export MENUCONFIG_COLOR=blackbg
export KRCH="x86"
@@ -48,10 +49,15 @@ if [[ $install == 0 ]];then
BUILDCMD=" make $MAKEFLAGS bzImage "
#LDFLAGS_MODULE=""
unset INSTALL_MOD_STRIP
- make localyesconfig || exit 1
+ if [[ $conf == 1 ]];then
+ make localyesconfig || exit 1
+ fi
else
#cp ~/config/kconfig/config .config
- make menuconfig || exit 1
+ #make menuconfig || exit 1
+ if [[ $conf == 1 ]];then
+ make nconfig || exit 1
+ fi
make modules_prepare || exit 1
fi
diff --git a/dmenu_run b/dmenu_run
index d88cbf0..c0d3dbc 100755
--- a/dmenu_run
+++ b/dmenu_run
@@ -1,4 +1,4 @@
#!/bin/zsh
#PATH="/home/raghavendra/bin:/opt/wine/bin:/bin:/usr/bin:/sbin:/usr/sbin"
#exe=`dmenu_path_c | dmenu -i -fa 'xft:Bitstream:pixelsize=14' -nb black -nf white -p : ${1+"[email protected]"}` && exec ${=exe}
-exe=`dmenu_path | yeganesh -f -- -i -fn 'xft:Bitstream:pixelsize=16' -m 1 -sb aquamarine4 -nb grey2 -nf grey50 -p : ` && exec ${=exe}
+exe=`dmenu_path | yeganesh -f -- -i -fn 'xft:Bitstream:pixelsize=16' -sb aquamarine4 -nb grey2 -nf grey50 -p : ` && exec ${=exe}
diff --git a/functions b/functions
index 657214e..d3ddfa2 100644
--- a/functions
+++ b/functions
@@ -6,6 +6,9 @@ else
/usr/bin/mplayer -really-quiet $XDG_CACHE_HOME/pronounce/$word
fi
}
+function pal(){
+ pacman -Ql $1 | /bin/grep -v "/usr/share/locale"
+}
function translate(){
wget -qO - "http://ajax.googleapis.com/ajax/services/language/translate?langpair=|en&v=1.0&q=`xsel`" |cut -d \" -f 6
@@ -38,6 +41,12 @@ dtach -A $HOME/.cache/1080 -E ssh [email protected] -L 1080:soc
#tmux new-session -s cnkt ssh [email protected] -L 1080:socks.yahoo.com:1080
}
+function wcnkt(){
+#export TERM=xterm
+dtach -A $HOME/.cache/wnohang -E ssh [email protected]
+#tmux new-session -s cnkt ssh [email protected] -L 1080:socks.yahoo.com:1080
+}
+
function randbash(){
curl -s http://bash.org/?random1|grep -oE "<p class=\"quote\">.*</p>.*</p>"|grep -oE "<p class=\"qt.*?</p>"|sed -e 's/<\/p>/\n/g' -e 's/<p class=\"qt\">//g' -e 's/<p class=\"qt\">//g'|perl -ne 'use HTML::Entities;print decode_entities($_),"\n"'| head -1
}
@@ -127,21 +136,37 @@ done
#}
function genscope(){
- /usr/bin/cscope -b -R -q
+ /usr/bin/cscope -b -R -q -k
}
function cscope(){
#/usr/bin/cscope -d -f $(readlink -f (../)#cscope.out) [email protected]
file=$(readlink -f (../)#cscope.out)
[[ $? != 0 ]] && return 1
pushd $file:h
- /usr/bin/cscope -d [email protected]
+ /usr/bin/cscope -d -p 4 [email protected]
+}
+function dmode(){
+ unset CC CXX
+ export CFLAGS="-march=native -O0 -pipe -g"
+ export CXXLAGS="-march=native -O0 -pipe -g"
+ unset LDFLAGS
}
-
function cscore()
{
curl -s -e "http://www.google.com" -A "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1" "http://livechat.rediff.com:80/sports/score/score.txt"
}
+function ckernel(){
+
+ echo "
+ file /home/raghavendra/Arch/qemu/vmlinux
+ cd /home/raghavendra/Arch/Build/torvalds-git
+ set architecture i386:x86-64:intel
+ target remote /dev/pts/17
+ "
+
+}
+
function wpack(){
pacman -Q | grep "[email protected]"
}
@@ -567,6 +592,12 @@ function {news,mutt,ncm,weechat,weechat-curses,newsbeuter,ncmpcpp,atop,rtorrent,
# fi
}
+function btime(){
+ stat -f $1 | /bin/grep -q ext || return 1
+ mnt=$(stat --format %m $1 | xargs -I {} grep {} /proc/mounts | awk '{ print $1 }')
+ debugfs -R "stat $1" $mnt | /bin/grep crtime
+}
+
function {reboot,sdown} {
typeset -A map
map=(sdown '/sbin/shutdown -h now' reboot 'command reboot')
@@ -578,7 +609,7 @@ function {reboot,sdown} {
fi
}
startx(){
- /usr/bin/startx &>|~/logs/X.log
+ /usr/bin/startx -- [email protected] &>|~/logs/X.log
}
viewjson(){
@@ -588,4 +619,7 @@ viewjson(){
viewlite(){
sqlite3 $1 .dump
}
+function isitdown(){
+ dlink http://www.downforeveryoneorjustme.com/$1 | /bin/grep "you"
+}
# vim: set ft=sh ts=4 sw=4 foldmethod=syntax tw=80 noet:
diff --git a/getimap b/getimap
index 090b1c6..4a54a97 100755
--- a/getimap
+++ b/getimap
@@ -1,5 +1,4 @@
#!/bin/bash
-#exit
if ! mount | grep -q wormole;then
echo "Booh.... "
exit
diff --git a/gitscope b/gitscope
new file mode 100755
index 0000000..f1d7fae
--- a/dev/null
+++ b/gitscope
@@ -0,0 +1,9 @@
+#!/bin/zsh
+# post-merge too ?
+if [[ $1 =~ [0]{40} ]];then
+ /usr/bin/cscope -b -R -q
+ exit
+fi
+scopefile="/tmp/gitscope.$$"
+git --no-pager diff --diff-filter=AMRC --name-only $1 $2 >| $scopefile && \
+ (cscope -b -q -i $scopefile && rm $scopefile) &!
diff --git a/mailboxes b/mailboxes
index 61e612d..db7c2de 100755
--- a/mailboxes
+++ b/mailboxes
@@ -11,6 +11,7 @@ popd -q
today=$(date +%Y-%m-%d)
yesterday=$(date --date='1 day ago' +%Y-%m-%d)
+other=$(date --date='2 day ago' +%Y-%m-%d)
if [[ ! ${$(readlink ~/Mail/Kronos/Today):t} == $today \
|| ! ${$(readlink ~/Mail/Kronos/Yesterday/):t} == $yesterday ]];then
@@ -31,6 +32,7 @@ echo "~/Mail/Kronos/Today \
~/Mail/Kronos/ \
~/Mail/Yahoo/ \
~/Mail/Sent/ \
+ ~/Mail/Kronos/$other \
$(find ~/Mail/ -type d -name new -printf '%d:%[email protected]:%h \n' \
| sort -t : -k 1,2 -r \
| cut -d : -f 3 \
diff --git a/mplayer b/mplayer
index 605cf51..0517880 100755
--- a/mplayer
+++ b/mplayer
@@ -1,4 +1,6 @@
#!/bin/zsh
+zmodload zsh/zutil
+start=${START:-0}
source ~/bin/mplayer.fns
if [[ $0 == *mplayeraux ]];then
@@ -13,6 +15,7 @@ if [[ ! -e $MPSOCKET ]] ;then
notify-send "Mplayer" "mplayer starting up....."
fi
+[[ $start == 1 ]] && stdin=0
exec &>>|/tmp/mplayer.log
pwdir=$(pwd)
@@ -27,6 +30,7 @@ else
${=LOCK}/mplayer.$randnum /usr/bin/mplayer -$vo_map[$fixedvo] -msglevel all=4 -slave -idle -input file=$MPSOCKET -input conf=$HOME/.mplayer/input.conf.mine &!
fi
popd -q
+[[ $start == 1 ]] && exit
FILE=$retval
@@ -57,5 +61,5 @@ else
fi
fi
/bin/echo "mplayer \"$FILE\"" >>| ~/.current
-) &
+) &!
# vim: set foldmethod=marker:
diff --git a/mplayer.fns b/mplayer.fns
index 772f56c..ba9b040 100644
--- a/mplayer.fns
+++ b/mplayer.fns
@@ -110,7 +110,9 @@ case $1 in
clean)
rm /tmp/mplayer/* 2>/dev/null
rm /tmp/mplayer.fif 2>/dev/null
- killall -9 mplayer 2>/dev/null
+ killall mplayer 2>/dev/null
+ sleep 1
+ killall -9 mplayer &>/dev/null
rm /tmp/locks/mplayer* 2>/dev/null
mv /tmp/mplayer.log /tmp/.mplayer.log
exit
diff --git a/notify-send b/notify-send
index 574f1d6..4d1efec 100755
--- a/notify-send
+++ b/notify-send
@@ -9,7 +9,7 @@ xnotify(){
rest=${(Q)rest}
text=$(echo "^fg(green)$heading[1,15]: ^fg(grey85)$rest" | perl -pe 'if (!eof()) { s/\n/ | /g }' | tr -dc '[:print:]' )
- echo "$text" | dzen2 -p $duration -xs 2 -y -1 &!
+ echo "$text" | dzen2 -p $duration -xs 1 -y -1 &!
}
cnotify(){
tmux display-message '[email protected]'
diff --git a/sticker b/sticker
new file mode 100755
index 0000000..426f33c
--- a/dev/null
+++ b/sticker
@@ -0,0 +1,83 @@
+#! /usr/bin/env python2
+
+# Edit these
+HOST = "/home/raghavendra/.mpd/socket"
+PORT = 6600
+PASS = None
+
+
+from optparse import OptionParser
+from socket import error as SocketError
+from sys import stderr
+
+from mpd import MPDClient, MPDError
+
+
+ACTIONS = ("get", "set", "delete", "list", "find")
+
+
+def main(action, uri, name, value):
+ client = MPDClient()
+ client.connect(HOST, PORT)
+ if PASS:
+ client.password(PASS)
+
+ if action == "get":
+ print client.sticker_get("song", uri, name)
+ if action == "set":
+ client.sticker_set("song", uri, name, value)
+ if action == "delete":
+ client.sticker_delete("song", uri, name)
+ if action == "list":
+ stickers = client.sticker_list("song", uri)
+ for sticker in stickers:
+ print sticker
+ if action == "find":
+ matches = client.sticker_find("song", uri, name)
+ for match in matches:
+ if "file" in match:
+ print match["file"]
+
+
+if __name__ == "__main__":
+ parser = OptionParser(usage="%prog action args", version="0.1",
+ description="Manipulate and query "
+ "MPD song stickers.")
+ options, args = parser.parse_args()
+
+ if len(args) < 1:
+ parser.error("no action specified")
+ action = args.pop(0)
+
+ if action not in ACTIONS:
+ parser.error("action must be one of: %s" % " ".join(ACTIONS))
+
+ if len(args) < 1:
+ parser.error("no URI specified")
+ uri = args.pop(0)
+
+ if action in ("get", "set", "delete", "find"):
+ if len(args) < 1:
+ parser.error("no name specified")
+ name = args.pop(0)
+ else:
+ name = None
+
+ if action == "set":
+ if len(args) < 1:
+ parser.error("no value specified")
+ value = args.pop(0)
+ else:
+ value = None
+
+ try:
+ main(action, uri, name, value)
+ except SocketError as e:
+ print >> stderr, "%s: error with connection to MPD: %s" % \
+ (parser.get_prog_name(), e[1])
+ except MPDError as e:
+ print >> stderr, "%s: error executing action: %s" % \
+ (parser.get_prog_name(), e)
+
+
+# vim: set expandtab shiftwidth=4 softtabstop=4 textwidth=79:
diff --git a/tpaste b/tpaste
new file mode 100755
index 0000000..9b74c95
--- a/dev/null
+++ b/tpaste
@@ -0,0 +1,7 @@
+#!/bin/zsh
+count=$(tmux show-buffer | wc -l)
+if [[ $count -gt 1 ]];then
+ return 0
+else
+ tmux paste-buffer
+fi
diff --git a/tux b/tux
index b19d126..3a5bdaf 100755
--- a/tux
+++ b/tux
@@ -35,6 +35,16 @@ if [[ $arg == "tnum" ]];then
echo -n $winum
+elif [[ $arg == "paste" ]];then
+ shift
+ count=$(tmux show-buffer | wc -l)
+ if [[ $count > 1 ]];then
+ exit 0
+ else
+ tmux paste-buffer
+ exit 1
+ fi
+
elif [[ $arg == "tfind" ]];then
shift
app=${1:?param}
diff --git a/wsync b/wsync
index 947f27a..dcfcece 100755
--- a/wsync
+++ b/wsync
@@ -1,6 +1,8 @@
#!/bin/zsh
mkdir -p /tmp/wsync
gproj=""
+projdir="/home/raghavendra/Arch/Projects"
+remotedir="/sate/gitole"
sproj=$1
trap logint INT
@@ -16,31 +18,43 @@ pread (){
echo -n ">_ "
read
}
-projdir="/home/raghavendra/Arch/Projects"
-remotedir="/sate/gitole"
-
-if [[ -n $sproj ]];then
- proj=$sproj
- pread "Syncing $proj"
+rpush(){
+ print "\n\n"
+ proj=$1
pushd $proj
+ projname=${proj:t}
if /bin/grep -q "Unnamed repo" .git/description;then
echo "Enter one line description"
>| .git/description
+ mkdir -p $remotedir/$proj:t/
cp .git/description $remotedir/$proj:t/
fi
+
if [[ ! -d $remotedir/$projname.git ]];then
git clone --mirror -v $proj /tmp/wsync/$projname.git
scp -q -r /tmp/wsync/$projname.git [email protected]:/$remotedir:t/
-
else
while ! gitprompt 2>/dev/null;do
+ echo
print "Dirty repo"
pread "Commit $proj and then continue"
+ git status
+ git add -A
+ git commit -v
done
- #git push --mirror -v $remotedir/$projname.git
git push --mirror -v ssh://[email protected]/$remotedir:t/$projname.git
fi
popd
+ print "=============================================================="
+ print "\n\n"
+}
+
+
+if [[ -n $sproj ]];then
+ proj=$sproj
+ proj="$HOME/Arch/Projects/$proj"
+ pread "Syncing $proj"
+ rpush $proj
echo "$proj done"
else
@@ -49,27 +63,7 @@ do
gproj="$proj"
projname=${proj:t}
echo "Syncing $proj"
- pushd $proj
- if /bin/grep -q "Unnamed repo" .git/description;then
- echo "Enter one line description"
- >| .git/description
- cp .git/description $remotedir/$proj:t/
- fi
- if [[ ! -d $remotedir/$projname.git ]];then
- git clone --mirror -v $proj /tmp/wsync/$projname.git
- scp -q -r /tmp/wsync/$projname.git [email protected]:/$remotedir:t/
-
- else
- if ! gitprompt 2>/dev/null;then
- print "Dirty repo"
- pread "Commit $proj and then continue"
- fi
- git status
- git add -A
- git commit
- git push --mirror -v ssh://[email protected]/$remotedir:t/$projname.git
- fi
- popd
+ rpush $proj
echo "$proj done"
done
fi