#!/bin/sh 
export LD_LIBRARY_PATH=/mnt/us/extensions/yad/usr/lib:$LD_LIBRARY_PATH
cd /mnt/us/extensions/yad/usr/bin
export XDG_DATA_HOME=/mnt/us/extensions/yad/pixmaps 
export XDG_CACHE_HOME=/mnt/us/extensions 
export GTK2_RC_FILES=/mnt/us/extensions/yad/pixmaps/gtkrc 
export GDK_PIXBUF_MODULE_FILE=/mnt/us/extensions/yad/usr/lib/gtk-2.0/2.10.0/loaders.cache 
		PLATFORM="$(cat /sys/devices/platform/mxc_epdc_fb/graphics/fb0/modes)"

#2 for landscape 1 for potrait
ROTATION=$(cat /sys/devices/platform/mxc_epdc_fb/graphics/fb0/modes | sed -e 's/.*x\([^"]*\)p.*/\1/' | grep -v `cat /sys/devices/platform/mxc_epdc_fb/graphics/fb0/stride` | wc -l)
WIDE=$(cat /sys/devices/platform/mxc_epdc_fb/graphics/fb0/stride)

if [ ${ROTATION} -eq 1 ]; then
	HIGH=$(cat /sys/devices/platform/mxc_epdc_fb/graphics/fb0/modes | tail -1 | tr -d "U:" | sed 's/p-0//' | sed "s/${WIDE}//" | sed 's/x//')
else 
	HIGH=$(cat /sys/devices/platform/mxc_epdc_fb/graphics/fb0/modes | sed -e 's/.*x\([^"]*\)p.*/\1/' | head -1)
fi

process=`ps -A | sed 's/sh -c lipc-send-event com.lab126.system.event ; sh -c /LAUNCHER: /g'  | awk '{print $1"  "$4" "$5" "$6" "$7" "$8" "$9}'  | \
grep -v 'sirq-\|framework\|init.exe\|mxc_spi\|kmmcd\|pillowd -f\|dbus-daemon\|pmic-event\|pdflush\|kthreadd\|posixcputmr\|watchdog\|desched\|events\|khelper\|async/mgr\|kblockd/0\|zq_calib\|loop0\|loop2\|otaupd\|tmd\|lipc-daemon\|phd\|cmd\|todo\|vlumd\|powerd\|appmgrd\|archive\|fsp\|dynconfig\|dpmd\|kjournald\|wifid\|lxinit\|cvm\|pmond\|acxmgrd\|scanner-main\|blanket\|parselog\|sftp-server\|udevd\|ksdioirqd\|wpa_supplicant\|web-reader\|process\|-sh\|yad\|EPDC\|syslog-ng\|crond\|exe\|loop3\|loop4\|loop5\|loop6\|loop7\|volumd\|mmcqd\|khungtaskd\|aio/0\|unionfs_siod\|nfsiod\|crypto/0\|kondemand/0\|kconservative/0\|esdhc_wq/0\|webreader\|AR6K\|kswapd0' \
| ./yad --list --title="L:D_N:dialog_ID:Kill.Process_M:true" --window-icon="process-stop" --buttons-layout=center --column "Please select a process to kill:" --text="List all $USER processes:" --width ${WIDE} --height ${HIGH}` 

ans=`echo $?` 

   if test "$ans" -eq "0" ; 
   then 

      select=`echo $process | cut -d" " -f1` 

      kill $select 
         ans1=`echo $?` 
         if [ "$ans1" == "0" ] ; 
         then 
         select1=`echo $process | cut -d":" -f3  | cut -d" " -f2` 
          echo | ./yad --fixed --timeout="5" --title="L:D_N:dialog_ID:Kill.Process_M:true" --window-icon="process-stop" --buttons-layout=center --button="gtk-ok:0" --text-align="center" --borders="30" \
          --text="<big><big><b>${select1%|*}</b></big></big><big><b> was killed!</b></big>" 
         else 
          echo | ./yad --fixed --timeout="5" --title="L:D_N:dialog_ID:Kill.Process_M:true" --window-icon="process-stop" --buttons-layout=center --button="gtk-ok:0" --text-align="center" --borders="30" \
          --text="<big><big><b>Process</b></big></big><big><b> not found!</b></big>" 
         fi 
   exit 0 
    fi 
  
   if test "$ans" -eq "1" ; 
   then 
   exit 0 
   fi
