Re: Emergency terminal

xmonad-bounces:
The attached message has been automatically discarded. Date: Fri, 15 Feb 2008 08:45:01 +0200 From: Salvatore Iovene
To: xmonad@haskell.org Subject: Emergency terminal Hi all, sometimes I need to open a terminal window just for a quick task (i.e. quickly view an image). Using Mod+p and opening a dmenu is not really good for that (lack of good completation support) and I don't want to open a new terminal that will change the existing layout (not good on the eye).
The ideal solution would be having a special key that'd fire up a floating terminal on the bottom of the screen, only, say, 5 lines high, so you could quickly give your command without interfering with the existing layout.
Is there anything like this already around? Thanks!
There's been much talk about a 'scratchpad' terminal. This doesn't exist, but would be easy to implement as an extension -- just open up a terminal with a property set on it, then write a manageHook rule that looks for that property, and positions the window as floating, and with particular geometry. This would be a great extension to have, if someone would like to write it. -- Don

Don Stewart wrote:
xmonad-bounces:
The attached message has been automatically discarded. Date: Fri, 15 Feb 2008 08:45:01 +0200 From: Salvatore Iovene
To: xmonad@haskell.org Subject: Emergency terminal Hi all, sometimes I need to open a terminal window just for a quick task (i.e. quickly view an image). Using Mod+p and opening a dmenu is not really good for that (lack of good completation support) and I don't want to open a new terminal that will change the existing layout (not good on the eye).
The ideal solution would be having a special key that'd fire up a floating terminal on the bottom of the screen, only, say, 5 lines high, so you could quickly give your command without interfering with the existing layout.
Is there anything like this already around? Thanks!
There's been much talk about a 'scratchpad' terminal. This doesn't exist, but would be easy to implement as an extension -- just open up a terminal with a property set on it, then write a manageHook rule that looks for that property, and positions the window as floating, and with particular geometry.
This would be a great extension to have, if someone would like to write it.
-- Don
This will find its way onto the wiki and/or into Contrib eventually, but here's code and instructions for now. Add the following manageHook entry: title =? "scratchpad" --> doRectFloat scratchpadRect and the following functions doRectFloat :: W.RationalRect -> ManageHook doRectFloat r = ask >>= \w -> doF (W.float w r) scratchpadRect :: W.RationalRect scratchpadRect = W.RationalRect 0.25 0.375 0.5 0.25 and the following keys entry: (( modMask, xK_s ), unsafeSpawn $ terminal conf ++ " -title scratchpad") to your xmonad.hs. This assumes you have StackSet imported as W. If you don't, you'll have to change the qualifier (or remove it) as necessary. If you use urxvt, rxvt or xterm, they support the -title parameter. Most others probably will as well, following xterm's lead. Then mod+s should spawn a floating terminal window in the center of the active workspace, half-screen wide and quarter-screen tall. This sizing and position can be customized by modifying scratchpadRect. I'm still learning Haskell, and just getting my feet wet hacking xmonad. I learned a good bit doing this, and I'm also going to keep this live in my config; it's really handy. I'm not sure how easily this could be bundled into a contrib package. It seems like it might be better just as an example minimal config for others to merge with their own. I'm willing to package it up, but I don't have any experience sending darcs patches or uploading to hackage yet. Though I suppose I have to learn some time. Advice on whether this is better submitted as a contrib patch or a wiki entry is most welcome, as are critiques of my code (it seems like my doRectFloat should exist in contrib already somewhere, this can't be the first time someone's wanted that feature). Braden Shepherdson shepheb

On Fri, Feb 15, 2008 at 11:02 PM, Braden Shepherdson < Braden.Shepherdson@gmail.com> wrote:
Don Stewart wrote:
xmonad-bounces:
The attached message has been automatically discarded. Date: Fri, 15 Feb 2008 08:45:01 +0200 From: Salvatore Iovene
To: xmonad@haskell.org Subject: Emergency terminal Hi all, sometimes I need to open a terminal window just for a quick task (i.e. quickly view an image). Using Mod+p and opening a dmenu is not really good for that (lack of good completation support) and I don't want to open a new terminal that will change the existing layout (not good on the eye).
The ideal solution would be having a special key that'd fire up a floating terminal on the bottom of the screen, only, say, 5 lines high, so you could quickly give your command without interfering with the existing layout.
Is there anything like this already around? Thanks!
There's been much talk about a 'scratchpad' terminal. This doesn't exist, but would be easy to implement as an extension -- just open up a terminal with a property set on it, then write a manageHook rule that looks for that property, and positions the window as floating, and with particular geometry.
This would be a great extension to have, if someone would like to write it.
-- Don
This will find its way onto the wiki and/or into Contrib eventually, but here's code and instructions for now.
This is great! If you're up to it, please package this as a contrib module, probably in XMonad.Util. If you're not sure how to do that, or need any help just send an e-mail or ask in the #xmonad channel on irc.freenode.net. This should definitely go in the xmonad-contrib library as opposed to on the wiki.
Add the following manageHook entry:
title =? "scratchpad" --> doRectFloat scratchpadRect
You could give this rule a name like 'manageScratchpad' (maybe two versions, one with a default rectangle and one that takes the rectangle as a parameter) so users could just drop that into their manageHook.
and the following functions
doRectFloat :: W.RationalRect -> ManageHook doRectFloat r = ask >>= \w -> doF (W.float w r)
scratchpadRect :: W.RationalRect scratchpadRect = W.RationalRect 0.25 0.375 0.5 0.25
doRectFloat should perhaps eventually go into ManageHook in the core, but for now I think it's fine to put it in a contrib module.
and the following keys entry:
(( modMask, xK_s ), unsafeSpawn $ terminal conf ++ " -title scratchpad")
Again, you could define a function that performs this spawn and export it from the contrib module, so users can just drop it into their keybindings list with minimal effort.
I'm not sure how easily this could be bundled into a contrib package. It seems like it might be better just as an example minimal config for others to merge with their own. I'm willing to package it up, but I don't have any experience sending darcs patches or uploading to hackage yet.
No uploading to hackage necessary here! =) Just make sure you have the latest darcs sources (instructions for getting them are on xmonad.org; to get the latest patches just do a 'darcs pull'). Once you've made the changes you'd like, do a 'darcs add' to add any new files you created to the repository, then do 'darcs record' to record your changes into a patch. Finally, 'darcs send' will send your patch to the mailing list (if you have a mail agent configured correctly to do this; otherwise you can just do 'darcs send -o /path/to/some/file.dpatch' and then manually attach the generated file to a message to the list. Again, if you need any help, don't hesitate to ask! as are critiques of my code (it seems like my
doRectFloat should exist in contrib already somewhere, this can't be the first time someone's wanted that feature).
The code looks great. And you'd be surprised how many obvious, simple, yet really nice features there are that no one's thought of or wanted yet. =) -Brent

OK, I set this up. It's pretty cool. Thanks for figuring out how. But I wish it worked more like the Ion scratchpad. In that one, the floating rectangle was permanent, and the hotkey just switched to it. I'm trying to use the scratchpad to do 'vim ~/TODO' and it's a little troublesome because the hotkey starts another one rather than just causing the existing one appear.

On Wed, Feb 20, 2008 at 03:45:32PM +0800, brian wrote:
OK, I set this up. It's pretty cool. Thanks for figuring out how.
But I wish it worked more like the Ion scratchpad. In that one, the floating rectangle was permanent, and the hotkey just switched to it. I'm trying to use the scratchpad to do 'vim ~/TODO' and it's a little troublesome because the hotkey starts another one rather than just causing the existing one appear.
Hmm, perhaps combine this with the new "run or raise" contrib?

On Feb 20, 2008 5:06 PM, Spencer Janssen
On Wed, Feb 20, 2008 at 03:45:32PM +0800, brian wrote:
But I wish it worked more like the Ion scratchpad. In that one, the floating rectangle was permanent, and the hotkey just switched to it. I'm trying to use the scratchpad to do 'vim ~/TODO' and it's a little troublesome because the hotkey starts another one rather than just causing the existing one appear.
Hmm, perhaps combine this with the new "run or raise" contrib?
OK, I did all the usual stuff except runOrRaise (XMonad.terminal conf ++ " -title todo -e vim -X ~/TODO") (title =? "todo")) That's pretty cool, but it switches focus to the scratchpad as opposed to bringing it to me. Still, progress.

On Wed, Feb 20, 2008 at 1:11 PM, brian
On Feb 20, 2008 5:06 PM, Spencer Janssen
wrote: On Wed, Feb 20, 2008 at 03:45:32PM +0800, brian wrote:
But I wish it worked more like the Ion scratchpad. In that one, the floating rectangle was permanent, and the hotkey just switched to it. I'm trying to use the scratchpad to do 'vim ~/TODO' and it's a little troublesome because the hotkey starts another one rather than just causing the existing one appear.
Hmm, perhaps combine this with the new "run or raise" contrib?
OK, I did all the usual stuff except runOrRaise (XMonad.terminal conf ++ " -title todo -e vim -X ~/TODO") (title =? "todo"))
That's pretty cool, but it switches focus to the scratchpad as opposed to bringing it to me. Still, progress.
It should be possible to bring the window to you. Check out XMonad.Actions.WindowBringer -- it doesn't do what you want, but perhaps it will give you some ideas. Even better, it should probably be refactored to provide some more fundamental operations (there are actions to create a menu from which you can choose a window name to be brought to you -- but no simple function which, given a window name, will bring it to you). -Brent

On Thu, Feb 21, 2008 at 02:11:44AM +0800, brian wrote:
On Feb 20, 2008 5:06 PM, Spencer Janssen
wrote: On Wed, Feb 20, 2008 at 03:45:32PM +0800, brian wrote:
But I wish it worked more like the Ion scratchpad. In that one, the floating rectangle was permanent, and the hotkey just switched to it. I'm trying to use the scratchpad to do 'vim ~/TODO' and it's a little troublesome because the hotkey starts another one rather than just causing the existing one appear.
Hmm, perhaps combine this with the new "run or raise" contrib?
OK, I did all the usual stuff except runOrRaise (XMonad.terminal conf ++ " -title todo -e vim -X ~/TODO") (title =? "todo"))
That's pretty cool, but it switches focus to the scratchpad as opposed to bringing it to me. Still, progress.
So I think the best thing to do is to add some flexibility to WindowGo. We can split out the window location code into a separate function: locateWindow :: Query Bool -> X (Maybe Window) Then we can combine this location function with other user routines. Cheers, Spencer Janssen
participants (5)
-
Braden Shepherdson
-
Brent Yorgey
-
brian
-
Don Stewart
-
Spencer Janssen