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

Hi, 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 As the result, this version doesn't work as expected. 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? On an unrelated note, where do you get opportunities to apply your Haskell skills? -- Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software! mailto:fercerpav@gmail.com

I'm kinda busy this weekend with a machine migration, so I haven't been
following this very closely.
On Sat, Aug 30, 2014 at 11:22 AM, Paul Fertser
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):
It's actually worse than that, because the format of WM_CLIENT_MACHINE is not specified; for example, on the local host it could be any of: "localhost" short hostname fully qualified hostname dotted quad (IP address) conceivably, IPv6 address occasionally "localhost" qualified by local domain An additional stinger in the tail is that two (arguably misconfigured... but virtually every Linux default install for the most common distributions is misconfigured in this way) hosts may both end up getting "localhost" (== an address on 127/8) when asking for their canonical network name, and you can't tell which one it refers to. So if WM_CLIENT_MACHINE resolves to a loopback address (::1 or 127.0.0.0/8; 127.0.0.1 is not good enough, several Linuxes use 127.0.1.1 as a dhcp hack) you pretty much have to ignore it and assume you can't know what machine it is running on. Same if WM_CLIENT_MACHINE is not set at all. I also recently determined that the Haskell X11 bindings have a buggy interface to retrieving WM_CLIENT_MACHINE via Xlib instead of fetching the property directly, and xmonad can dump core if the bug is triggered. 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?
Probably, although spotting window factories is difficult in general. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

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)

On Sat, Aug 30, 2014 at 04:50:03PM -0700, Anton Vorontsov wrote:
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. :)
I thought you were a Moscow embedded developer hacking on old iPAQs and now you appear to be writing perfect English and sophisticated Haskell from a PDT location, what a surprise! I'm glad to hear you're having fun :)
+ vars = ["XAUTHLOCALHOSTNAME","HOST","HOSTNAME"]
This is from my pretty standard Gentoo install, and the same result on another Debian machine too: Prelude System.Posix.Env> getEnv `mapM` ["XAUTHLOCALHOSTNAME","HOST","HOSTNAME"] [Nothing,Nothing,Nothing] paul@laptop ~ $ env | egrep '(XAUTHLOCALHOSTNAME|HOST|HOSTNAME)' paul@laptop ~ $ -- Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software! mailto:fercerpav@gmail.com

On Sun, Aug 31, 2014 at 09:35:41AM +0400, Paul Fertser wrote:
On Sat, Aug 30, 2014 at 04:50:03PM -0700, Anton Vorontsov wrote:
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. :)
I thought you were a Moscow embedded developer hacking on old iPAQs and now you appear to be writing perfect English and sophisticated Haskell from a PDT location, what a surprise! I'm glad to hear you're having fun :)
;-)
+ vars = ["XAUTHLOCALHOSTNAME","HOST","HOSTNAME"]
This is from my pretty standard Gentoo install, and the same result on another Debian machine too:
Prelude System.Posix.Env> getEnv `mapM` ["XAUTHLOCALHOSTNAME","HOST","HOSTNAME"] [Nothing,Nothing,Nothing]
paul@laptop ~ $ env | egrep '(XAUTHLOCALHOSTNAME|HOST|HOSTNAME)' paul@laptop ~ $
Wow. Well, it just means that you have to create one. After poking around, I now see that XMonad/Layout/OnHost.hs talks about the same thing... It also contains a good idea: we can just set it in the config file itself. No doubt that I should document it, though. Similar to XMonad/Layout/OnHost.hs. Thanks! Anton p.s. The proper way to handle remote clients is a little bit more trickier, especially considering that the hostname might be changing. For this, we have to check current hostname and WM_CLIENT_MACHINE at the window creation time. If they are equal, then it is the local window and we have to store some flag for future use (since WM_CLIENT_MACHINE and hostname can diverge later on). But that would require a new dependency either in xmonad, or in a config file (better)...
participants (3)
-
Anton Vorontsov
-
Brandon Allbery
-
Paul Fertser