[xmonad] Complex hotkeys definition

Brandon Allbery allbery.b at gmail.com
Mon Jan 17 20:10:41 UTC 2022


You have two problems. The first is that `$` extends as far as
possible, so `spawn` ends up being grouped with `W.view` instead of
with `windows`; fix this by using explicit parentheses instead of `$`,
that is `windows (W.view "2")`. The second is that the correct
operator to use is either `*>` or `>>`.

Although you will then discover a third problem, which is a race
condition because `spawn` is asynchronous (Linux is not Windows),
meaning sometimes the new window will open on the previously active
workspace. You may want to use
https://hackage.haskell.org/package/xmonad-contrib-0.17.0/docs/XMonad-Actions-SpawnOn.html#v:spawnOn
instead (don't forget to add
https://hackage.haskell.org/package/xmonad-contrib-0.17.0/docs/XMonad-Actions-SpawnOn.html#v:manageSpawn
to the `manageHook` or it won't work).

On Mon, Jan 17, 2022 at 2:44 PM mito <info at mito-space.com> wrote:
>
> Dear all,
>
> yet I failed properly occasionally extending "myHotkeys" commands with
> additional arguments, e.g. like also spawning something when switching
> workspaces.
>
> Say, the default is something like:
>
> myHotkeys = [
>            ...
>            , ("M-2", windows $ W.view "2")
>            ...
>            ]
>
> for hitting <Super_L+2> for changing to workspace "2".
>
> But what if I wanted to additionally execute some extra command or app –
> such as launching "konsole" (just for testing; I am going to do
> something else)?
>
> Simply editing and adding stuff link
>
>            , ("M-2", windows $ W.view "2" $ spawn "konsole")
> or
>            , ("M-2", windows $ W.view "2" . spawn "konsole")
> or
>            , ("M-2", windows $ W.view "2" || spawn "konsole")
> or
>            , ("M-2", windows $ W.view "2" <+> spawn "konsole")
>
> doesn't work, due to compilation errors.
>
> I am no programmer and haven't yet found the right operators or order;
> or am I missing brackets?
> And I don't get the error logs in detail really.
>
> Thanks in advance!
> _______________________________________________
> 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