Commit graph

40 commits

Author SHA1 Message Date
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
f40418475f [modules/datetime] Re-enable datetime module
Add datetime module + aliases date and time.

see #23
2016-12-09 07:11:23 +01:00
Tobi-wan Kenobi
2fa8d7b778 [core/themes] Add module-specific themes
Allow module-specific theme information to overload "default"
configuration. I.e. it is now possible to have specific prefix or
postfix configurations for different modules. The module name is derived
for each widget from the module (__module__) from which it was
instantiated.

see #23
2016-12-08 12:44:52 +01:00
Tobi-wan Kenobi
562fd85ca2 [core/theme] Add support for icon themes
Allow sub-themes ("iconsets") to be merged into the "main" theme. That
way, effectively, it's possible to define colors and icons in separate
JSON files.

see #23
2016-12-08 12:09:21 +01:00
Tobi-wan Kenobi
394ef61760 [core/theme] Add support for default -> prefix/suffix in themes
Themes can now define default prefix and suffix strings.

see #23
2016-12-08 11:52:47 +01:00
Tobi-wan Kenobi
64f5fc100e [core/theme] Add prefix/postfix methods
Add a way to specify prefix and postfix strings to the full text of a
widget's text. Currently, the theme does not fill those yet.

see #23
2016-12-08 11:31:20 +01:00
Tobi-wan Kenobi
2399cf9af1 [core/themes] Add theme loading
Load a theme from a JSON file.
2016-12-08 09:44:05 +01:00
Tobi-wan Kenobi
f645203579 [core] Widget creation/update overhaul
Until now, widgets were re-created during each iteration. For multiple,
reasons, using static widget objects is much easier, so instead of
creating new widgets continuously, modules now create the widgets during
instantiation and get the list of widgets passed as parameter whenever
an update occurs. During the update, they can still manipulate the
widget list by removing and adding elements as needed.

Advantages:
* Less memory fragmentation (fewer (de)allocations)
* Easier event management (widgets now have static IDs)
* Easier module code (widget contents can simply be the result of a
  callback)

see #23
2016-12-08 08:44:54 +01:00
Tobi-wan Kenobi
60ae92c8e3 [core/themes] Prepare adding of themeing support
* Add framework JSON definition for themes
* Add framework test module
* Add framework module

see #23
2016-12-04 18:10:04 +01:00
Tobi-wan Kenobi
a8a6c9bba2 [core] Refactor engine
This is going to be a bit more comprehensive than anticipated. In order
to cleanly refactor the core and the engine, basically start from
scratch with the implementation.

Goals:

* Test coverage
* Maintain backwards compatibility with module interface as much as
  possible (but still make modules easier to code)
* Simplicity

see #23
2016-12-03 20:38:54 +01:00
Tobi-wan Kenobi
20858991b9 [theme] Fix cycling through widget styles
Cycled widget styles (such as the battery charging style) were broken
until now. The reason for this: They maintain state that represents the
current cycle position (i.e. what is the current icon that is being
displayed), but that is done in a way that uses repr() on the widget
object.

Since the widget objects are re-created each time the bar is drawn, this
is a deeply flawed design.

Instead, use the instance() of the widget for now.
2016-12-02 22:35:28 +01:00
Tobi-wan Kenobi
f306366629 [core] Minor refactoring
Use a small helper function from util, tidy up some parts of the
output.
2016-12-02 17:52:05 +01:00
Tobi-wan Kenobi
a93fa4aa5c Merge branch 'master' into icon-themes
* separate color themes from icons
* each theme can now use one or more icon themes
* icons are chosen in a "first match" fashion

fixes #17
2016-12-02 17:18:01 +01:00
Tobi-wan Kenobi
209fa83324 [themes] Make it possible to merge themes to get "icon themes"
Add code that allows themes to be merged (i.e. if certain elements are
not present in a theme, another theme can be "overlaid" to add missing
elements).

Effectively, this is used to create the logical concept of an "icon
theme", which is loaded after the main theme. So, the main theme can
define colors, and the icon theme fills in any missing elements
(practically, all the icons in the form of prefixes and suffixes).

Icon sets are defined in a theme using the "icons" directive, which
should be an array.

see #17
2016-11-25 21:06:24 +01:00
Tobi-wan Kenobi
f6db8b0a85 [themes] Move theme folder out of Python folder
fixes #16
2016-11-25 17:57:41 +01:00
Tobi-wan Kenobi
dead54ed1f [modules/cmus] Add controls for cmus (next/prev/shuffle/repeat)
Add controls that allow the user to switch to the next and previous song
in cmus, toggle shuffle and repeat. Pause/play is toggled by clicking on
the song title itself.

fixes #5
2016-11-12 12:11:42 +01:00
Tobias Witek
e2a6d41389 [theme] Add YAML as optional format for themes
This addresses issue #4
2016-11-05 16:53:34 +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
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
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
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
f02c49286b [main] Add available themes to listing output 2016-10-31 16:47:34 +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
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
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