[xmonad] darcs patch: Add Stoppable layout for power saving

Anton Vorontsov anton at enomsg.org
Sat Aug 30 23:50:03 UTC 2014


On Sat, Aug 30, 2014 at 07:22:33PM +0400, Paul Fertser wrote:
> On Fri, Aug 29, 2014 at 06:41:14PM -0700, Anton Vorontsov wrote:
> > +signalLocalWindow :: Signal -> Window -> X ()
> > +signalLocalWindow s w  = do
> > +    host <- io $ getEnvDefault "HOSTNAME" ""
> > +    hasProperty (Machine host) w >>= flip when (signalWindow s w)
> 
> HOSTNAME is a bash-specific variable and it's not exported by default,
> so neither XMonad nor ghci sees it (even though I actually use bash on
> this machine):
> 
> Prelude System.Posix.Env> getEnv "HOSTNAME" 
> Nothing

Ugh. As Brandon Allbery rightfully pointed out, the whole hostname issue
is a mess.

I also found this post about XAUTHLOCALHOSTNAME:

  http://lists.x.org/archives/xorg-arch/2005-August/000200.html

Personally, in my setup I have all three env variable set: HOST{,NAME} and
XAUTHLOCALHOSTNAME.

Please see if the patch below helps. It should account for different
setups.

...
> I've noticed another unpleasant side-effect of this: urxvtd is a
> single process that can have many windows (each spawned with
> urxvtc). So if the stoppable workspace has a urxvtd window, all the
> other terminal windows get frozen too. Should an optional filtering
> facility be added?

Yea, maybe as a hook.

> On an unrelated note, where do you get opportunities to apply your
> Haskell skills?

I do some AI/BCI research using Haskell, but it's for my own fun.
Commercially I don't apply it anywhere. :)


---

diff -rN -u old-XMonadContrib/XMonad/Layout/Stoppable.hs new-XMonadContrib/XMonad/Layout/Stoppable.hs
--- old-XMonadContrib/XMonad/Layout/Stoppable.hs	2014-08-30 16:11:44.835184230 -0700
+++ new-XMonadContrib/XMonad/Layout/Stoppable.hs	2014-08-30 16:11:44.838184259 -0700
@@ -74,8 +74,11 @@
 
 signalLocalWindow :: Signal -> Window -> X ()
 signalLocalWindow s w  = do
-    host <- io $ getEnvDefault "HOSTNAME" ""
+    host <- io $ takeOneMaybe `liftM` (getEnv `mapM` vars)
     hasProperty (Machine host) w >>= flip when (signalWindow s w)
+  where
+    takeOneMaybe = last . (mzero:) . take 1 . catMaybes
+    vars = ["XAUTHLOCALHOSTNAME","HOST","HOSTNAME"]
 
 withAllOn :: (a -> X ()) -> Workspace i l a -> X ()
 withAllOn f wspc = f `mapM_` integrate' (stack wspc)


More information about the xmonad mailing list