[xmonad] workspaces conditional on host name

Brandon Allbery allbery.b at gmail.com
Mon Sep 19 16:08:59 UTC 2022


That should actually be fine. Check the case of your hostname? You
might want to drop a `print hostname` before the `let` and then check
the session log.

On Mon, Sep 19, 2022 at 12:02 PM Ramon Diaz-Uriarte <rdiaz02 at gmail.com> wrote:
>
> Dear All,
>
> I use XMonad on different machines. The configuration is identical, except for the default workspaces, so I'd like to have the config file set the default workspaces automagically. Haskell ignorant here, but googling around I think I am almost there. These are, I think, the relevant pieces
>
>
> myWorkspaces    = map show[1..7]
> myWorkspacesPhelsuma    = map show[1..3] ++ ["top", "sync", "zot",  "whats"]
> myWorkspacesTriturus    = map show[1..2] ++ ["top", "sync"]
>
>
> main :: IO ()
> main = do
>    hostname <- io (getEnv "HOSTNAME")
>    let myWorkspaces = case hostname of
>          "Phelsuma" -> myWorkspacesPhelsuma
>          "Triturus" -> myWorkspacesTriturus
>          _ -> myWorkspaces
>    xmonad
>       $ ewmh
>       $ dynamicProjects myProjects
>       $ withNavigation2DConfig def
>       $ docks
>       $ withEasySB (statusBarProp "xmobar ~/.xmonad/.xmobarrc" (pure myXmobarPP)) defToggleStrutsKey
>       $ myConfig
>
>
> myConfig = def {
>          --- blablabla
>          workspaces =  myWorkspaces
>          }
>
>
> However, I keep getting an error:
>
>     • Couldn't match expected type ‘Maybe String’
>                   with actual type ‘[Char]’
>     • In the pattern: "Phelsuma"
>       In a case alternative: "Phelsuma" -> myWorkspacesPhelsuma
>       In the expression:
>         case hostname of
>           "Phelsuma" -> myWorkspacesPhelsuma
>           "Triturus" -> myWorkspacesTriturus
>           _ -> myWorkspaces
>     |
> 882 |          "Phelsuma" -> myWorkspacesPhelsuma
>     |          ^^^^^^^^^^
>
> (and the same error for the second entry, "Triturus")
>
>
> This I think should be fairly easy to fix, but I can't find how. I tried writing the case section as
>
> let myWorkspaces = case hostname of
>          Just "Phelsuma" -> myWorkspacesPhelsuma
>          Just "Triturus" -> myWorkspacesTriturus
>          _ -> myWorkspaces
>
> and that does not give me an error, but it seems to ignore the actual hostname and uses the "default" one (the one with workspaces 1 to 7). So I think I am using "Just" incorrectly and possibly also misunderstanding how "let" works in main.
>
> Any suggestions?
>
> Thanks,
>
> --
> Ramon Diaz-Uriarte
> Department of Biochemistry, Lab B-31
> Facultad de Medicina
> Universidad Autónoma de Madrid
> Arzobispo Morcillo, 4
> 28029 Madrid
> Spain
>
> Phone: +34-91-497-2412
>
> Email: rdiaz02 at gmail.com
>        r.diaz at uam.es
>
> https://ligarto.org/rdiaz
> _______________________________________________
> xmonad mailing list
> xmonad at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad



-- 
brandon s allbery kf8nh
allbery.b at gmail.com


More information about the xmonad mailing list