script is not perfect and may need your customization. It was written so you can end programs and power off your system from terminal
requrements:xvkbd ~6mb
code (add programs running on your system):
(ps ax | grep -v grep | grep transmission) #check if transmission is running if [ "$?" -eq 0 ]; then b=$(xwininfo -name Transmission | grep Window\ id:\ | awk '{print $4}') #get programs window id xvkbd -xsendevent -window $b -text "\Cq" #send keystroke to quit program fi sleep 1 #set firefox title to normal firefox about:blank sleep 1 (ps ax | grep -v grep | grep gnumeric) if [ "$?" -eq 0 ]; then b=$(xwininfo -name Book1.gnumeric\ :\ Gnumeric | grep Window\ id:\ | awk '{print $4}') xvkbd -xsendevent -window $b -text "\Cq" fi (ps ax | grep -v grep | grep nicotine) if [ "$?" -eq 0 ]; then b=$(xwininfo -name Nicotine+\ 1.2.9 | grep Window\ id:\ | awk '{print $4}') xvkbd -xsendevent -window $b -text "\Cq" fi sleep 1 (ps ax | grep -v grep | grep firefox) if [ "$?" -eq 0 ]; then echo firefox running, now trying to end #(using different character c) c=$(xwininfo -name Mozilla\ Firefox | grep Window\ id:\ | awk '{print $4}') xvkbd -xsendevent -window $c -text "\Cw"; sleep 1 xvkbd -xsendevent -window $c -text "\Cq"; fi df xvkbd -xsendevent -window $c -text "\Av"; (ps ax | grep -v grep | grep linuxdcpp) if [ "$?" -eq 0 ]; then b=$(xwininfo -name LinuxDC++ | grep Window\ id:\ | awk '{print $4}') xvkbd -xsendevent -window $b -text "\Cq" fi (ps ax | grep -v grep | grep vlc) if [ "$?" -eq 0 ]; then b=$(xwininfo -name VLC\ media\ player | grep Window\ id:\ | awk '{print $4}') xvkbd -xsendevent -window $b -text "\Cq" fi #send once again commands to firefox in case it wasnt running xvkbd -xsendevent -window $c -text "\Cw"; xvkbd -xsendevent -window $c -text "\Cq"; (ps ax | grep -v grep | grep transmission) if [ "$?" -eq 1 ]; then echo transmission now off, poweroff? #last resort to end firefox killall firefox sudo shutdown -P now fi
article will be updated as donation recievedrequrements:xvkbd ~6mb
code (add programs running on your system):
(ps ax | grep -v grep | grep transmission) #check if transmission is running if [ "$?" -eq 0 ]; then b=$(xwininfo -name Transmission | grep Window\ id:\ | awk '{print $4}') #get programs window id xvkbd -xsendevent -window $b -text "\Cq" #send keystroke to quit program fi sleep 1 #set firefox title to normal firefox about:blank sleep 1 (ps ax | grep -v grep | grep gnumeric) if [ "$?" -eq 0 ]; then b=$(xwininfo -name Book1.gnumeric\ :\ Gnumeric | grep Window\ id:\ | awk '{print $4}') xvkbd -xsendevent -window $b -text "\Cq" fi (ps ax | grep -v grep | grep nicotine) if [ "$?" -eq 0 ]; then b=$(xwininfo -name Nicotine+\ 1.2.9 | grep Window\ id:\ | awk '{print $4}') xvkbd -xsendevent -window $b -text "\Cq" fi sleep 1 (ps ax | grep -v grep | grep firefox) if [ "$?" -eq 0 ]; then echo firefox running, now trying to end #(using different character c) c=$(xwininfo -name Mozilla\ Firefox | grep Window\ id:\ | awk '{print $4}') xvkbd -xsendevent -window $c -text "\Cw"; sleep 1 xvkbd -xsendevent -window $c -text "\Cq"; fi df xvkbd -xsendevent -window $c -text "\Av"; (ps ax | grep -v grep | grep linuxdcpp) if [ "$?" -eq 0 ]; then b=$(xwininfo -name LinuxDC++ | grep Window\ id:\ | awk '{print $4}') xvkbd -xsendevent -window $b -text "\Cq" fi (ps ax | grep -v grep | grep vlc) if [ "$?" -eq 0 ]; then b=$(xwininfo -name VLC\ media\ player | grep Window\ id:\ | awk '{print $4}') xvkbd -xsendevent -window $b -text "\Cq" fi #send once again commands to firefox in case it wasnt running xvkbd -xsendevent -window $c -text "\Cw"; xvkbd -xsendevent -window $c -text "\Cq"; (ps ax | grep -v grep | grep transmission) if [ "$?" -eq 1 ]; then echo transmission now off, poweroff? #last resort to end firefox killall firefox sudo shutdown -P now fi
0 comments:
Post a Comment