[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: panel.sh modification suggestion (faster (once a second) clock update)



On Mon, Apr 01, 2013 at 11:08:56PM -0700, Raf Cloesen wrote:
> I recently installed herbstluftwm, and I am absolutely delighted. I
> have delighted configuring this program. From the start, yet, I was
> somewat disappointed by the fact that the clock would take so long (a
> little over a minute on my sistem. Does somebody want the details of
> the sistem?) in updating. Initially it will not show until that time
> passed.

All these problems aren't happening here. I implemented them and the
only problem i can imagine is that the tools on your system behave
different. Is there any error message print to stderr by panel.sh?
What's the output of this command on your system?

    echo -e 'a\na\nb\nc' | awk '$0 != l { print ; l=$0 ; fflush(); }'

The expected output is

    a
    b
    c

Is there some message complaining that there is no awk-'fflush()' on
your system?

> In my study of panel.sh, I have learnd that the clock will be updated
> in response to the correct hook (date [argument]) being send to the
> herbstluftwm. I have at this time not yet discovered where this hook
> is triggered (maybe it isn't?).

No, it is not triggered as a hook. The architecture of panel.sh is as
follows: there are many processes connected with pipes.

  herbstclient -i       date-loop
            \             |
             \            V
              \         "uniq" (line 54, line 43-45)
               \         /
                \       /
                 \     /
                  V   V
            subshell (line 48-58)
                    | (line 58)
                    V
             big-while-loop
                    | (line 143)
                    V
                  dzen2

Each arrow represents a pipe. The big-while-loop reads "events" from
different sources: the date-loop and hooks from herbstluftwm. From these
events, big-while-loop generates the output and sends it to dzen2. So
the date-loop "simulates" hooks.

> Yet, based on this knowledge, I changed the following line (number 52
> in the original panel.sh. Here the change stated as it would be if
> applied to the original panel.sh):
> 
>     date +'date ^fg(#efefef)%H:%M^fg(#909090), %Y-%m-^fg(#efefef)%d'
> 
> to:
> 
>   herbstclient emit_hook $(date +'date ^fg(#efefef)%H:%M^fg(#909090), %Y-%m-^fg(#efefef)%d')

This just causes the date-loop to work around the "uniq" by sending the
line to the "herbstclient -i".


> Of course, given this formating of the time, no diference will be
> noticable (exept for the initial lack of clock for about a minute). In
> my configuration (showing seconds), this does make a considerable
> diference. A side effect worth mentioning is the fact that (given
> enough of the original panel.sh remains in your custom version) the
> hole panel will update every one second. So other data (like battery
> state provided by 'acpi --battery' in my custom panel.sh) will update
> every second too.

The solution for the battery is to feed the "subshell" with another
event source, by adding something like the following before
"herbstclient --idle":

    while true ; do
        echo -n "battery "
        acpi -b
        sleep 1 || break
    done > >(uniq_linebuffered)  &
    childpid+=" $!"


Regards,
Thorsten