You are not logged in.
Pages: 1
Topic closed
Is there a way to focus a window when it is spawned/shifted to a workspace in xmonad? For example, I shift my firefox instances to the "web" workspace, but the focus/view remains on the current workspace.
Last edited by Nepherte (2009-03-05 20:13:00)
Offline
You want a keybinding that shifts a window to a workspace, and then focuses the workspace?
-- other keybindings above here
++
[((m .|. modm, k), windows $ f i)
| (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)
, (\i -> W.greedyView i . W.shift i, controlMask)]]
That probably isn't what you want (it moves the focused window to that workspace, and then focuses the same workspace).
Instead of manually moving windows to specific workspace you probably should be using a manageHook.
Offline
It's not really what I was looking for indeed but it comes close. I already use the manageHook to match ClassNames and whatsoever to open applications in a workspace. But if I open firefox from workspace a, manageHook will put firefox in workspace b as defined by the managehook, but the focus remains in workspace a. I want it to focus the just opened firefox in workspace b. I hope I made myself clear.
Offline
I'm not much of a Haskell coder but I think I know what you're saying, if I understand correctly you want to change something like ", className =? "Gran Paradiso" --> doShift "2:www"" so that it switches to the "2:www" workspace aswell? Are there any resident Haskell/Xmonad experts on this board who can help out with this? I assume it should be almost as simple as adding an extra couple of statements to that line, and I would appreciate this functionality aswell.
Offline
That's exactly what I want
Offline
I think it's better to keep the workspace-switching in the keybinding. If you run a few of the applications on startup, you'll be jumping around like crazy. I'm not really an expert, but this function should do it:
startFocus command workspace = do
spawn command
windows $ W.greedyView workspace
So, for example, to run Firefox and switch to "2:www", bind startFocus "firefox" "2:www" to the key(s) you want. This creates duplication (you have Firefox and 2:www together in both the hook and in the keybinding), so you may want to move these app-workspace pairs into a list.
I tried to get the "move-focus" to work in tha manage hook, but it always dies with a type error.
Fixed code indenting.
Last edited by abesto (2009-03-06 05:18:03)
Linux user #476135 || Dotfiles hosted by GitHub
Offline
W.greedyView seems to do the trick. Any idea how I can combine it in my manageHook so it does both W.shift "web" and W.greedyView "web"? Here's a part of my manageHook
-- Define the workspace an application has to go to
myManageHook = composeAll . concat $
[ -- The applications that go to web
[ className =? b --> doF (W.shift "web" ) | b <- myClassWebShifts]
Offline
Here's a way to do it:
className =? b --> doF (W.shift "web") <+> doF (W.greedyview "web") | b <- myClassWebShifts]
Offline
Thanks, I just figured it out before you posted. Unfortunately it doesn't give the wanted behaviour What it does is leave myClassWebShifts unshifted and switches to workspace "web".
Offline
A somewhat hacky approach: create two managehooks - one with the shift, and the other with the greedyView function. Then do something like this:
newManageHook = myShiftHook <+> myViewHook <+> manageHook defaultConfig
Linux user #476135 || Dotfiles hosted by GitHub
Offline
Unfortunately that doesn't work either. Again, it leaves myClassWebShifts unshifted and it switches to workspace "web". I guess I'll just leave it at that, manually switching to the workspace. I used to resolve this issue by using devilspie back in the days when I used gnome + xmonad. Now that I use xmonad only, I'll have to leave it be since devilspie only works with gnome unless someone comes up with another solution
Offline
Hello,
, ((0, xK_f), (windows $ W.greedyView "web") >> spawn "firefox")
The above line focuses the "web" workspace and opens firefox in this particular workspace.
Was it what you want?
Offline
A few hours of looking for this my self and I finally discovered http://www.haskell.org/haskellwiki/Xmon … onfig_tips which contains the answer.
The following will put new FocusMeNow windows on the "doc" workspace and also greedily view that workspace.
import Control.Monad (liftM2) myManageHook = composeAll [ className = "FocusMeNow" --> viewShift "doc" -- more hooks ] where viewShift = doF . liftM2 (.) W.greedyView W.shift
This works just fine for me. I hope it is of some help to you.
Ben.
Offline
Thanks for the solution Ben, but I doubt that the op is still looking for an answer considering that the last post in the thread was over a year ago. Your solution will probably help someone else looking for it.
Closing...
There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !
Offline
Pages: 1
Topic closed