exiting: asking for confirmation (or a four-key combination)

Dear All, Occasionally, I do something silly and by mistake type modMask + shift + q and xmonad, as it should, immediately exits. When done accidentally, this is a pain. So: a) is there a way to get xmonad to ask for confirmation to exit? b) alternatively, can I define four (of five) key combinations, so I need to do something really contrived to exit? I've searched both answers without success, and my attempts at four-key combinations have not worked (even if I get xmonad --recompile to run). Thanks, R. -- Ramon Diaz-Uriarte Department of Biochemistry, Lab B-25. Facultad de Medicina (UAM) Arzobispo Morcillo, 2 28029 Madrid Spain Phone: +34-91-497-2412 Email: rdiaz02@gmail.com ramon.diaz@iib.uam.es http://ligarto.org/rdiaz

On Thu, Nov 10, 2011 at 08:06, Ramon Diaz-Uriarte
b) alternatively, can I define four (of five) key combinations, so I need to do something really contrived to exit?
You'll find XMonad.Actions.Submap helps with this. EZConfig makes it even easier; you can bind to e.g. "M-Sh-quit<Return>" (that's mod+shift+"quit"+return key). -- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms

How about this?
import Control.Monad
import System.Exit
import XMonad.Util.Run
promptExit = do
response <- runProcessWithInput "dmenu" ["-p", "Really quit?"] "yes\nno\n"
when (response == "yes") (io (exitWith ExitSuccess))
Then you can add a keybinding like ((modMask, xK_q), promptExit). You
might also look into XMonad.Prompt; somebody who's a bit more expert
in that module can probably suggest how to do the analogous thing.
~d
Quoting Ramon Diaz-Uriarte
Dear All,
Occasionally, I do something silly and by mistake type
modMask + shift + q
and xmonad, as it should, immediately exits. When done accidentally, this is a pain. So:
a) is there a way to get xmonad to ask for confirmation to exit?
b) alternatively, can I define four (of five) key combinations, so I need to do something really contrived to exit?
I've searched both answers without success, and my attempts at four-key combinations have not worked (even if I get xmonad --recompile to run).
Thanks,
R. -- Ramon Diaz-Uriarte Department of Biochemistry, Lab B-25. Facultad de Medicina (UAM) Arzobispo Morcillo, 2 28029 Madrid Spain
Phone: +34-91-497-2412
Email: rdiaz02@gmail.com ramon.diaz@iib.uam.es
_______________________________________________ xmonad mailing list xmonad@haskell.org http://www.haskell.org/mailman/listinfo/xmonad

Thanks to both Daniel Wagner and Brandon Allbery for their suggestions. I've ended up using Daniel's one because it seemed more similar to what I was thinking. I only changed the order of "yes\nno\n", to make the default be "no" since I very, very rarely exit xmonad (on purpose). Best, R. On Thu, 10 Nov 2011 14:45:55 -0500,wagnerdm@seas.upenn.edu wrote:
How about this?
import Control.Monad import System.Exit import XMonad.Util.Run
promptExit = do response <- runProcessWithInput "dmenu" ["-p", "Really quit?"] "yes\nno\n" when (response == "yes") (io (exitWith ExitSuccess))
Then you can add a keybinding like ((modMask, xK_q), promptExit). You might also look into XMonad.Prompt; somebody who's a bit more expert in that module can probably suggest how to do the analogous thing.
~d
Quoting Ramon Diaz-Uriarte
:
Dear All,
Occasionally, I do something silly and by mistake type
modMask + shift + q
and xmonad, as it should, immediately exits. When done accidentally, this is a pain. So:
a) is there a way to get xmonad to ask for confirmation to exit?
b) alternatively, can I define four (of five) key combinations, so I need to do something really contrived to exit?
I've searched both answers without success, and my attempts at four-key combinations have not worked (even if I get xmonad --recompile to run).
Thanks,
R. -- Ramon Diaz-Uriarte Department of Biochemistry, Lab B-25. Facultad de Medicina (UAM) Arzobispo Morcillo, 2 28029 Madrid Spain
Phone: +34-91-497-2412
Email: rdiaz02@gmail.com ramon.diaz@iib.uam.es
_______________________________________________ xmonad mailing list xmonad@haskell.org http://www.haskell.org/mailman/listinfo/xmonad
_______________________________________________ xmonad mailing list xmonad@haskell.org http://www.haskell.org/mailman/listinfo/xmonad -- Ramon Diaz-Uriarte Department of Biochemistry, Lab B-25. Facultad de Medicina (UAM) Arzobispo Morcillo, 4 28029 Madrid Spain
Phone: +34-91-497-2412 Email: rdiaz02@gmail.com ramon.diaz@iib.uam.es http://ligarto.org/rdiaz

On Sat, Nov 12, 2011 at 08:43, Ramon Diaz-Uriarte
Thanks to both Daniel Wagner and Brandon Allbery for their suggestions.
I've ended up using Daniel's one because it seemed more similar to what I was thinking. I only changed the order of "yes\nno\n", to make the default be "no" since I very, very rarely exit xmonad (on purpose).
Daniel's solution has the potential for problems, because xmonad's main loop isn't processing events while it's running. (This is a common problem with most of the contrib functions that process input; they really need to do their input handling in the handleEventHook instead of opening a new connection to the X server. For those who keep track of such things, the possible failure mode is the same as with the infamous putSelection.) -- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms

Thanks. I wasn't at all aware of that. I'll use the solution you suggested
then.
R.
On Sat, 12 Nov 2011 11:47:24 -0500,Brandon Allbery
On Sat, Nov 12, 2011 at 08:43, Ramon Diaz-Uriarte
wrote:
Thanks to both Daniel Wagner and Brandon Allbery for their suggestions.
I've ended up using Daniel's one because it seemed more similar to what I was thinking. I only changed the order of "yes\nno\n", to make the default be "no" since I very, very rarely exit xmonad (on purpose).
Daniel's solution has the potential for problems, because xmonad's main loop isn't processing events while it's running. (This is a common problem with most of the contrib functions that process input; they really need to do their input handling in the handleEventHook instead of opening a new connection to the X server. For those who keep track of such things, the possible failure mode is the same as with the infamous putSelection.)
-- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms -- Ramon Diaz-Uriarte Department of Biochemistry, Lab B-25. Facultad de Medicina (UAM) Arzobispo Morcillo, 4 28029 Madrid Spain
Phone: +34-91-497-2412 Email: rdiaz02@gmail.com ramon.diaz@iib.uam.es http://ligarto.org/rdiaz
participants (3)
-
Brandon Allbery
-
Ramon Diaz-Uriarte
-
wagnerdm@seas.upenn.edu