As mentioned in bug #57562, the desktop-shell panel clock ought to be configurable. Krh put the following ideas forward:
1) panel clock configurable by a string enum-- user can specify none/minutes/seconds
2) panel clock configurable by a strftime() string with 'none' as a special case
The second option would require more input validation than the first, but either is possible.
(In reply to comment #0)
> As mentioned in bug #57562, the desktop-shell panel clock ought to be
> configurable. Krh put the following ideas forward:
> 1) panel clock configurable by a string enum-- user can specify
> 2) panel clock configurable by a strftime() string with 'none' as a
> special case
> The second option would require more input validation than the first, but
> either is possible.
I looked into this and wrote a patch to make the clock format configurable. When I did this I noticed the the width allocated for the clock is hard coded to 170. I figured it would make sense to determine the width based on the text extents from cairo. However when I tried this I noticed an oddity in toytoolkit where window_get_surface() returns NULL before the first redraw (because window_set_surface() is called from window_create_surface() which creates a surface on each redraw). This means that there is no valid cairo surface available from window_get_surface() when the first widget resize is called. I managed to get it working by calling window_create_surface() when the window is created in toytoolkit, but this requires setting a non-zero allocation size. It does not necessarily have to be a valid size, just something that allows us to create the initial cairo_surface. (i.e. width=1, height=1 works)
Kristian suggested we can make font configurable too.
One other thing I will mention here is the clock update timer must be configured based on the format. The default is 60 seconds, but for formats including types such as "%s", "%S" and "%T", the timer then needs to be set to fire every second. The function I wrote uses strstr() to check for these but maybe there's a better way to solve this problem.
I am not posting a patch at this time, because of these issues.
Getting the text extents should not be a problem after this hack:
This is being worked on by Armin Krezović:
This has been implemented in weston in the following commit:
c6a55db desktop-shell: make panel clock configurable
on Mar 24, 2017 at 04:13:50.
(provided by the Example extension).