Commit graph

306 commits

Author SHA1 Message Date
Michal Siedlaczek
d826e250c8 Catch RequestException when fetching weather 2017-04-01 09:23:32 -04:00
Tobias Witek
f0bacdecd8 [modules/xrandr] Fix a crash caused by Python3
Python3 does not have sys.maxint anymore, so replace it with
sys.maxsize, which is available in both Python2 and Python3.

fixes #59
2017-03-28 19:08:17 +02:00
Chris LaRose
fe11bad826 Silence ImportErrors for optional dependencies. Fixes #55. 2017-03-25 18:35:56 -07:00
Tobias Witek
b20e83cb8a [engine] Fix interval configuration
Until now, manually specifying an interval did not work, as a cast to
float was missing. Now, it's possible to specify an update interval in
seconds via "-p interval=<interval>"

fixes #54
2017-03-16 21:04:24 +01:00
zetxx
289b42b26a fix: state, check regex result before use it 2017-03-15 23:12:55 +02:00
zetxx
0b961e2304 fix: init type 2017-03-15 23:02:13 +02:00
zetxx
69e4780182 feat: added volume level for amixer 2017-03-15 22:55:05 +02:00
Yashar Shahi
c203cd6173 [modules/pacman] Update url filtering
Arch mirrors can also have rsync protocol
2017-03-10 21:18:34 +03:30
Yashar Shahi
e2fcbfae4f [modules/pacman] Remove extra debugging raise 2017-03-10 20:02:28 +03:30
Yashar Shahi
82ce0ac834 [modules/pacman] Set thresholds
Compute weighted sum and set thresholds accordingly
2017-03-10 19:53:52 +03:30
Yashar Shahi
b9a4b590a4 [modules/pacman] Update list of repositories 2017-03-10 19:09:31 +03:30
Yashar Shahi
50d7a27487 Bug fix: pacman.py freezes the bar
Move update in a seperate thread.
2017-03-10 18:51:30 +03:30
yashar-sb-sb
88e3b8c146 Update pacman.py
Use widget to store parameters instead of using private variables.
2017-03-10 16:22:54 +03:30
Tobi-wan Kenobi
16c202a7ed [modules/disk] Remove stray unicode character in output 2017-03-10 08:17:43 +01:00
yashar-sb-sb
422348e01d Update diskspace()
Delete extra space! (looks better without the extra space. and now it's consistent with other widgets.)
2017-03-09 23:41:55 +03:30
yashar-sb-sb
3f96102b28 Update diskspace()
Add hdd icon.
2017-03-09 23:38:31 +03:30
yashar-sb-sb
dfb5bfe71c Update comment
Re-add the comment which was deleted by mistake.
2017-03-09 22:51:28 +03:30
yashar-sb-sb
9efca45b02 Update update()
Fix the issue with computation of used space.
2017-03-09 22:37:41 +03:30
yashar-sb-sb
3f17f0382e Update update module
Used shutil.disk_usage(path) instead of os.statvfs(path)
2017-03-09 20:39:40 +03:30
Tobi-wan Kenobi
826c568625 [tests] Add generic module tests
These tests check that all widgets of all modules conform to some basic
principles, at least.
2017-03-05 13:30:10 +01:00
Tobi-wan Kenobi
f9984ba386 [tests] Add unit tests for load module 2017-03-05 13:16:13 +01:00
Tobi-wan Kenobi
8724af2906 [tests/battery] Add tests for battery module 2017-03-05 09:35:56 +01:00
Tobi-wan Kenobi
90dd636b43 [tests/engine] Add test for module aliasing 2017-03-04 18:53:31 +01:00
Tobi-wan Kenobi
6a14681a65 [tests/theme] Add tests for theme.py 2017-03-04 14:17:27 +01:00
Tobi-wan Kenobi
f65ab6bcae [tests/config] Add unit tests for config.py 2017-03-04 12:11:43 +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
fe5bbd4b46 [modules/kernel] Use Python standard module "platform"
Instead of executing an external call to "uname", use the standard
Python module "platform" to retrieve information about the kernel used.

Positive side-effect: This is portable, if i3 ever exists on Windows :P
2017-03-03 19:18:25 +01:00
Tobi-wan Kenobi
955f123b88 [modules/kernel] Add documentation and vim hints 2017-03-03 19:13:30 +01:00
Pierre
bc514265d4 new module that displays current kernel
it uses the output of 'uname -r' prefixed with the linux font-awesome icon
2017-03-03 16:01:59 +01:00
Tobi-wan Kenobi
ec19f48853 [modules/weather] Remove remaining timer references
Remove obsolete _timer references.
2017-02-26 15:30:07 +01:00
Pavle Portic
44aa1bc564 [modules/weather] Add API key parameter documentation and round temperature to int 2017-02-26 14:17:26 +01:00
Tobi-wan Kenobi
a3f4b0aa6d [input] Cleaner termination logic, also, remove /tmp/bee.log
Accidentially opened file /tmp/bee.log, without writing anything to it.
2017-02-26 09:13:44 +01:00
Tobi-wan Kenobi
6d47240d6a [modules/nic] reduce code complexity (hopefully)
fixes #37
2017-02-26 09:08:36 +01:00
Tobi-wan Kenobi
8dc07e666e [modules/weather] Replace urllib with requests
Since requests works the same for python2.7 and python3.x, use requests
instead of urllib (which returns a string in python2.7, but byte data in
python3.0, at least).
2017-02-26 08:19:30 +01:00
Tobi-wan Kenobi
feb5719ecc [modules/weather] Minor reworks
* Use app-specific API key for bumblebee-status
* Add some parameters (location, unit, update interval)
* Make interval calculation based on time, not number of calls
2017-02-26 08:07:58 +01:00
Pavle Portic
49af9c14d6 [modules/weather] Add rudimentary weather module 2017-02-26 02:42:27 +01:00
Tobi-wan Kenobi
188ee36780 [modules] Add redshift module
New module that shows the current state of redshift
(day/night/transition) and, if in transition, also shows
the day/night percentages.

fixes #40
2017-01-21 11:23:29 +01:00
Tobi-wan Kenobi
87714f12ee [modules/*] Add required executables/commandline tools to help output
fixes #39
2017-01-05 04:55:14 +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
Pavle Portic
0f1725982a [modules/gpmdp] Add Google play music desktop player support 2017-01-02 21:44:53 +01:00
Tobi-wan Kenobi
a705adf207 [modules/pulseaudio] Fix status extraction
With multiple devices, extracting mute status and volumes failed
(because the loop would continue even after it found the correct device)
2016-12-20 07:49:21 +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
4f7666533c [modules/pulseaudio] Refactor callback registration
Make it easier to add/extend callbacks in the future.

fixes #35
2016-12-17 08:16:10 +01:00
Tobi-wan Kenobi
cfd1406525 [modules/pulseaudio] (Hopefully) improve parsing logic
Improve parsing logic to make code easier to understand and extend.

fixes #32
2016-12-17 08:06:58 +01:00
Tobi-wan Kenobi
220bb9bf60 [core/input] Ugly hack for responsiveness
Somehow, the fix in the previous commit didn't work, it seems that
sometimes epoll() doesn't trigger, even if there is more data in
sys.stdin. I'm sure I'm doing something horribly wrong here.

Anyhow, as a quick fix, check for the open bracket to be sure to not
buffer the first event too long.
2016-12-17 08:04:21 +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
71cc0c216f [engine/config] Add helptexts 2016-12-15 19:44:49 +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
999547f794 [modules/layout] Re-enable keyboard layout switcher
Displays the current layout and allows switching to next/previous
configured layout via mouse clicks.
2016-12-11 15:00:13 +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
d10fc814ed [modules/dnf] Re-enable DNF update checking module
see #23
2016-12-11 12:53:31 +01:00
Tobi-wan Kenobi
dd6b13265d [modules/pacman] Re-enable pacman update information
see #23
2016-12-11 12:42:49 +01:00
Tobi-wan Kenobi
1d6ca352b9 [modules/xrandr] Re-enable xrandr module
Displays the connected screens and allows the user to enable/disable
them.

see #23
2016-12-11 12:23:33 +01:00
Tobi-wan Kenobi
17ee621a5a [modules/ping] Spawn thread on-the-fly
Instead of having a thread that runs in the background continuously,
spawn a new one for every update interval. That speeds up the tests
quite a lot.

see #23
2016-12-11 11:50:15 +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
23d7d53fca [modules] critical/warning threshold refactoring
Quite a lot of modules use the "if higher X -> critical, if higher Y ->
warning" idiom now, so extracted that into a common function for reuse.

see #23
2016-12-11 08:25:54 +01:00
Tobi-wan Kenobi
edfccd2d31 [modules/spacer] Re-enable "spacer", the text-display widget
see #23
2016-12-11 08:17:37 +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
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
a1455c9687 [modules/battery] Handle inexistent battery more gracefully 2016-12-10 19:54:31 +01:00
Tobi-wan Kenobi
14b8feeef1 [modules/datetime] Add help text 2016-12-10 19:30:25 +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
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
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
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