Fwd: How to use onScreen function on startup?

---------- Forwarded message ----------
From: kevind256

Hi, I'm not that familiar with haskell or xmonad, but I can tell you how I do that :) -- Hooks -- manageHook' :: ManageHook manageHook' = composeAll .concat $ [ --app placement [ className =? c --> doF (W.shift "2-web") | c <- webApps ] , [ className =? c --> doF (W.shift "3-mail") | c <- mailApps ] , [ resource =? c --> doF (W.shift "4-multimedia") | c <- multimediaApps ] , [ className =? c --> doF (W.shift "5-IM") | c <- imApps ] , [ className =? c --> doF (W.shift "6-windows") | c <- windowsApps ] ] webApps = ["Opera"] mailApps = ["Claws-mail", "mutt"] multimediaApps = ["mocp"] windowsApps = ["VirtualBox"] imApps = ["Skype"] I think that isn't that hard to understand :) "W" comes from "import qualified XMonad.StackSet as W" Then just load that ManageHook in your main. If you have any further question feel free to ask. Felix On 12. December 2010 - 09:34, kevind256 wrote:
Date: Sun, 12 Dec 2010 09:34:46 +0300 From: kevind256
To: xmonad@haskell.org Subject: [xmonad] Fwd: How to use onScreen function on startup? ---------- Forwarded message ---------- From: kevind256
Date: Sat, 11 Dec 2010 13:37:55 +0300 Subject: How to use onScreen function on startup? To: xmonad@haskell.org Hi,
Sorry to ask question out of total lack of knowledge of Haskell, but how do I use a function (in this case onScreen from XMonad.Actions.OnScreen) at xmonad startup? I's like to assign the last workspace to second screen by default, since it's really secondary in my setup (music player is there usually).
I tried putting this in main = do { ... } section: onScreen 1 "9";
but got this long error message (till end of this post): Error detected while loading xmonad configuration file: /home/kevin/.xmonad/xmonad.hs
xmonad.hs:30:1: Couldn't match expected type `IO a' against inferred type `i -> XMonad.StackSet.StackSet i l a1 [Char] sd -> XMonad.StackSet.StackSet i l a1 [Char] sd' In a stmt of a 'do' expression: onScreen 1 "9" In the expression: do { xmproc <- spawnPipe "xmobar"; onScreen 1 "9"; xmonad $ defaultConfig {normalBorderColor = "black", focusedBorderColor = "red2", borderWidth = 2, modMask = modm, focusFollowsMouse = False, manageHook = manageDocks <+> manageHook defaultConfig, layoutHook = avoidStruts $ simpleTabbed ||| Tall 1 5.0e-2 0.5, logHook = dynamicLogWithPP $ xmobarPP {ppOutput = hPutStrLn xmproc, ppTitle = xmobarColor "white" "" . shorten 100}} `additionalKeys` [((modm, xK_a), spawn "aumix -v-2"), ((modm, xK_f), spawn "aumix -v+2"), ....] } In the definition of `main': main = do { xmproc <- spawnPipe "xmobar"; onScreen 1 "9"; xmonad $ defaultConfig {normalBorderColor = "black", focusedBorderColor = "red2", borderWidth = 2, modMask = modm, focusFollowsMouse = False, manageHook = manageDocks <+> manageHook defaultConfig, layoutHook = avoidStruts $ simpleTabbed ||| Tall 1 5.0e-2 0.5, logHook = dynamicLogWithPP $ xmobarPP {ppOutput = hPutStrLn xmproc, ppTitle = xmobarColor "white" "" . shorten 100}} `additionalKeys` [((modm, xK_a), spawn "aumix -v-2"), ....] }
Please check the file for errors.
_______________________________________________ xmonad mailing list xmonad@haskell.org http://www.haskell.org/mailman/listinfo/xmonad ---end quoted text---

As far as I understand it, you're shifting windows to different
workspaces upon these applications' startup. What I wanted is to
assign a workspace to a screen at xmonad's startup. So I do not see
connection between this and your example. ManageHook (apparently)
isn't used at xmonad startup, instead just 'main' is called, but
something's wrong with my understanding of this all. Thank you for
responce anyway.
On 12/12/10, Felix Blanke
Hi,
I'm not that familiar with haskell or xmonad, but I can tell you how I do that :)
-- Hooks -- manageHook' :: ManageHook manageHook' = composeAll .concat $ [ --app placement [ className =? c --> doF (W.shift "2-web") | c <- webApps ] , [ className =? c --> doF (W.shift "3-mail") | c <- mailApps ] , [ resource =? c --> doF (W.shift "4-multimedia") | c <- multimediaApps ] , [ className =? c --> doF (W.shift "5-IM") | c <- imApps ] , [ className =? c --> doF (W.shift "6-windows") | c <- windowsApps ] ]
webApps = ["Opera"] mailApps = ["Claws-mail", "mutt"] multimediaApps = ["mocp"] windowsApps = ["VirtualBox"] imApps = ["Skype"]
I think that isn't that hard to understand :)
"W" comes from "import qualified XMonad.StackSet as W"
Then just load that ManageHook in your main.
If you have any further question feel free to ask.
Felix
On 12. December 2010 - 09:34, kevind256 wrote:
Date: Sun, 12 Dec 2010 09:34:46 +0300 From: kevind256
To: xmonad@haskell.org Subject: [xmonad] Fwd: How to use onScreen function on startup? ---------- Forwarded message ---------- From: kevind256
Date: Sat, 11 Dec 2010 13:37:55 +0300 Subject: How to use onScreen function on startup? To: xmonad@haskell.org Hi,
Sorry to ask question out of total lack of knowledge of Haskell, but how do I use a function (in this case onScreen from XMonad.Actions.OnScreen) at xmonad startup? I's like to assign the last workspace to second screen by default, since it's really secondary in my setup (music player is there usually).
I tried putting this in main = do { ... } section: onScreen 1 "9";
but got this long error message (till end of this post): Error detected while loading xmonad configuration file: /home/kevin/.xmonad/xmonad.hs
xmonad.hs:30:1: Couldn't match expected type `IO a' against inferred type `i -> XMonad.StackSet.StackSet i l a1 [Char] sd -> XMonad.StackSet.StackSet i l a1 [Char] sd' In a stmt of a 'do' expression: onScreen 1 "9" In the expression: do { xmproc <- spawnPipe "xmobar"; onScreen 1 "9"; xmonad $ defaultConfig {normalBorderColor = "black", focusedBorderColor = "red2", borderWidth = 2, modMask = modm, focusFollowsMouse = False, manageHook = manageDocks <+> manageHook defaultConfig, layoutHook = avoidStruts $ simpleTabbed ||| Tall 1 5.0e-2 0.5, logHook = dynamicLogWithPP $ xmobarPP {ppOutput = hPutStrLn xmproc, ppTitle = xmobarColor "white" "" . shorten 100}} `additionalKeys` [((modm, xK_a), spawn "aumix -v-2"), ((modm, xK_f), spawn "aumix -v+2"), ....] } In the definition of `main': main = do { xmproc <- spawnPipe "xmobar"; onScreen 1 "9"; xmonad $ defaultConfig {normalBorderColor = "black", focusedBorderColor = "red2", borderWidth = 2, modMask = modm, focusFollowsMouse = False, manageHook = manageDocks <+> manageHook defaultConfig, layoutHook = avoidStruts $ simpleTabbed ||| Tall 1 5.0e-2 0.5, logHook = dynamicLogWithPP $ xmobarPP {ppOutput = hPutStrLn xmproc, ppTitle = xmobarColor "white" "" . shorten 100}} `additionalKeys` [((modm, xK_a), spawn "aumix -v-2"), ....] }
Please check the file for errors.
_______________________________________________ xmonad mailing list xmonad@haskell.org http://www.haskell.org/mailman/listinfo/xmonad ---end quoted text---

Sorry, I missread your e-mail :/ Felix On 12. December 2010 - 16:19, kevind256 wrote:
Date: Sun, 12 Dec 2010 16:19:12 +0300 From: kevind256
To: Felix Blanke Cc: xmonad@haskell.org Subject: Re: [xmonad] Fwd: How to use onScreen function on startup? As far as I understand it, you're shifting windows to different workspaces upon these applications' startup. What I wanted is to assign a workspace to a screen at xmonad's startup. So I do not see connection between this and your example. ManageHook (apparently) isn't used at xmonad startup, instead just 'main' is called, but something's wrong with my understanding of this all. Thank you for responce anyway.
On 12/12/10, Felix Blanke
wrote: Hi,
I'm not that familiar with haskell or xmonad, but I can tell you how I do that :)
-- Hooks -- manageHook' :: ManageHook manageHook' = composeAll .concat $ [ --app placement [ className =? c --> doF (W.shift "2-web") | c <- webApps ] , [ className =? c --> doF (W.shift "3-mail") | c <- mailApps ] , [ resource =? c --> doF (W.shift "4-multimedia") | c <- multimediaApps ] , [ className =? c --> doF (W.shift "5-IM") | c <- imApps ] , [ className =? c --> doF (W.shift "6-windows") | c <- windowsApps ] ]
webApps = ["Opera"] mailApps = ["Claws-mail", "mutt"] multimediaApps = ["mocp"] windowsApps = ["VirtualBox"] imApps = ["Skype"]
I think that isn't that hard to understand :)
"W" comes from "import qualified XMonad.StackSet as W"
Then just load that ManageHook in your main.
If you have any further question feel free to ask.
Felix
On 12. December 2010 - 09:34, kevind256 wrote:
Date: Sun, 12 Dec 2010 09:34:46 +0300 From: kevind256
To: xmonad@haskell.org Subject: [xmonad] Fwd: How to use onScreen function on startup? ---------- Forwarded message ---------- From: kevind256
Date: Sat, 11 Dec 2010 13:37:55 +0300 Subject: How to use onScreen function on startup? To: xmonad@haskell.org Hi,
Sorry to ask question out of total lack of knowledge of Haskell, but how do I use a function (in this case onScreen from XMonad.Actions.OnScreen) at xmonad startup? I's like to assign the last workspace to second screen by default, since it's really secondary in my setup (music player is there usually).
I tried putting this in main = do { ... } section: onScreen 1 "9";
but got this long error message (till end of this post): Error detected while loading xmonad configuration file: /home/kevin/.xmonad/xmonad.hs
xmonad.hs:30:1: Couldn't match expected type `IO a' against inferred type `i -> XMonad.StackSet.StackSet i l a1 [Char] sd -> XMonad.StackSet.StackSet i l a1 [Char] sd' In a stmt of a 'do' expression: onScreen 1 "9" In the expression: do { xmproc <- spawnPipe "xmobar"; onScreen 1 "9"; xmonad $ defaultConfig {normalBorderColor = "black", focusedBorderColor = "red2", borderWidth = 2, modMask = modm, focusFollowsMouse = False, manageHook = manageDocks <+> manageHook defaultConfig, layoutHook = avoidStruts $ simpleTabbed ||| Tall 1 5.0e-2 0.5, logHook = dynamicLogWithPP $ xmobarPP {ppOutput = hPutStrLn xmproc, ppTitle = xmobarColor "white" "" . shorten 100}} `additionalKeys` [((modm, xK_a), spawn "aumix -v-2"), ((modm, xK_f), spawn "aumix -v+2"), ....] } In the definition of `main': main = do { xmproc <- spawnPipe "xmobar"; onScreen 1 "9"; xmonad $ defaultConfig {normalBorderColor = "black", focusedBorderColor = "red2", borderWidth = 2, modMask = modm, focusFollowsMouse = False, manageHook = manageDocks <+> manageHook defaultConfig, layoutHook = avoidStruts $ simpleTabbed ||| Tall 1 5.0e-2 0.5, logHook = dynamicLogWithPP $ xmobarPP {ppOutput = hPutStrLn xmproc, ppTitle = xmobarColor "white" "" . shorten 100}} `additionalKeys` [((modm, xK_a), spawn "aumix -v-2"), ....] }
Please check the file for errors.
_______________________________________________ xmonad mailing list xmonad@haskell.org http://www.haskell.org/mailman/listinfo/xmonad ---end quoted text---
---end quoted text---

* On Sunday, December 12 2010, kevind256 wrote:
---------- Forwarded message ---------- From: kevind256
Date: Sat, 11 Dec 2010 13:37:55 +0300 Subject: How to use onScreen function on startup? To: xmonad@haskell.org Hi,
Sorry to ask question out of total lack of knowledge of Haskell, but how do I use a function (in this case onScreen from XMonad.Actions.OnScreen) at xmonad startup? I's like to assign the last workspace to second screen by default, since it's really secondary in my setup (music player is there usually).
I tried putting this in main = do { ... } section: onScreen 1 "9";
First, onScreen manipulates xmonad state so it needs to be run after that has been created. So put it in the startupHook like: main = do ... main = xmonad defaultConfig { ... -- other stuff modMask = modm, startupHook = windows (viewOnScreen 1 "9") } I've corrected the expression as well, following the 'simpler' example given in the module documentation. Adam

Thanks, it worked. I initially thought that viewOnScreen will also
focus that screen (which I did not want), but it doesn't.
For the sake of my (mis)education, could you provide some info what is
this windows(...) and why is it required? Maybe just a link to
documentation, if possible.
On 12/12/10, Adam Vogt
* On Sunday, December 12 2010, kevind256 wrote:
---------- Forwarded message ---------- From: kevind256
Date: Sat, 11 Dec 2010 13:37:55 +0300 Subject: How to use onScreen function on startup? To: xmonad@haskell.org Hi,
Sorry to ask question out of total lack of knowledge of Haskell, but how do I use a function (in this case onScreen from XMonad.Actions.OnScreen) at xmonad startup? I's like to assign the last workspace to second screen by default, since it's really secondary in my setup (music player is there usually).
I tried putting this in main = do { ... } section: onScreen 1 "9";
First, onScreen manipulates xmonad state so it needs to be run after that has been created. So put it in the startupHook like:
main = do ... main = xmonad defaultConfig { ... -- other stuff modMask = modm, startupHook = windows (viewOnScreen 1 "9") }
I've corrected the expression as well, following the 'simpler' example given in the module documentation.
Adam
_______________________________________________ xmonad mailing list xmonad@haskell.org http://www.haskell.org/mailman/listinfo/xmonad

There should be some more general discussion of the issue in this overview of the xmonad: http://www.haskell.org/haskellwiki/Xmonad/Guided_tour_of_the_xmonad_source But more specifically, it's an arbitrary split between functions that are allowed to directly modify xmonad's state, read and write arbitrary files and other IO, and those that only get to return new values. Suppose you have two functions with the type accepted by `windows', which focus another workspace, shift windows around etc.: f, g :: WindowSet -> WindowSet The xmonad library could also export: f_, g_ :: X () f_ = windows f g_ = windows g But let's say you want a single keybind that does f and then g. For example, shift a window to another workspace, and view the new workspace too. You could implement this as: x, y :: X () x = windows (\windowset -> g (f windowset)) y = do f_ g_ x is a better option than y, since it leads to less round trips to the X server: it produces a new version of xmonad's state, and then asks the X server to make the window arrangement fit the new state. y does the same as if you has two keybinds and hit them right after eachother. Another potential with the split up approach (`referential transparency') is easier testing. It's also better to have much of the code dealing with the X server all in one place (see the source for XMonad.Operations.windows). Or somebody might come along with another implementation of `windows' and be able to reuse some more code. In other words, the design reflects some common practices used to help simplify software. But those arguments don't really apply to whether contrib should export one, or both of f and f_, which is more of a bikeshedding topic. * On Sunday, December 12 2010, kevind256 wrote:
Thanks, it worked. I initially thought that viewOnScreen will also focus that screen (which I did not want), but it doesn't.
For the sake of my (mis)education, could you provide some info what is this windows(...) and why is it required? Maybe just a link to documentation, if possible.
On 12/12/10, Adam Vogt
wrote: * On Sunday, December 12 2010, kevind256 wrote:
---------- Forwarded message ---------- From: kevind256
Date: Sat, 11 Dec 2010 13:37:55 +0300 Subject: How to use onScreen function on startup? To: xmonad@haskell.org Hi,
Sorry to ask question out of total lack of knowledge of Haskell, but how do I use a function (in this case onScreen from XMonad.Actions.OnScreen) at xmonad startup? I's like to assign the last workspace to second screen by default, since it's really secondary in my setup (music player is there usually).
I tried putting this in main = do { ... } section: onScreen 1 "9";
First, onScreen manipulates xmonad state so it needs to be run after that has been created. So put it in the startupHook like:
main = do ... main = xmonad defaultConfig { ... -- other stuff modMask = modm, startupHook = windows (viewOnScreen 1 "9") }
I've corrected the expression as well, following the 'simpler' example given in the module documentation.
Adam
_______________________________________________ xmonad mailing list xmonad@haskell.org http://www.haskell.org/mailman/listinfo/xmonad

Thanks for explaination. windows() therefore finally applies changes
specified by functions inside. Well at this moment, I think we
shouldn't have f_ (this means more verbosity in case of single
function call, but more uniformity and less possibility for incorrect
style which surely would arise otherwise).
On 12/13/10, Adam Vogt
There should be some more general discussion of the issue in this overview of the xmonad: http://www.haskell.org/haskellwiki/Xmonad/Guided_tour_of_the_xmonad_source
But more specifically, it's an arbitrary split between functions that are allowed to directly modify xmonad's state, read and write arbitrary files and other IO, and those that only get to return new values.
Suppose you have two functions with the type accepted by `windows', which focus another workspace, shift windows around etc.:
f, g :: WindowSet -> WindowSet
The xmonad library could also export:
f_, g_ :: X () f_ = windows f g_ = windows g
But let's say you want a single keybind that does f and then g. For example, shift a window to another workspace, and view the new workspace too.
You could implement this as:
x, y :: X () x = windows (\windowset -> g (f windowset)) y = do f_ g_
x is a better option than y, since it leads to less round trips to the X server: it produces a new version of xmonad's state, and then asks the X server to make the window arrangement fit the new state. y does the same as if you has two keybinds and hit them right after eachother.
Another potential with the split up approach (`referential transparency') is easier testing. It's also better to have much of the code dealing with the X server all in one place (see the source for XMonad.Operations.windows). Or somebody might come along with another implementation of `windows' and be able to reuse some more code. In other words, the design reflects some common practices used to help simplify software.
But those arguments don't really apply to whether contrib should export one, or both of f and f_, which is more of a bikeshedding topic.
* On Sunday, December 12 2010, kevind256 wrote:
Thanks, it worked. I initially thought that viewOnScreen will also focus that screen (which I did not want), but it doesn't.
For the sake of my (mis)education, could you provide some info what is this windows(...) and why is it required? Maybe just a link to documentation, if possible.
On 12/12/10, Adam Vogt
wrote: * On Sunday, December 12 2010, kevind256 wrote:
---------- Forwarded message ---------- From: kevind256
Date: Sat, 11 Dec 2010 13:37:55 +0300 Subject: How to use onScreen function on startup? To: xmonad@haskell.org Hi,
Sorry to ask question out of total lack of knowledge of Haskell, but how do I use a function (in this case onScreen from XMonad.Actions.OnScreen) at xmonad startup? I's like to assign the last workspace to second screen by default, since it's really secondary in my setup (music player is there usually).
I tried putting this in main = do { ... } section: onScreen 1 "9";
First, onScreen manipulates xmonad state so it needs to be run after that has been created. So put it in the startupHook like:
main = do ... main = xmonad defaultConfig { ... -- other stuff modMask = modm, startupHook = windows (viewOnScreen 1 "9") }
I've corrected the expression as well, following the 'simpler' example given in the module documentation.
Adam
_______________________________________________ xmonad mailing list xmonad@haskell.org http://www.haskell.org/mailman/listinfo/xmonad
participants (3)
-
Adam Vogt
-
Felix Blanke
-
kevind256