how to redirect dynamicLogXinerama output to a FIFO/named pipe?
I would like to be able to have xmonad write the output of its dynamicLogXinerama to a FIFO (that I can then read from a Unity app indicator and thus display the workspaces being currently used). I modified my desktop config so that rather than executing xmonad directly it instead runs a simple wrapper script #!/bin/sh mkfifo /tmp/xmonad-fifo xmonad >/tmp/xmonad-fifo but to my surprise running 'tail -f /tmp/xmonad-fifo' shows no output, while if I simply start xmonad in a terminal I can see it printing information about the workspaces being used to the terminal: [1] [1] [2]1 [2]1 ... It would be awesome if anyone could tell me why xmonad's dynamicLog output is not showing up in the FIFO. xmonad itself is clearly running (from the moment I start reading data from the FIFO.) thanks! ~l
On Tue, Jun 19, 2012 at 9:57 PM, Lara Michaels <laramichaels1978@yahoo.com>wrote:
but to my surprise running 'tail -f /tmp/xmonad-fifo' shows no output, while if I simply start xmonad in a terminal I can see it printing information about the workspaces being used to the terminal:
At a guess, you've just demonstrated that nobody has been using dynamicLogXinerama. It isn't flushing its output, and I can't find anywhere where xmonad sets its stdout to unbuffered or line buffered output. Output to a terminal is automatically line buffered, so in that case it works as expected; block buffering means it'd only get flushed to the FIFO every 4Kbytes or so. You could try importing System.IO and adding hSetBuffering stdout LineBuffering to the startupHook. -- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms
Hi Brandon thank you for this. I tried changing xmonad.hs to read main = do xmonad $ gnomeConfig { modMask = mod4Mask , startupHook = hSetBuffering stdout LineBuffering , manageHook = manageDocks <+> myManageHook <+> manageHook defaultConfig , workspaces = myWorkspaces , normalBorderColor = "#cccccc" , focusedBorderColor = "#cd8b00" , borderWidth = 3 , layoutHook = showWName myLayout , logHook = dynamicLogXinerama -- , logHook = ewmhDesktopsLogHook <+> dynamicLogXinerama , handleEventHook = ewmhDesktopsEventHook } `additionalKeysP` myKeys but now xmonad shows me an error message: Couldn't match expected type 'X ()' with actual type 'IO ()' In the return type of a call of 'hsetBuffering' In the 'startupHook' field of a record In the first argument of 'addditionalKeysP', [...] Do you know why this is happening? thank you for any help ~l ________________________________ From: Brandon Allbery <allbery.b@gmail.com> To: Lara Michaels <laramichaels1978@yahoo.com> Cc: "xmonad@haskell.org" <xmonad@haskell.org> Sent: Wednesday, June 20, 2012 3:33 AM Subject: Re: [xmonad] how to redirect dynamicLogXinerama output to a FIFO/named pipe? On Tue, Jun 19, 2012 at 9:57 PM, Lara Michaels <laramichaels1978@yahoo.com> wrote: but to my surprise running 'tail -f /tmp/xmonad-fifo' shows no output, while if I simply start xmonad in a terminal I can see it printing information about the workspaces being used to the terminal: At a guess, you've just demonstrated that nobody has been using dynamicLogXinerama. It isn't flushing its output, and I can't find anywhere where xmonad sets its stdout to unbuffered or line buffered output. Output to a terminal is automatically line buffered, so in that case it works as expected; block buffering means it'd only get flushed to the FIFO every 4Kbytes or so. You could try importing System.IO and adding hSetBuffering stdout LineBuffering to the startupHook. -- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms
You can use liftIO to turn an IO action into an X action: liftIO (hSetBuffering stdout LineBuffering). ~d Quoting Lara Michaels <laramichaels1978@yahoo.com>:
Hi Brandon
thank you for this. I tried changing xmonad.hs to read main = do xmonad $ gnomeConfig { modMask = mod4Mask , startupHook = hSetBuffering stdout LineBuffering , manageHook = manageDocks <+> myManageHook <+> manageHook defaultConfig , workspaces = myWorkspaces , normalBorderColor = "#cccccc" , focusedBorderColor = "#cd8b00" , borderWidth = 3 , layoutHook = showWName myLayout , logHook = dynamicLogXinerama -- , logHook = ewmhDesktopsLogHook <+> dynamicLogXinerama , handleEventHook = ewmhDesktopsEventHook } `additionalKeysP` myKeys
but now xmonad shows me an error message:
Couldn't match expected type 'X ()' with actual type 'IO ()' In the return type of a call of 'hsetBuffering' In the 'startupHook' field of a record In the first argument of 'addditionalKeysP', [...]
Do you know why this is happening?
thank you for any help ~l
________________________________ From: Brandon Allbery <allbery.b@gmail.com> To: Lara Michaels <laramichaels1978@yahoo.com> Cc: "xmonad@haskell.org" <xmonad@haskell.org> Sent: Wednesday, June 20, 2012 3:33 AM Subject: Re: [xmonad] how to redirect dynamicLogXinerama output to a FIFO/named pipe?
On Tue, Jun 19, 2012 at 9:57 PM, Lara Michaels <laramichaels1978@yahoo.com> wrote:
but to my surprise running 'tail -f /tmp/xmonad-fifo' shows no output, while if I simply start xmonad in a terminal I can see it printing information about the workspaces being used to the terminal:
At a guess, you've just demonstrated that nobody has been using dynamicLogXinerama. It isn't flushing its output, and I can't find anywhere where xmonad sets its stdout to unbuffered or line buffered output. Output to a terminal is automatically line buffered, so in that case it works as expected; block buffering means it'd only get flushed to the FIFO every 4Kbytes or so.
You could try importing System.IO and adding
hSetBuffering stdout LineBuffering
to the startupHook. -- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms
On Wed, Jun 20, 2012 at 7:38 AM, Lara Michaels <laramichaels1978@yahoo.com>wrote:
, startupHook = hSetBuffering stdout LineBuffering
*sigh* sorry, late night and I missed part of it. Also, you're using gnomeConfig, so it takes a little more: , startupHook = (io $ hSetBuffering stdout LineBuffering) <+> startupHook gnomeConfig -- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms
Hi Brandon thank you for this, now I no longer get the error message upon starting xmonad. However, still nothing gets read by 'tail -f .xmonad-fifo'. Is there some other way to the dynamicLogXinerama information so that I can display it on an applet/appindicator? thanks! ~l ________________________________ From: Brandon Allbery <allbery.b@gmail.com> To: Lara Michaels <laramichaels1978@yahoo.com> Cc: "xmonad@haskell.org" <xmonad@haskell.org> Sent: Wednesday, June 20, 2012 7:37 PM Subject: Re: [xmonad] how to redirect dynamicLogXinerama output to a FIFO/named pipe? On Wed, Jun 20, 2012 at 7:38 AM, Lara Michaels <laramichaels1978@yahoo.com> wrote: , startupHook = hSetBuffering stdout LineBuffering *sigh* sorry, late night and I missed part of it. Also, you're using gnomeConfig, so it takes a little more: , startupHook = (io $ hSetBuffering stdout LineBuffering) <+> startupHook gnomeConfig -- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms
On Thu, Jun 21, 2012 at 9:31 AM, Lara Michaels <laramichaels1978@yahoo.com>wrote:
thank you for this, now I no longer get the error message upon starting xmonad. However, still nothing gets read by 'tail -f .xmonad-fifo'.
Sorry for the delay on this, things have been "interesting" here of late. It belatedly occurred to me that this *is* a FIFO, and as such the reader has to open it first, with O_RDWR (or what Haskell calls ReadWriteMode) or it won't get hooked up properly. (This is a POSIXism, and Linux at least is very strict about it; depending on the kernel version, you may see ENXDEV ("No such device or address") or what gets "opened" is a dummy node that will never successfully read or write data.)
Is there some other way to the dynamicLogXinerama information so that I can display it on an applet/appindicator?
dynamicLogXinerama is not very flexible; the documentation notes this, and suggests an alternative which provides most of the same information while giving you flexibility (dynamicLogXinerama<http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-DynamicLog.html#v:dynamicLogXinerama> ). All in all, POSIX FIFOs are remarkably useless (and I'm still amazed POSIX found a way to make them even less useful than they were originally) and should probably be avoided. -- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms
Hi Brandon, Many thanks for this. I will try to open the FIFO using the O_RDWR flag. My xmonad setup broke so badly when I upgraded my system to a more recent Ubuntu version that I am largely paralyzed work-wise because of this... best ~l ________________________________ From: Brandon Allbery <allbery.b@gmail.com> To: Lara Michaels <laramichaels1978@yahoo.com> Cc: "xmonad@haskell.org" <xmonad@haskell.org> Sent: Thursday, June 28, 2012 8:00 PM Subject: Re: [xmonad] how to redirect dynamicLogXinerama output to a FIFO/named pipe? On Thu, Jun 21, 2012 at 9:31 AM, Lara Michaels <laramichaels1978@yahoo.com> wrote: thank you for this, now I no longer get the error message upon starting xmonad. However, still nothing gets read by 'tail -f .xmonad-fifo'. Sorry for the delay on this, things have been "interesting" here of late. It belatedly occurred to me that this *is* a FIFO, and as such the reader has to open it first, with O_RDWR (or what Haskell calls ReadWriteMode) or it won't get hooked up properly. (This is a POSIXism, and Linux at least is very strict about it; depending on the kernel version, you may see ENXDEV ("No such device or address") or what gets "opened" is a dummy node that will never successfully read or write data.) Is there some other way to the dynamicLogXinerama information so that I can display it on an applet/appindicator? dynamicLogXinerama is not very flexible; the documentation notes this, and suggests an alternative which provides most of the same information while giving you flexibility (dynamicLogXinerama). All in all, POSIX FIFOs are remarkably useless (and I'm still amazed POSIX found a way to make them even less useful than they were originally) and should probably be avoided. -- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms
participants (3)
-
Brandon Allbery -
Lara Michaels -
wagnerdm@seas.upenn.edu