Commit graph

908 commits

Author SHA1 Message Date
Daniel Eklöf
5a2f4a3ece module/battery: run(): return 0 on success 2018-12-29 18:01:40 +01:00
Daniel Eklöf
62997eda8c bar: run(): only return 0 if all modules exited with 0 2018-12-29 18:01:21 +01:00
Daniel Eklöf
449210cc07 main: use bar's return value as exit value 2018-12-29 17:57:30 +01:00
Daniel Eklöf
10877d7c2e main: error handling 2018-12-29 17:56:26 +01:00
Daniel Eklöf
825c5c82b5 main: load config file from ~/.config/f00bar/config.yml 2018-12-29 17:54:33 +01:00
Daniel Eklöf
6d082f9f99 bar: disable debug logging 2018-12-29 17:54:24 +01:00
Daniel Eklöf
1f182b862e particle/progress-bar: allow user to configure an on-click handler
Since we're typically interrested in *where* (on the progress-bar) the
user clicked, we need a way to pass the clicked position to the
handler.

Normally, the on-click handler is expanded when a particle
instantiates its exposable. At this point, we (obviously) don't have
the click position.

This is solved by expanding the handler a second time, when the bar is
clicked.

Thus, the user can use the "{where}" tag in the click handler. "where"
will be expanded to a percentage value (0-100).
2018-12-29 17:36:34 +01:00
Daniel Eklöf
bd365405d7 particle/list: remove excessive debug output 2018-12-29 17:14:49 +01:00
Daniel Eklöf
421f1466df bar: reset cursor and return when mouse is at a border 2018-12-29 17:13:38 +01:00
Daniel Eklöf
7da09530b8 particle/string: tags_expand_template() now returns NULL if template is NULL 2018-12-29 17:12:11 +01:00
Daniel Eklöf
6857b99c56 particle/list: tags_expand_template() now returns NULL if template is NULL 2018-12-29 17:11:54 +01:00
Daniel Eklöf
32b4e9986d tag: tags_expand_template(): return NULL if template is NULL 2018-12-29 17:10:54 +01:00
Daniel Eklöf
85801a5deb particle/string: expand on_click handler before passing to exposable 2018-12-29 17:10:10 +01:00
Daniel Eklöf
aee4805df8 particle/list: expand on_click handler before passing to exposable 2018-12-29 17:09:57 +01:00
Daniel Eklöf
ed86061532 particle: refactor 2018-12-29 17:04:39 +01:00
Daniel Eklöf
ab67d036ae tags: break out string formatting from particle/string 2018-12-29 17:03:41 +01:00
Daniel Eklöf
620017860e particle: handle ON_MOUSE_CLICK
If a particle has an on-click handler, execute it when we receive an
ON_MOUSE_CLICK event.

This is done by first tokenizing the command string. We currently
handle one level of quotes, but no escape characters.

Then, fork(). Main process waits for child to finish. Child daemonizes
and then execvp() the tokenized argument vector.
2018-12-29 16:24:22 +01:00
Daniel Eklöf
abc4ff0402 bar: generate exposable ON_MOUSE_CLICK events on button release events 2018-12-29 16:23:27 +01:00
Daniel Eklöf
88bcf425bf particle/list: on_click handler 2018-12-29 16:15:37 +01:00
Daniel Eklöf
68606e49ed config: clean up particle_list_from_config() 2018-12-29 16:14:09 +01:00
Daniel Eklöf
b2082e38ed yml: support multiple merge values
This adds support for merging multiple values, using a list of
dictionaries:

    foo:
      <<: [*foo, *bar]
2018-12-29 16:06:04 +01:00
Daniel Eklöf
36e3bdd9fd particle/list: override on_mouse()
If we have our own on_click handler, call the default
implementation. Otherwise, check which sub-particle the mouse is over,
and delegate the on_mouse() call.
2018-12-29 14:46:29 +01:00
Daniel Eklöf
cecab625ac particle: implement a default on_mouse handler
Which changes the cursor to a hand when there's a non-NULL on-click
handler.
2018-12-29 14:40:45 +01:00
Daniel Eklöf
9e5dbfe27d particle/string: constructor now takes an 'on_click_template' 2018-12-29 14:38:10 +01:00
Daniel Eklöf
5164d1d6ea particle: add an 'on_click_template' to base constructor.
This is intended to be a format-like string, with the possibility to
use tag formatters.

The expanded string will later be passed to the system() call.
2018-12-29 14:36:18 +01:00
Daniel Eklöf
6019129acc config: clean up particle_string_from_config() 2018-12-29 14:30:09 +01:00
Daniel Eklöf
7670473735 bar: call exposable's on_mouse() on mouse motion events
For this to be doable, the bar no longer destroys the module's
exposables after rendering them. Instead, we keep them around, letting
them represent the "current" content of the bar.

Then, when we receive a mouse motion event, we can iterate the
exposables and calculate which one of them the mouse is over, and call
its on_mouse() function.
2018-12-29 12:56:10 +01:00
Daniel Eklöf
1cb268f2e7 exposable: define an 'on_mouse' interface function 2018-12-29 12:55:51 +01:00
Daniel Eklöf
e8d8bf70d3 exposable: add a "common" constructor and default destructor 2018-12-29 12:51:31 +01:00
Daniel Eklöf
acda1a4b21 module: re-order function pointer declarations 2018-12-29 12:49:25 +01:00
Daniel Eklöf
4d173326e4 particle: remove 'parent' (it wasn't used anyway) 2018-12-29 12:49:00 +01:00
Daniel Eklöf
cc654eda57 module/mpd: cleanup 2018-12-28 15:26:22 +01:00
Daniel Eklöf
97b279ff82 module/mpd: don't detach refresh thread
Instead, abort and join previous thread (if any), just before creating
a new one.

Abort/join the last one when destroying the module.

Note: we may end up with a dangling (non-joined) thread for a
while (for example, when state goes from playing -> paused/stopped).

It will however be joined eventually; either when state goes to
'playing' again, or when the module is destroyed.
2018-12-28 14:22:17 +01:00
Daniel Eklöf
cc59593f29 module/mpd: idle mask variable is unused, when we don't debug log 2018-12-28 14:15:03 +01:00
Daniel Eklöf
0103eff3a0 module/mpd: free album/artist/title before replacing them 2018-12-28 14:14:43 +01:00
Daniel Eklöf
f2a3deb362 particle/progress-bar: disable debug logging 2018-12-28 14:14:31 +01:00
Daniel Eklöf
64af167d66 module/mpd: disable debug logging 2018-12-28 14:14:21 +01:00
Daniel Eklöf
d8274c2c9c module/mpd: refresh thread only resets refresh_abort_fd if it's "ours"
That is, we only reset it if the module main thread haven't already
done so (and quite possibly created another eventfd).
2018-12-28 14:08:45 +01:00
Daniel Eklöf
b40069616c module/mpd: refresh_abort_fd now uses -1 to indicate there are is no active thread 2018-12-28 14:08:16 +01:00
Daniel Eklöf
ba31a557f5 module/mpd: refresh thread calls bar->refresh() directly
This is possible, since content() now calculates the correct 'elapsed'
time, based on the time the original elapsed value was received from
MPD.
2018-12-28 14:07:06 +01:00
Daniel Eklöf
f74f2ad031 module/mpd: elapsed and duration are now tracked in millseconds 2018-12-28 14:06:13 +01:00
Daniel Eklöf
3027b6cd9e particle/progress-bar: add debug log 2018-12-28 14:05:17 +01:00
Daniel Eklöf
b0f0a1e942 tag: add realtime unit MSECS (milliseconds) 2018-12-28 14:05:02 +01:00
Daniel Eklöf
13cc11e200 tag: refresh_in() *must* use the realtime unit 2018-12-28 14:04:35 +01:00
Daniel Eklöf
67bd38f5df module/mpd: implement refresh_in() 2018-12-28 12:47:18 +01:00
Daniel Eklöf
89ebfa0dbb module/mpd: remember *when* the 'elapsed' member was set.
This allows us to update the elapsed field without having to talk to
MPD.

In particular, it fixes a bug where we reported the same elapsed value
when we we're updated due to *other* modules calling bar->refresh().
2018-12-28 12:47:14 +01:00
Daniel Eklöf
adb70e9f35 particle/progress-bar: force-refresh realtime tags
When we're tracking a realtime tag, calculate the time left until the
next segment in the progress bar will get filled, and schedule a force
refresh.
2018-12-28 12:43:54 +01:00
Daniel Eklöf
20b3299afd tag: add a refresh_in() interface function
E.g. particles may use this to force a refresh after a certain amount
of time.

Note that it can only be used with 'realtime' tags.
2018-12-28 12:43:02 +01:00
Daniel Eklöf
5008008079 module: add a refresh_in() interface function
Modules can implement this to allow e.g. particles to force a refresh
after a certain amount of time.
2018-12-28 12:42:08 +01:00
Daniel Eklöf
1ed0dab6ad config: raise default battery poll interval from 30s to 60s 2018-12-28 12:41:38 +01:00