[xmonad] runOrRaiseNext lost functionality in xmonad 0.9?

Gwern Branwen gwern0 at gmail.com
Mon Jul 12 00:57:00 EDT 2010


On Sun, Jul 11, 2010 at 7:53 PM, Joseph Garvin
<joseph.h.garvin at gmail.com> wrote:
> If I just put "firefox" then it works, but "firefox || firefox" does
> not, leading me to believe the command is no longer executed through
> the shell. Is this intentional?

This is documented in the haddocks:

-- | 'action' is an executable to be run via 'safeSpawnProg' (of
"XMonad.Util.Run") if the Window cannot be found.
--   Presumably this executable is the same one that you were looking for.

On Sun, Jul 11, 2010 at 10:30 PM, Adam Vogt <vogt.adam at gmail.com> wrote:
> can call out to the shell to check with 'which' with the following
> expression you can put where you had runOrRaiseNext:
>
>    do
>  (_,paths,_) <- io $ readProcessWithExitCode
>                "which"
>                ["firefox-3.5","firefox3","firefox"]
>                ""
>  -- run the first one that exists
>  case lines paths of
>    firefox : _ -> runOrRaiseNext firefox ...
>    _ -> return () -- or something else?

Another solution is to look at the current code:

    runOrRaise = raiseMaybe ○ safeSpawnProg

XMonad.Util.Run.safeSpawnProg is defined as:

    safeSpawnProg ∷ MonadIO m ⇒ FilePath → m ()
    safeSpawnProg = flip safeSpawn []

In comparison, XMonad.Util.Run.unsafeSpawn:

     unsafeSpawn ∷ MonadIO m ⇒ String → m ()
     unsafeSpawn = spawn

And String == FilePath, so these type signatures are identical.

So to restore the old behavior is as simple as  swapping B for A:

    runOrRaise' = raiseMaybe ○ unsafeSpawn

I thought this was all clear in the haddocks, but I guess not. I've
expanded the haddock for runOrRaise to point out raiseMaybe's greater
generality.

-- 
gwern


More information about the xmonad mailing list