<div dir="ltr">Er. What version of ghc? That sounds like either a ghc runtime bug, or a system configuration issue. In particular, xmonad creates no threads itself, so that would be the ghc runtime's IO manager thread.</div><br><div class="gmail_quote"><div dir="ltr">On Fri, Nov 30, 2018 at 3:07 PM Dmitriy Matrosov <<a href="mailto:sgf.dma@gmail.com">sgf.dma@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 11/30/2018 12:11 AM, Brandon Allbery wrote:<br>
> Yes. More specifically, it's ultimately using the execve() syscall, via<br>
> one of the wrappers which propagates the environment (which one depends<br>
> on whether it's asked to do $PATH search or not).<br>
<br>
So.. here is version using environment:<br>
<br>
import XMonad<br>
import XMonad.Operations<br>
import XMonad.Util.EZConfig<br>
<br>
import System.Environment<br>
import Control.Exception<br>
<br>
main :: IO ()<br>
main = do<br>
let xcf = def<br>
{ modMask = mod4Mask<br>
, handleExtraArgs = disableKeysE<br>
}<br>
`additionalKeys`<br>
[ ((mod4Mask, xK_d), disableKeysOn) ]<br>
xmonad xcf<br>
<br>
disableKeysOn :: X ()<br>
disableKeysOn = do<br>
trace "Preparing to disable keys and restarting.."<br>
io $ setEnv "XMONAD_DISABLE_KEYS" "1"<br>
restart "xmonad" True<br>
<br>
disableKeysE :: [String] -> XConfig Layout -> IO (XConfig Layout)<br>
disableKeysE _ xcf = do<br>
me <- lookupEnv "XMONAD_DISABLE_KEYS"<br>
case me of<br>
Just _ -> do<br>
trace "Disabling all keys."<br>
unsetEnv "XMONAD_DISABLE_KEYS"<br>
return (xcf {keys = \_ -> mempty})<br>
Nothing -> return xcf<br>
<br>
It also restarts xmonad on key press (when disabling keys) and all<br>
works fine, but.. xmonad frequently crashes with<br>
<br>
xmonad: failed to create OS thread: Resource temporarily <br>
unavailable<br>
<br>
I don't think this crash relates somehow to using environment, and it<br>
happened from time to time before too, but still.. Can you advise,<br>
how to fix it?<br>
<br>
> On Thu, Nov 29, 2018 at 4:07 PM Dmitriy Matrosov <<a href="mailto:sgf.dma@gmail.com" target="_blank">sgf.dma@gmail.com</a><br>
> <mailto:<a href="mailto:sgf.dma@gmail.com" target="_blank">sgf.dma@gmail.com</a>>> wrote:<br>
><br>
> On 11/29/2018 09:50 PM, Brandon Allbery wrote:<br>
> > You were talking about restart, between the running xmonad and its<br>
> > replacement via executeFile. There, you can use the environment.<br>
> There<br>
> > is no way to pass information between an invoked "xmonad<br>
> --restart" and<br>
> > the running xmonad.<br>
><br>
> You mean, `executeFile` preserves environment? So, i may change <br>
it from<br>
> running xmonad (by e.g. keybinding) and then restart it?<br>
><br>
> > On Thu, Nov 29, 2018 at 6:01 AM Dmitriy Matrosov<br>
> <<a href="mailto:sgf.dma@gmail.com" target="_blank">sgf.dma@gmail.com</a> <mailto:<a href="mailto:sgf.dma@gmail.com" target="_blank">sgf.dma@gmail.com</a>><br>
> > <mailto:<a href="mailto:sgf.dma@gmail.com" target="_blank">sgf.dma@gmail.com</a> <mailto:<a href="mailto:sgf.dma@gmail.com" target="_blank">sgf.dma@gmail.com</a>>>> wrote:<br>
> ><br>
> ><br>
> ><br>
> > On November 28, 2018 9:25:00 PM GMT+03:00, Brandon Allbery<br>
> > <<a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a> <mailto:<a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>><br>
> <mailto:<a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a> <mailto:<a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>>>> wrote:<br>
> > >Not by default; there's already a bug (<br>
> > ><a href="https://github.com/xmonad/xmonad/issues/78" rel="noreferrer" target="_blank">https://github.com/xmonad/xmonad/issues/78</a>) about our not<br>
> obeying the<br>
> > >ICCCM<br>
> > >replace protocol unless started by replacing some other WM.<br>
> > ><br>
> > >There's a few other places you can hide extra parameters;<br>
> starting<br>
> > that<br>
> > >early, the environment is probably the easiest to use, <br>
provided<br>
> > they're<br>
> > >not<br>
> > >too large (see why there's a state file now).<br>
> ><br>
> > Hm, i don't understand how to use environment. I need to pass<br>
> > something to running xmonad process (to which i send<br>
> > XMONAD_RESTART). As far as i know, i can't change <br>
environment of<br>
> > another process..<br>
> ><br>
> ><br>
> > >On Wed, Nov 28, 2018 at 1:20 PM Dmitriy Matrosov<br>
> > <<a href="mailto:sgf.dma@gmail.com" target="_blank">sgf.dma@gmail.com</a> <mailto:<a href="mailto:sgf.dma@gmail.com" target="_blank">sgf.dma@gmail.com</a>><br>
> <mailto:<a href="mailto:sgf.dma@gmail.com" target="_blank">sgf.dma@gmail.com</a> <mailto:<a href="mailto:sgf.dma@gmail.com" target="_blank">sgf.dma@gmail.com</a>>>><br>
> > >wrote:<br>
> > ><br>
> > >> Hi.<br>
> > >><br>
> > >> On 11/21/2018 09:49 PM, Eyal Erez wrote:<br>
> > >> > Hi,<br>
> > >> ><br>
> > >> > I'm getting some collisions between my xmonad<br>
> keybindings and an<br>
> > >> > application I'm running (it's a game that is suppose to<br>
> run full<br>
> > >screen<br>
> > >> > but in reality just uses a large window). I was<br>
> wondering if I<br>
> > >could<br>
> > >> > suspend or change some keybindings from a script that I<br>
> can run<br>
> > >before<br>
> > >> > the app launches and then restore later.<br>
> > >> ><br>
> > >> > Is this at all possible? Happy to entertain other <br>
options.<br>
> > >><br>
> > >> Here is proof of concept:<br>
> > >><br>
> > >><br>
> > >> import XMonad<br>
> > >> import XMonad.Hooks.EwmhDesktops<br>
> > >><br>
> > >> import System.Directory<br>
> > >> import System.FilePath<br>
> > >><br>
> > >><br>
> > >> main :: IO ()<br>
> > >> main = do<br>
> > >> let xcf = ewmh $ def<br>
> > >> { modMask = mod4Mask<br>
> > >> , handleExtraArgs = <br>
disableKeys<br>
> > >> }<br>
> > >> xmonad xcf<br>
> > >><br>
> > >> disableKeys :: [String] -> XConfig Layout -> IO<br>
> (XConfig<br>
> > >Layout)<br>
> > >> disableKeys _ xcf = do<br>
> > >> xd <- getXMonadDir<br>
> > >> let disableFn = xd </> "disable_keys"<br>
> > >> b <- doesFileExist disableFn<br>
> > >> if b<br>
> > >> then do<br>
> > >> trace "Disabling all keys."<br>
> > >> removeFile disableFn<br>
> > >> return (xcf {keys = \_ -> mempty})<br>
> > >> else return xcf<br>
> > >><br>
> > >><br>
> > >> To disable all keys create file `~/.xmonad/disable_keys`<br>
> and then<br>
> > >> restart xmonad with `xmonad --restart`. All keys will be<br>
> disabled<br>
> > >> _and_ file deleted (to avoid locking yourself), thus next<br>
> restart<br>
> > >will<br>
> > >> restore all keys back.<br>
> > >><br>
> > >> As far as i understand, xmonad grabs keys in<br>
> `X.Main.launch` before<br>
> > >> entering main loop. Thus, the one way to change key grab<br>
> is to<br>
> > >restart<br>
> > >> xmonad. I need to modify `XConfig` before calling<br>
> > X.Main.launch`, and<br>
> > >> this may be done by `handleExtraArgs` (called in <br>
`launch'` in<br>
> > >> `X.Main.xmonad`). Unfortunately, it seems, that xmonad<br>
> does not<br>
> > allow<br>
> > >> to pass extra cmd arguments during restart<br>
> (`X.Operations.restart`<br>
> > >> always starts xmonad with name `xmonad` and no<br>
> arguments). Also, i<br>
> > >> can't use extensible state in `handleExtraArgs`, because<br>
> it runs in<br>
> > >> `IO` (`X` context is not yet built at that time). Thus,<br>
> to pass<br>
> > >> something to it, i may use either file or (probably)<br>
> > `--replace`. The<br>
> > >> above version uses file. And i have no luck with<br>
> `--replace`: it<br>
> > >> seems, `xmonad` can't replace itself?..<br>
> > >> _______________________________________________<br>
> > >> xmonad mailing list<br>
> > >> <a href="mailto:xmonad@haskell.org" target="_blank">xmonad@haskell.org</a> <mailto:<a href="mailto:xmonad@haskell.org" target="_blank">xmonad@haskell.org</a>><br>
> <mailto:<a href="mailto:xmonad@haskell.org" target="_blank">xmonad@haskell.org</a> <mailto:<a href="mailto:xmonad@haskell.org" target="_blank">xmonad@haskell.org</a>>><br>
> > >> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad</a><br>
> > >><br>
> > _______________________________________________<br>
> > xmonad mailing list<br>
> > <a href="mailto:xmonad@haskell.org" target="_blank">xmonad@haskell.org</a> <mailto:<a href="mailto:xmonad@haskell.org" target="_blank">xmonad@haskell.org</a>><br>
> <mailto:<a href="mailto:xmonad@haskell.org" target="_blank">xmonad@haskell.org</a> <mailto:<a href="mailto:xmonad@haskell.org" target="_blank">xmonad@haskell.org</a>>><br>
> > <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad</a><br>
> ><br>
> ><br>
> ><br>
> > --<br>
> > brandon s allbery kf8nh<br>
> > <a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a> <mailto:<a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>><br>
> <mailto:<a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a> <mailto:<a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>>><br>
><br>
> _______________________________________________<br>
> xmonad mailing list<br>
> <a href="mailto:xmonad@haskell.org" target="_blank">xmonad@haskell.org</a> <mailto:<a href="mailto:xmonad@haskell.org" target="_blank">xmonad@haskell.org</a>><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad</a><br>
><br>
><br>
><br>
> --<br>
> brandon s allbery kf8nh<br>
> <a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a> <mailto:<a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>><br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>brandon s allbery kf8nh</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a></div></div></div></div></div>