Commit graph

292 commits

Author SHA1 Message Date
Tobi-wan Kenobi
1a4cddb0b6 [core] Fix callback registration ("shadowed" events)
Until now, as soon as a widget registered *any* callback, the default
callbacks (e.g. scroll up/down to go to next/previous workspace) didn't
work anymore, as there was a better match for the general registration
(even though not for the button).

To fix this, merge the callback registration into a flat registration,
where a key is calculated from the ID of the registrar and the
registered button.

see #23
2016-12-11 07:38:56 +01:00
Tobi-wan Kenobi
d91294f010 [modules/battery] Fix ac and unknown display
If the computer runs on AC, display that instead of showing "100%" in
the status.

Also, if reading the charging status fails for some reason (except the
computer being on AC), go into critical state and display "n/a".

see #23
2016-12-11 07:28:15 +01:00
Tobi-wan Kenobi
2cc2cf8282 [core/engine] Add aliasing mechanism to modules
Allow modules to define aliases. This replaces the symlink mechanism
that was in place previously, because it was a bit ugly (and confused
code climate).

see #23
2016-12-11 07:18:06 +01:00
Tobi-wan Kenobi
8f759e6134 [CI] Add config file for Code Climate 2016-12-10 22:20:55 +01:00
Tobi-wan Kenobi
fbd7801d8d [CI] Disable test coverage reporting
Seems to work only for the default branch, so disable until merge back
to master.
2016-12-10 22:15:25 +01:00
Tobi-wan Kenobi
83488fe97f [CI] Add Code Climate token for test coverage
Let's see if/how code coverage works.
2016-12-10 22:12:02 +01:00
Tobi-wan Kenobi
14ca6d5cf0 [doc] Add code climate shield to README.md 2016-12-10 20:09:42 +01:00
Tobi-wan Kenobi
547b3dc296 [doc] Re-add README.md 2016-12-10 20:05:02 +01:00
Tobi-wan Kenobi
e8f9a50cf7 [CI] Removing Python 3.2, as it complains about unicode strings
Honestly: I have *no idea* how to fix this, so for the time being,
Python 3.2 won't be supported.
2016-12-10 20:00:09 +01:00
Tobi-wan Kenobi
c44b529c1f [CI] Add more Python versions to Travis
Now that the tests run through with Python2.7, extend the list of Python
versions to be supported.
2016-12-10 19:55:40 +01:00
Tobi-wan Kenobi
a1455c9687 [modules/battery] Handle inexistent battery more gracefully 2016-12-10 19:54:31 +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
921afe475f [CI] Restrict Travis to Python2.7 only until build works 2016-12-10 19:37:03 +01:00
Tobi-wan Kenobi
6e3a9ec4d3 [CI] Add "mock" to Travis dependencies 2016-12-10 19:36:40 +01:00
Tobi-wan Kenobi
2e2351a69e [tests] Mock Popen() in module tests 2016-12-10 19:35:38 +01:00
Tobi-wan Kenobi
c23af541e4 [CI] Add psutil and netifaces to Travis dependencies 2016-12-10 19:32:22 +01:00
Tobi-wan Kenobi
14b8feeef1 [modules/datetime] Add help text 2016-12-10 19:30:25 +01:00
Tobi-wan Kenobi
2c766d0c97 [CI] Initial travis configuration 2016-12-10 19:27:50 +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
8f6bb7b45d [core/input] Remove "valid input required" logic from input
Accidentially committed a experimental way to enforce waiting for a
valid input, mainly for testing.

see #23
2016-12-10 18:22:05 +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
0489ce1b51 [core/engine] Register wheel up/down callbacks for desktop switch
Switch desktop to prev/next on wheel up/down.

see #23
2016-12-10 12:14:12 +01:00
Tobi-wan Kenobi
7ea8c5320d [modules] Add help texts
see #23
2016-12-10 12:03:58 +01:00
Tobi-wan Kenobi
4d4a7bf29d [modules/battery] Re-enable battery module
Extend theme to be able to accept lists of values and cycle through
them. Use this to "animate" the charging symbol for the battery.

see #23
2016-12-10 12:00:08 +01:00
Tobi-wan Kenobi
72e375ac8b [modules/nic] Check for vanished interfaces
If a widget exists for an interface that is not there anymore (i.e. a
tunnel interface that has been removed, or a USB device that has been
unplugged), remove that widget from the list.

see #23
2016-12-10 11:33:35 +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
c820223d0c [core/input] Execute commands in background
When spawning a command from an input interaction, do it in the
background, so as to not block further interactions.

see #23
2016-12-10 10:47:23 +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
b1ec41f905 [modules/cmus] Add mouse controls
Enable play/pause, repeat/shuffle toggle, next/prev song by clicking on
the various elements in the bar.

see #23
2016-12-10 08:19:24 +01:00
Tobi-wan Kenobi
1a3217bb5f [modules/cmus] Add status callback
Inform the theme about the current playback status (start, stop, repeat,
shuffle).

see #23
2016-12-10 08:16:27 +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