[xmonad] Not running my startupHook on restart

Adam Sjøgren asjo at koldfront.dk
Thu Dec 31 16:35:48 UTC 2015


I have a startupHook that spawns a number of windows on various
workspaces.

When I restart XMonad, I don't want those windows opened again.

Is there an easy way to have startupHook only run when logging in, and
not when restarting XMonad?

The way I have tried to solve this, unsuccessfully, is to make my
startupHook look like this:

  myStartup = when (noRun /= "1") $ do
                spawnOn "1" "emacs"
                spawnOn "6" "x-terminal-emulator"
                -- and so on...
              where
                noRun = unsafePerformIO $ env "NO_STARTUP_HOOK" "0"

  env :: String -> String -> IO String
  env variable fallthrough = getEnv variable `Control.Exception.catch` econst fallthrough

(where getEnv is imported from System.Environment).

And then I have changed the restart keybinding like this:

        , ("M-S-r", spawn "xmonad --recompile; export NO_STARTUP_HOOK=1; xmonad --restart")

Unfortunately it doesn't work - I guess something "more" is going on
when "xmonad --restart" runs, because if I add a key:

        , ("M-S-y", spawn "export HEP=yay; notify-send --expire-time 2000 'Testing' \"ENV: [$HEP]\"")

then pressing M-S-y gives me an alert with the text "ENV: [yay]" in it.
But if I do:

        , ("M-S-y", spawn "notify-send --expire-time 2000 'Testing' \"ENV: [$NO_STARTUP_HOOK]\"")

the notification says "ENV: []" regardless of whether I have restarted
XMonad or not.

I have a feeling that I am taking the long walk to solve this - any
ideas of the easy way to the goal here?


  Thanks!

    Adam

-- 
 "Här kommer rädslan, nu igen                                 Adam Sjøgren
  När alla fjärilar i magen nålas upp                    asjo at koldfront.dk
  till ett mönster på min säng"



More information about the xmonad mailing list