I want to write a shutdown menu for XMonad, and bind it to a key combo.
So the ingredients seem to be these following.
- A command, so a
String, that can be executed in a shell to open the menu. The user than chooses what to do (e.g. Suspend, Shutdown, ...), and the output of that executable will be aStringas well, call itchoice. - Then I'd have a pure
String -> Stringfunctionfto map the user decision to the command to run. - Finally I'd have to execute that
f choice :: Stringwhich woud have no output.
And this whole thing should be done by XMonad, so I assume I would have to add ("M-r", shutdownmenu) to the mappings I pass to def `additionalKeysP` mappings. That shutdownmenu function is the one that should perform the steps above.
But to do that, I'd need, I believe,
- a
String -> X Stringfunction to launch the program that asks the user to choose what to do; I though I would find something inXMonad.Util.Run, but no function there seems to have the signature and semantics that I need, - the
String -> Stringfunction, which is the easy thing, - the
String -> X ()function, for whichspawnseems to fit the bill.
What I don't find is the first of these ingredients, getCommandOutput looks similar to what I need, but it retuns in the IO moand instead of in the X monad or a generic monad m, so I can't really do much with it in the X monad.
Or can I?