Commit graph

73 commits

Author SHA1 Message Date
Tobi-wan Kenobi
f0013c7581 [tests/util] Add test for execute with wait=False 2017-03-04 11:35:46 +01:00
Tobi-wan Kenobi
6dbe440cb5 [tests] Purge tests and start with a clean implementation of subprocess
Seems like subprocess and friends (Popen, communicate) are not so easy
to mock cleanly. Therefore, start from scratch and carefully write test
by test, until (at least) the old test coverage has been restored.
2017-03-04 11:25:52 +01:00
Tobi-wan Kenobi
d3fc5094f8 [modules/gpmdp] Make unit tests run through
* full_text needs to return a string *always*
* relax full_text check to also allow unicode results
2017-01-02 22:26:57 +01:00
Tobi-wan Kenobi
846d28714a [tests] Add tests for bumblebee.util
Add tests for the utility functions and fix a few embarrassing bugs in
the process.
2016-12-17 09:00:49 +01:00
Tobi-wan Kenobi
9a350ddc2a [tests/config] Add tests for helptexts
Ensure that each theme is listed in the helptext and that there is a
helptext entry for every module.
2016-12-17 08:42:23 +01:00
Tobi-wan Kenobi
f6be25bc73 [core/input] Move from select to epoll
Use epoll instead of select in order to be able to use level-triggered
semantics and not get stuck on the first event.
2016-12-17 07:43:38 +01:00
Tobi-wan Kenobi
31f9154be2 [help] Add theme and module listing
Re-enable the possibility to list available themes and modules.

fixes #29
2016-12-17 07:05:23 +01:00
Tobi-wan Kenobi
5e305bf3b6 [engine/input] Re-enable mouse button parameter bindings
Re-enable the possibility to define custom mouse actions by binding
commands to "<alias|module>.<left-click|right-click|...>". These
commands are then executed as shell commands.

fixes #30
2016-12-15 19:41:50 +01:00
Tobi-wan Kenobi
75f5af4866 [core/input] Skip partial events
Clicking on a separator creates partial events ("instance" missing).
Ignore those events, as they crash the input processor.

fixes #31
2016-12-11 13:43:34 +01:00
Tobi-wan Kenobi
9878bbf971 [tests] Fix automated testrun in Travis
Forgot to mock Popen() in setUp
2016-12-11 12:31:37 +01:00
Tobi-wan Kenobi
9fe0915730 [tests] Add mocking for module tests 2016-12-11 12:26:28 +01:00
Tobi-wan Kenobi
71582cbcd7 [modules/ping] Re-enable ping module
Show RTT measured by ICMP echo request/replies for a given host.

For that to work correctly, change the "full_text" callback for a widget
so that the widget itself is also passed as argument in the callback
method. That actually makes a lot of sense, since the widget can now be
used as a repository of state information.

see #23
2016-12-11 11:37:24 +01:00
Tobi-wan Kenobi
666daff9a6 [modules/pulseaudio] Re-enable pulseaudio module
Display volume for default PulseAudio source/sink, change volume and
mute/unmute device.

see #23
2016-12-11 08:51:56 +01:00
Tobi-wan Kenobi
c2c70da4ef [tests/disk] Fix copy/paste error - duplicate method name 2016-12-11 08:45:43 +01:00
Tobi-wan Kenobi
e603a2cb26 [tests/battery] Forgot a mock in previous commit 2016-12-11 08:14:55 +01:00
Tobi-wan Kenobi
7db80b6d3b [tests/battery] Mock exists() call for Travis CI 2016-12-11 08:11:26 +01:00
Tobi-wan Kenobi
c8fc75a401 [modules/load] Re-enable load module
Display system load and show warning/critical error when load is above a
certain threshold (compared to the number of available CPUs).

see #23
2016-12-11 08:01:43 +01:00
Tobi-wan Kenobi
4bd13c2f63 [tests] Refactor i3barinput
Use the assertMouseEvent helper in i3barinput.

see #23
2016-12-11 08:01:16 +01:00
Tobi-wan Kenobi
716bafa90e [tests] Fix unit tests (at least on my system) 2016-12-10 19:45:13 +01:00
Tobi-wan Kenobi
2e2351a69e [tests] Mock Popen() in module tests 2016-12-10 19:35:38 +01:00
Tobi-wan Kenobi
d41c142d4a [modules/memory] Re-enable memory usage module
Add module that shows RAM consumption and opens the gnome-system-monitor
on click.

see #23
2016-12-10 19:20:19 +01:00
Tobi-wan Kenobi
16a4613e57 [tests] Minor refactoring
Draw some commonly-used assertion logic into common functions.

see #23
2016-12-10 19:08:29 +01:00
Tobi-wan Kenobi
e15147fe10 [tests/disk] Add critical/warning threshold tests for disk module
see #23
2016-12-10 18:49:25 +01:00
Tobi-wan Kenobi
12f5ce5977 [modules/disk] Re-enable disk usage module
Add a module that shows the disk usage for various paths and opens
nautilus on that path whenever it is clicked.

see #23
2016-12-10 18:21:01 +01:00
Tobi-wan Kenobi
771c597ce9 [modules/caffeine] Re-implement caffeine module
Add caffeine module & add a framework for testing it (no tests yet,
though).

see #23
2016-12-10 15:36:18 +01:00
Tobi-wan Kenobi
163419063d [tests/battery] Add some tests for the battery module
see #23
2016-12-10 14:50:49 +01:00
Tobi-wan Kenobi
1b8385b33f [modules/brighness] Re-enable brightness module
Add a module for reporting, increasing and decreasing the brightness of
a display.

see #23
2016-12-10 14:31:18 +01:00
Tobi-wan Kenobi
029492e16d [core] Non-blocking input thread for i3bar events
Make input thread non-blocking by using select(). This increases the CPU
utilization a bit (depending on the timeout), but makes the thread exit
cleanly, even if an exception is thrown in the main thread.

see #23
2016-12-10 13:45:54 +01:00
Tobi-wan Kenobi
a045962d00 [modules/nic] Re-enable NIC module
Re-add the NIC module with all its functionality (hopefully...).

This introduces a new concept: Instead of having separate queries for
critical and warning (which really are just another set of states), a
module can now return a list of states for each widget. All the state
information is then merged together into a single theme. So, for
instance, the NIC module can return a state saying "critical -
wlan-down", which applies the theme information for both "critical" and
"wlan-down".

see #23
2016-12-10 11:25:02 +01:00
Tobi-wan Kenobi
918d7a6046 [core/input] Add callback deregistration
Enable components to unregister callbacks (i.e. for dynamic widgets).

see #23
2016-12-10 10:26:07 +01:00
Tobi-wan Kenobi
761b81970d [modules/cpu] Pad to 3 digits before comma to fix width
I cannot get the min_width property to work right now, so in order to
fix the width of the CPU widget, pad the utilization to 3 digits (so
that even 100% aligns nicely).

see #23
2016-12-10 09:04:12 +01:00
Tobi-wan Kenobi
38a42e4a77 [tests/cmus] Add tests for cmus mouse interaction
see #23
2016-12-10 08:37:04 +01:00
Tobi-wan Kenobi
225d471c6a [modules/cpu] Add configurable warning and critical thresholds
The cpu module now has cpu.warning and cpu.critical thresholds. If the
CPU utilization is higher than any of those values, the widget's state
changes to warning or critical, respectively.

see #23
2016-12-10 08:09:13 +01:00
Tobi-wan Kenobi
87e76b9e40 [modules/cmus] Re-add cmus module
Re-add a first version of the cmus module originally contributed by
@paxy97.

Still missing:
* Icon themes (status)
* On-click actions

see #23
2016-12-10 07:47:24 +01:00
Tobi-wan Kenobi
9ce7739efb [tests] Add specific tests for CPU module
* Check that the left mouse button action works
* Check that the format is OK

see #23
2016-12-09 22:28:04 +01:00
Tobi-wan Kenobi
e72c25b0bc [core] Add input processing
Create infrastructure for input event handling and add i3bar event
processing. For each event, callbacks can be registered in the input
module.
Modules and widgets both identify themselves using a unique ID (the
module name for modules, a generated UUID for the widgets). This ID is
then used for registering the callbacks. This is possible since both
widgets and modules are statically allocated & do not change their IDs.

Callback actions can be either callable Python objects (in which case
the event is passed as parameter), or strings, in which case the string
is interpreted as a shell command.

see #23
2016-12-09 19:29:16 +01:00
Tobi-wan Kenobi
fa30b9505b [all] More pylint fixes
see #23
2016-12-09 16:33:29 +01:00
Tobi-wan Kenobi
4baf63f88c [core/themes] Add state themes
Each widget can now return a state using the method "state()". This
string is then used to look up a theme information which is used instead
of the default or module theme, if found.

see #23
2016-12-09 13:32:22 +01:00
Tobi-wan Kenobi
88b36417f8 [core/theme] Fix padding
Missing prefix/suffix broke padding.

see #23
2016-12-09 13:06:08 +01:00
Tobi-wan Kenobi
c1f1e1a939 [core/themes] Add separator customization
Add customized separators:
* The default separators are automatically disabled if custom separators
  are used (to "just" disable the default, use empty custom separators)
* Use previous background color as their background color and the
  current background color as foreground color
* Allow the separator-block-width to be configured

see #23
2016-12-09 12:55:16 +01:00
Tobi-wan Kenobi
527489e0de [core/themes] Add "cycling" support
Allow a theme to define a "cycle" of attributes that are cycled through
on a widget-per-widget basis (e.g. for alternating the widget
background). These cycles take precedence over the default values, but
can be overridden by module-specific theme instructions.

see #23
2016-12-09 12:28:39 +01:00
Tobi-wan Kenobi
59fb47ae3b [all] pylint cleanup 2016-12-09 11:57:13 +01:00
Tobi-wan Kenobi
e59e969bdc [core] Refactor -> replace some getter/setter pairs with attributes
Remove some set_* methods and replace them with a simple attribute.

see #23
2016-12-09 11:49:59 +01:00
Tobi-wan Kenobi
068968bbf5 [tests] Refactor by removing getter/setter methods
Instead of having get/set methods for simple attributes, use the
attributes directly.

see #23
2016-12-09 11:42:02 +01:00
Tobi-wan Kenobi
c52cb99518 [core/theme] Add support for foreground and background colors
Themes can now define "fg" and "bg" attributes that are used for
foreground (text) color and background color.

see #23
2016-12-09 09:02:19 +01:00
Tobi-wan Kenobi
0c7884d170 [all] pylint refinements
Improve code by bringing up the pylint score a bit.

see #23
2016-12-09 08:43:14 +01:00
Tobi-wan Kenobi
252260c249 [modules/datetime] Use parameter functionality to get format
Make the format string of the datetime module configurable using the new
parameter() method in the module.

Also, restructured the setting of the config information a bit so that
the parameter() method can be used in the constructor of a module.

see #23
2016-12-09 08:23:53 +01:00
Tobi-wan Kenobi
f33711f49f [core] Pass configuration parameters to modules
User can now use -p <key>=<value> to pass configuration parameters to
modules. For this, the module gets a "parameter()" method. Parameter
keys are in the format <name>.<key> where <name> is the name of the
loaded module. This is either the name of the module itself (e.g. "cpu")
or its alias, if the user specified it, for example:

bumblebee-status -m cpu -p cpu.warning=90

vs.

bumblebee-status -m cpu:test -p test.warning=90

see #23
2016-12-09 08:00:26 +01:00
Tobi-wan Kenobi
c8a51b416f [core] Add "Store" interface
Add an interface that allows arbitrary objects to store/retrieve
arbitrary key/value pairs. This will be used for different purposes in
the future:

* Config class(es) can store user-defined parameters for modules
* Widgets can store state
* ???

see #23
2016-12-09 07:41:07 +01:00
Tobi-wan Kenobi
a7e756e015 [tests] Generic module tests
Add a helper function that lists all existing modules and modify the CPU
module test so that it now generically iterates all available modules
and tests their widgets.

see #23
2016-12-09 07:27:01 +01:00