Confirmation dialog for xkill with Zenity

Other talk about Salix
Post Reply
User avatar
zAchAry
Posts: 804
Joined: 11. May 2010, 09:02
Location: Israel

Confirmation dialog for xkill with Zenity

Post 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?
Image
Help to make Slackware easier Donate to Salix
Shador
Posts: 1295
Joined: 11. Jun 2009, 14:04
Location: Bavaria

Re: Confirmation dialog for xkill with Zenity

Post 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.
Image
User avatar
zAchAry
Posts: 804
Joined: 11. May 2010, 09:02
Location: Israel

Re: Confirmation dialog for xkill with Zenity

Post by zAchAry »

Thank you so much :)

Also linuxquestions.org (Zenity + kill PID)
Image
Help to make Slackware easier Donate to Salix
User avatar
thenktor
Salix Wizard
Posts: 2426
Joined: 6. Jun 2009, 14:47
Location: Franconia
Contact:

Re: Confirmation dialog for xkill with Zenity

Post 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?
Image
burnCDDA (burns audio CDs)
geBIERt (German beer blog)
User avatar
zAchAry
Posts: 804
Joined: 11. May 2010, 09:02
Location: Israel

Re: Confirmation dialog for xkill with Zenity

Post 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.
Image
Help to make Slackware easier Donate to Salix
Post Reply