Page 1 of 1

Confirmation dialog for xkill with Zenity

Posted: 17. Feb 2011, 12:47
by zAchAry
Please DO NOT dedicate more than 1 minute on this post, it is really not worth the trouble


Do you know the GNOME Panel applet that is terminating running applications after clicking on them with the cursor and confirming the action with a Yes/No dialogue?

I know about xkill, but it is not satisfying due to it has not confirmation dialogue.

Instead, I would like to use xprop and kill and zenity

Here's what I have accomplished thus far:

PID_NUMBER

Code: Select all

xprop|grep "PID"|sed "s/[^0-9]//g"
APPLICATION_NAME

Code: Select all

xprop|grep "WM_CLASS"|cut -d \" -f 2
It should do something like this:

Code: Select all

zenity --question --text "Are you sure you want to terminate <APPLICATION_NAME>?"; kill pid <PID_NUMBER>
Any solutions?

Re: Confirmation dialog for xkill with Zenity

Posted: 17. Feb 2011, 15:37
by Shador

Code: Select all

blub=$(xprop | egrep 'PID|WM_CLASS' | sed -e 's/.* \([^\s]*\)$/\1/')
pid=$(echo ${blub} | cut -f1 -d ' ')
name=$(echo ${blub} | cut -f2- -d ' ')
zenity --question --text "Are you sure you want to terminate ${name}?" && kill pid ${pid}
Edit: Very unclean, but works here. You might consider building a simple parser with "xprop | egrep 'PID|WM_CLASS' | while read line; do ...; done" to support whitespaces in the app name and alternating pid/wm_class order.

Re: Confirmation dialog for xkill with Zenity

Posted: 17. Feb 2011, 21:13
by zAchAry
Thank you so much :)

Also linuxquestions.org (Zenity + kill PID)

Re: Confirmation dialog for xkill with Zenity

Posted: 18. Feb 2011, 07:56
by thenktor
Wasn't there a keyboard shortcut defined in xorg to start xkill? Or do I have to set one on my own in my window manager?

Re: Confirmation dialog for xkill with Zenity

Posted: 21. Feb 2011, 20:14
by zAchAry
@thenktor
It has been there in older versions (according to some websites...) but now it was removed for some reason, you have to set it for your own as it seems.