Commit graph

978 commits

Author SHA1 Message Date
Tobias Witek
4e0e3ef427 [general] Add Python3 support
* Change some formatting to please python3
* remote pyroute2 dependency, for which I didn't find a python3 module
  in Fedora24

this solves #1
2016-11-05 16:33:35 +01:00
Tobias Witek
caceb6f20f [help] Update and beautify the commandline help output 2016-11-05 16:18:53 +01:00
Tobias Witek
3af8ee771d [general] Refactoring
* remove (hopefully) unnecessary import statements
* make some code a bit more compact
* remove dead code ... again: hopefully so
2016-11-05 15:54:34 +01:00
Tobias Witek
e889098c77 [modules/disk] Remove "custom" instance callback
This callback just makes it really hard to see for the user what is
going on. The alias the user provides should *always* match the
instance, so that it can be used in a meaningful way in the click
action, for example (otherwise, something like "nautilus {instance}"
gets really hard to interpret.
2016-11-05 15:45:33 +01:00
Tobias Witek
67142d642b [module/output] Re-enable user configurable mouse click events
This is now much nicer implemented to address issue #3. A user can now
have a configuration parameter mapped to a module instance (via the
module name or the instance name) with the value "left-click",
"right-click", etc., like this:

-m disk:home -p home.left-click="nautilus {instance}"
2016-11-05 15:39:21 +01:00
Tobias Witek
26f5fd3064 [modules] Re-enable preconfigured on-click actions 2016-11-05 15:28:33 +01:00
Tobias Witek
c821deec1c [modules/time] bugfix: Use module instance format 2016-11-05 14:43:03 +01:00
Tobias Witek
2d873387ea [modules] Re-enable DNF module 2016-11-05 14:37:07 +01:00
Tobias Witek
4e648cf009 [modules] Add module-specific configuration
Big oversight in my previous commits: Widgets need to be able to have
specific configurations (i.e. the path for different instances of the
"disk" module has to be different).

To account for that, it is now possible to assign an "alias" to a module
instance using ":" (for example: -m "disk:home"). This alias is then
used for the configuration parameter resolution automatically, for
example:

-m disk:home -p home.path=/home

As a consequence, parameter names in the module code are now relative to
the module, which means: shorter!
2016-11-05 14:26:02 +01:00
Tobias Witek
9f9b27ad7a [modules] Re-enable spacer 2016-11-05 13:53:08 +01:00
Tobias Witek
fb466bfd91 [modules] Re-enable pulseaudio modules 2016-11-05 13:50:51 +01:00
Tobias Witek
db8737a6aa [modules/nic] Add interface type cache to avoid too many open files
Repeatedly querying the interface type the way I'm doing right now
results in "too many files open" pretty quickly. Obviously, it's a bit
of a concern that I am leaking a file descriptor somewhere, but for now,
the quickfix is to cache the type (it shouldn't change, anyhow).
2016-11-05 13:47:27 +01:00
Tobias Witek
a9a62a738d [modules] Re-enable nic module + allow widget states
All callback from a widget into a module (e.g. for retrieving the status
or the criticality state) now get a widget passed. This has the purpose
of allowing a module to store state/widget specific data somewhere. This
way, for instance, it is possible to store the interface name as part of
the widget, thus making it possible to show the status of the correct
interface.
2016-11-05 13:42:26 +01:00
Tobias Witek
bd0089dac0 [modules] Re-enable "disk" module 2016-11-05 13:23:46 +01:00
Tobias Witek
286aff2aa0 [output] Allow modules to pass back a single widget
Since "single widget" is the 99% use-case, make it easier for a module
to return a single widget.
2016-11-05 13:12:30 +01:00
Tobias Witek
2cfb0997a0 [modules] Re-enable battery module
Enable battery module with new states:
* discharging-[10,25,50,80,100]
* charging
* charged
2016-11-05 13:09:28 +01:00
Tobias Witek
18d7e1befb [config] Allow parameter passing via commandline
Allow the user to specify arbitrary configuration parameters from the
commandline and evaluate those in the modules (and elsewhere). Re-enable
the CPU module as a first showcase of this functionality.
2016-11-05 12:28:05 +01:00
Tobias Witek
353c47d76e [general] Very minor refactoring 2016-11-05 12:18:30 +01:00
Tobias Witek
73d62d7ded [widgets] Pass through some information to the underlying module object
For determining status, critical/warning state, etc. simply let the
widget pass through a call to the underlying object.
2016-11-05 12:14:33 +01:00
Tobias Witek
2f0cc30c38 [config] Write custom action for printing theme/module details 2016-11-05 12:07:54 +01:00
Tobias Witek
998db40a2d [theme] Re-implement rotation of values for theme entries
Allow theme entries to be lists that are then iterated. For this
purpose, extend the Config class so that it can serve as generic store
for data items. That makes it easy to centralize code used for rotation
etc. in a single place.
2016-11-05 11:57:09 +01:00
Tobias Witek
98acd15edf [theme] Re-implement colorscheme cycling
Again, allow the "default" section to contain cycles that are used one
after the other for each widget.
2016-11-05 11:40:27 +01:00
Tobias Witek
bab7821607 [all] Refactor module <-> output communication
Modules now return "bumblebee.output.Widget" objects, so that they can
actually define a list of items to be drawn in the bar.
2016-11-05 08:59:43 +01:00
Tobias Witek
7f91b8298f [modules] Refactor module initialization
Modules now get an output and a complete config object. This should make
customization much easier in the future.
2016-11-05 08:11:08 +01:00
Tobias Witek
c2adf38b92 [engine] Remove obsolete Argument class 2016-11-05 08:00:47 +01:00
Tobias Witek
a8b29ed22e [config] Beautify help output a bit 2016-11-05 07:59:58 +01:00
Tobias Witek
a58610f3ee [config] Start refactoring by creating separate config class
Add a class that will hold all configuration and argument information
and serve as central repository for this kind of information.
2016-11-05 07:54:36 +01:00
Tobias Witek
9da9fdaaa5 [engine] Add missing import 2016-11-05 06:47:22 +01:00
Tobias Witek
55474aadc3 [general] Minor refactoring
Shuffled some code around in an attempt to make it easier to read and
understand.
2016-11-04 21:41:22 +01:00
Tobias Witek
47935942f0 [engine] Reformat a bit (line breaking)
Break some extensively long lines
2016-11-04 21:18:07 +01:00
Tobias Witek
ea27ccb2c1 [output] Add waiting capability to output
Engine now calls wait on output for further data, is interrupted
on new data.
2016-11-04 21:10:21 +01:00
Tobias Witek
d62258c89d [all] Major refactoring
Introduce an "Engine" class to abstract some of the details of loading
modules, registering events, etc.
2016-11-04 21:03:12 +01:00
Tobias Witek
b99c454a5a [main] Redraw on click
Whenever a module in the bar is clicked, immediately redraw the line, to
make for a snappier user experience (especially when muting/unmuting).
2016-11-04 19:11:10 +01:00
Tobias Witek
89b97d7283 [modules/dnf] Only do update check every 'interval'
Yet another bug in the DNF module - really a troublesome one. Only call
the dnf updateinfo every interval, not every second. That significantly
reduces CPU load.
2016-11-04 19:01:19 +01:00
Tobias Witek
fb6337c625 [modules/dnf] DNF module was not updating properly
Due to name-clashing of the datetime module's "time" alias, time.sleep
didn't work (as it was looked up from the i3bumblebee module),
consequently, the DNF poll thread exited.

While at it, "beautify" the thread cancelling a bit by waiting until
the main thread is not running anymore.
2016-11-04 18:50:38 +01:00
Tobias Witek
6e8acc2765 [modules/memory] Show used instead of free RAM 2016-11-03 19:45:48 +01:00
Tobias Witek
29131e2f65 [modules/nic] Exclude docker and vbox interfaces
Until I have a clue on how to correctly handle them, exclude
docker and vbox network interfaces.
2016-11-03 19:45:12 +01:00
Tobias Witek
5532526595 [modules/dnf] Fix a bug wrt. counter extraction
Bugfixes and enhancements were wrongly extracted.
2016-11-03 19:44:34 +01:00
Tobias Witek
6fa7f9d789 [modules/disk] Show used instead of free disk 2016-11-03 19:44:11 +01:00
Tobias Witek
329f546879 [modules/battery] Cap capacity at 100%
Seems like my laptop at work is overly enthusiastic when it comes to
charging. I don't believe in 105% capacity.
2016-11-03 19:43:30 +01:00
Tobias Witek
7b62aeb67c [output/i3] Restrict workspace rotation to current output 2016-11-01 08:31:59 +01:00
Tobias Witek
4c34cd37d4 [modules] Add default click events to various modules
* cpu+memory: Open "gnome-system-monitor"
* disk: Open nautilus
* pulseaudio: Mute/unmute, open "pavucontrol" on right-click, raise/lower
  volume on mouse wheel up/down
2016-11-01 08:18:46 +01:00
Tobias Witek
fca3171556 [modules] Allow modules to provide default click actions
Pass the "output" object to the modules' constructor to allow them to
define their own callbacks.
Any user-provided callbacks take precedence and override those of the
module.
2016-11-01 08:09:10 +01:00
Tobias Witek
a63094af47 [output] Using "instance" for callback registration doesn't make sense
"instance" is actually better suited to be an argument to the callback
(which it already is) than part of the key for callback lookup.
2016-11-01 07:58:50 +01:00
Tobias Witek
7c2170f58a [i3] Use Popen instead of call - async call
subprocess.call() blocks until the command finishes - Popen is better
for executing in the background :)
2016-11-01 07:58:12 +01:00
Tobias Witek
579381978e [output] Add support for click-events in i3
The i3 output now has a separate thread that continuously monitors stdin
for incoming click events. The generic output class also has methods for
registering callbacks (as commands). For now, by default, scroll events
will be used to emulate the next/previous workspace.
2016-11-01 07:46:26 +01:00
Tobias Witek
43fcbd9306 [doc] Add updated themes and screenshots 2016-10-31 17:58:50 +01:00
Tobias Witek
f02c49286b [main] Add available themes to listing output 2016-10-31 16:47:34 +01:00
Tobias Witek
c0421163d4 [doc] Add description, usage and notes to all modules 2016-10-31 16:08:03 +01:00
Tobias Witek
598f3e70e9 [main] Initial support for "-l" parameter
List all available modules and query their description, notes and usage.
2016-10-31 15:49:15 +01:00
Tobias Witek
b2e9515861 [themes/solarized-powerline] switch default colors 2016-10-31 15:31:07 +01:00
Tobias Witek
f72d905d97 [modules] Add "spacer"
Add a very, very basic module that simply adds a spacer (and empty
element) to the bar.
2016-10-31 15:23:59 +01:00
Tobias Witek
bcf0264f99 [modules] Add DNF supervision module
Add a module that periodically (by default, once every 30min) calls
"dnf updateinfo" and evaluates the results to report the number of
bugfixes, enhancements, etc.

If there's either too many pending updates, or at least one security
update, the module goes critical.
2016-10-31 15:17:51 +01:00
Tobias Witek
b3e17d4899 [modules/date] Combine to datetime module with date and time aliases
Move module "date" to "datetime" (display both date and time), and
create new aliases "time" and "date" (which only show date and time,
respectively).
2016-10-31 14:39:52 +01:00
Tobias Witek
b0608c7054 [modules] Add pulseaudio control modules
Add a module that retrieve mute status and volume (left, right, mono)
from pulseaudio. Unfortunately, this module is really, really hacky. It
invokes "pactl" multiple times to get the status and does some ugly
parsing on the output.

Overall, this is pretty brittle and prone to failure, but as I was not
able to find a decent pulseaudio library for Python... Probably, I
haven't searched hard enough, cannot believe such a thing does not
exist.
2016-10-31 14:27:51 +01:00
Tobias Witek
bb6ca556c7 [modules] Add support for disk utilization
Add a new module "disk" that takes an optional parameter (the path) and
displays free & total disk space, along with the usage percentage.

Also, added Tunnel/VPN support to the themeing of the "net" module.
2016-10-31 13:34:48 +01:00
Tobias Witek
f29ddae47a [modules/nic] Fix status display
First, cache lookups were bugged... Second, the output needs to call
data() first, everything else later.

This is a bit nasty, and I'll consider re-visiting this, but right now,
I don't see any other way, given that modules can now be iterated.
2016-10-31 13:09:52 +01:00
Tobias Witek
0f6b418385 [modules] Add NIC module
Add a module that displays the status of all NICs (interface name, list
of IPs and state).

In its status, it also exposes whether it's a WiFi or a wired NIC.

For this functionality, additional code was implemented to allow a
module to add multiple elements to the bar at once. The framework calls
the module until its "next()" method return False.
2016-10-31 13:03:16 +01:00
Tobias Witek
dbd8ccb83f [themes] Add a solarized powerline theme 2016-10-31 12:20:39 +01:00
Tobias Witek
9e89e35d10 [modules] Add module for measuring CPU utilization
Add module "cpu", which uses psutil to measure CPU utilization between
two consecutive calls.
2016-10-31 12:16:23 +01:00
Tobias Witek
36333c275f [modules] Add module for displaying RAM usage
Shows free RAM, total RAM, free RAM percentage
2016-10-31 12:11:39 +01:00
Tobias Witek
293c8453be [modules/battery] Add warning and critical functionality for battery 2016-10-31 12:01:21 +01:00
Tobias Witek
83bb1deb52 [themes] Add cycling for individual elements
Add functionality to provide lists of values for individual elements of
a theme (e.g. the prefix) and those will be cycled for each call.

This can be used, for example, to show a "charging" symbol for the
battery that continuously goes throw all the battery stages to "animate"
the charging icon.
2016-10-31 11:46:07 +01:00
Tobias Witek
14bce293eb [themes] Add support for generic warning/critical colors
Font and background colors for warning and critical elements can now be
specified using fg-warning, fg-critical, bg-warning and bg-critical.

Also, optionally, the "urgent" flag will be set towards the i3bar, if
possible.
2016-10-31 11:35:12 +01:00
Tobias Witek
6278a4e564 [modules] Add module "date" as alias of "time"
The "time" module now has an alias (symlink) called "date". This is used
to differentiate a widget showing the time from a widget showing the
date.
2016-10-31 11:11:53 +01:00
Tobias Witek
23617fbdb7 [themes] Cycle handling bugfix
Cycling was accidentially more important than the individual widget
themes.
2016-10-31 11:05:54 +01:00
Tobias Witek
00c92cb9e3 [modules/time] Add parameter for format string
Format string for strftime is now configurable. Also, changed the
separator for module name vs. arguments to "::" to make it possible to
have ":" as part of the strftime format string (which is useful in most
cases).

Eventually, I'll probably have to come up with a better way, i.e. a
fully-fledged parser, and move away from "special characters", but right
now, the effort seems too much for the gain.
2016-10-31 10:53:31 +01:00
Tobias Witek
2a35905b89 [themes] Add "cycle" theme capability
It is now possible to add a list of theme configurations in the
"default" section called "cycle". These configuration items will be
cycled through module by module. to create "alternate style" effects.
This is *only* possible in the "default" configuration part, but any
module-specific configurations still take precedence.

Also, removed the capability of per-widget themes. That simply
complicates things and probably doesn't really bring any benefits.
2016-10-31 10:45:15 +01:00
Tobias Witek
656c499c95 [themes] Add custom separators
Add the possibility to configure custom separators in the theme file.
These will only be used if the default i3bar separators have been
disabled. Background color will always be taken from the previous
element (to work nicely with my long-term plan, a powerline-like status
line).
2016-10-31 08:14:12 +01:00
Tobias Witek
7b48b08365 [themes] Add font and background colors to themes
Themes can now specify "fg" (font color) and "bg" (background color) on
all levels.
2016-10-31 07:54:18 +01:00
Tobias Witek
8538f272d6 [rework] Replace old-style string formatting with new-style 2016-10-31 07:46:21 +01:00
Tobias Witek
60f63f3269 [themes] Configure presence of default i3bar separators
For each theme & module, it is now possible to configure whether the
default i3bar separators should be drawn or not.
2016-10-31 07:39:26 +01:00
Tobias Witek
97273b5a41 [themes] Add state-dependent themeing
Module themes (only!) can now contain state-specific theme information -
for example, the "battery" module has different states for charging and
discharging, and those can have different prefix and postfix
configurations to indicate what is going on.
2016-10-31 07:34:43 +01:00
Tobias Witek
3ca53dd0fa [themes] Make individual items theme-able (a bit)
Individual items in the bar can now be configured with a prefix and a
suffix. It works like this:

* If there is a specific module configuration in the theme
  configuration, use that (i.e. { "<modulename>": { "prefix: " a " } })
* Otherwise, if there is a configuration in the "default" section of the
  theme, use that
* Otherwise, if the module object itself has a method called like the
  required attribute (prefix, suffix), use that
* Otherwise, leave prefix/suffix empty ("")
2016-10-31 07:18:57 +01:00
Tobias Witek
e895400589 [modules] Add battery indicator plugin
Add a plugin that displays the remaining battery power in %. This also
introduces the concept of arguments that can be passed to a module
during startup by delimiting the module name with ":", for example:

-m battery:BAT1 to query the BAT1 device.

Note that this works to an arbitray length, i.e. if a module accepts 3
parameters: -m <modulename>:<A>:<B>:<C>

The module gets the arguments as list.
2016-10-30 18:10:25 +01:00
Tobias Witek
4ad41a8ee0 [themes] Add themeing framework
Add - again a very simplistic - method for themeing the output.
Essentially, the plan is to have JSON-formatted configuration files in
bumblebee/themes/ and have a separate class for querying the config
whenever the output needs to know about semantic formatting/coloring.

Note that the theme object is stored on a per-module basis. Right now,
that doesn't have any effect (except looking particularly wasteful), but
the idea is to be able to have different themes for different modules in
the future.
2016-10-30 17:56:04 +01:00
Tobias Witek
4133ae1907 [modules] Initial module loading framework
Add a very simplistic framework for loading modules that query system
data. The user can provide a list of modules via an argument switch, and
the name of the module is used to look up a Python module that has to
have a class called "Module".

The outer framework (the outputs, in particular) then uses various query
methods of that class to construct a meaningful output.
2016-10-30 17:30:09 +01:00
Tobias Witek
c4683f3700 [output] Create preliminary framework for output handling
Prepare a framework for having modular outputs. Essentially, the main
application uses a output-type object to format strings for the
preamble, the actual data items, and a "postamble" (finalizer). The
printing of that representation, again, is up to the main application,
not the output framework.

Probably, at some point in the future, an interface class will be in
order, but right now, I want to keep it lean - seeing as for the
forseeable future, i3bar is going to be the one and only consumer of
this.
2016-10-30 15:58:35 +01:00