Commit Graph

883 Commits

Author SHA1 Message Date
82ebad5e7a fix(timer_module): Ensure that interval > 0 (#2274)
Since 3.5.0, we use m_interval for a modulo operation, this crashes the
bar if the interval is 0. A non-positive interval shouldn't be allowed
anyway, so we now throw an exception in that case.

Fixes #2273
2020-12-05 22:58:38 +01:00
b2c515c73c fix(config): Reintroduce multiple inheritance (#2271)
Pre 3.5.0, any key starting with 'inherit' was treated as an inherit
directive. This allowed for multiple inheritance even though it was
never inteded in that way.
3.5.0 removed that bug/feature by doing a strict check against 'inherit'

It seems people were relying on this behavior, so we are adding it back.
However multiple inheritance with multiple keys is also deprecated in
favor of the `inherit` key now supporting multiple space separated
sections.

This is because the config doesn't have a key order, but inheritance
does depend on the order the different section keys are copied over (if
multiple inherited sections define the same key).

Fixes #2269
2020-12-05 02:48:18 +01:00
c198859cd5 fix(menu): Wrong printf token in error message (#2264)
'level' is a string, not an integer
2020-12-03 15:12:59 +01:00
e89da58940 fix(builder): Properly apply alpha for fg and bg
It was not quite clear how try_apply_alpha should behave if the given
color was not ALPHA_ONLY. The implementation just returned 'this'.
However, the build relied on it returning the given color.

This broke all bg and fg settings in the entire bar.

To clear this up, we switch this around take the alpha channel of 'this'
and also return 'this' if it isn't ALPHA_ONLY.

Fixes #2255
2020-12-01 14:53:41 +01:00
52eee95bf8 controller: Detach shell commands from polybar
Shell commands triggered from action tags used to block polybar until
they finished.

Since we are not actually interested in the output of the commands, it
makes sense to run them completely detached from polybar and have
polybar not block when executing these commands.

Now the spawned child processes no longer get killed when polybar
exits. This is fine because polybar is not responsible for these
processes since they were explicitly started by the user through click
commands.

Ref: #770
Ref: #1680
2020-11-29 03:53:59 +01:00
0416093edc Display correct(binary) unit prefixes in memory module (#2211) 2020-11-27 23:30:09 +01:00
5007dae35a If bar bg, fg, border, or line color is alpha only, apply to default 2020-11-27 22:08:03 +01:00
53c6f3b042 refactor(color): Better channel function names
(alpha|red|green|blue)_(d|i) are used for the four channels using
doubles or integers, respectively.
2020-11-27 22:08:03 +01:00
477189e443 Cleanup 2020-11-27 22:08:03 +01:00
4dfbba11c4 Make rgba class immutable 2020-11-27 22:08:03 +01:00
413c911cd1 Move apply_alpha functionality into rgba 2020-11-27 22:08:03 +01:00
eeab4f0d45 Print error message for invalid color strings 2020-11-27 22:08:03 +01:00
c9efd09f71 Load rgba from config instead of strings. 2020-11-27 22:08:03 +01:00
8e10c046fa Move all channel functions into rgba class
Since we use rgba everywhere, extracting channels from uint32_t directly
is not necessary anymore.
2020-11-27 22:08:03 +01:00
3655106a14 Adapt the renderer side to always use rgba 2020-11-27 22:08:03 +01:00
64fa6469ab Remove unused hex function
This allows us to also remove the cache class which was only used here
2020-11-27 22:08:03 +01:00
b238ec3403 Move most color_util functions into rgba class
The intent is for every color to be stored in a rgba instance

The rgba class now stores the color in a 32 bit integer to save space

This also removes the unused class rgb and moves everything else into a
cpp file.

Many functions also had weird template parameters. For example
alpha_channel<unsigned short int> would give a 2 byte number with the
alpha channel byte in both bytes.
color_util::hex would return a hex string with alpha channel if unsigned
short int was given and without if unsigned char was given. Even more
curiously those parameters were passed to *_channel and the result
nevertheless truncated to 8bits.
2020-11-27 22:08:03 +01:00
75eb41f5ad config: Better error messages when opening files
If a config file is a directory, ifstream would just read it as an empty
file without any errors.

Failing early here is a good idea.
2020-11-26 21:06:35 +01:00
ff3340e062 controller: Cleanup process_inputdata 2020-11-26 20:53:53 +01:00
1afb333858 doc(actions): Point user to doc when using legacy actions 2020-11-26 20:53:53 +01:00
191fb2972c actions: Integrate input_handler into module
Only modules can now be action handlers.
This also slightly simplifies the controller because we don't need to
keep track of input handlers, we can just use the module list.
2020-11-26 20:53:53 +01:00
658ed6974d Do not use reverse-scroll for prev/next actions
The next action should always select the next workspace, the same for
prev.

reverse-scroll should be directly used when setting the scroll actions.

This changes the behavior of `prev` and `next` actions in the i3 and
bspwm module.
But I don't think the impact will be significant and the old behavior
was misleading anyway.
2020-11-26 20:53:53 +01:00
1193b78e43 controller: Use unordered_map for legacy actions 2020-11-26 20:53:53 +01:00
41ffc3607d controller: Make action shell command local 2020-11-26 20:53:53 +01:00
9fb75779f3 Incorporate reviews 2020-11-26 20:53:53 +01:00
5ddb6fc0c5 Move legacy action handling to separate function 2020-11-26 20:53:53 +01:00
c60b488501 clang-format 2020-11-26 20:53:53 +01:00
507004df87 actions: Move parsing to utility file 2020-11-26 20:53:53 +01:00
0db8376222 menu: Emit exec actions
Now the menu closes properly again if any actions on it are clicked
2020-11-26 20:53:53 +01:00
ef8f7c9d94 feat(menu): Add exec action to menu module
Can be used to execute menu actions through ipc and will also be used to
make sure the menu closes when an action on it is clicked.
2020-11-26 20:53:53 +01:00
af5af1e497 Fix unused argument warning 2020-11-26 20:53:53 +01:00
a30ac5f4a3 fix(actions): Separate data from action properly 2020-11-26 20:53:53 +01:00
6618320947 actions: Use #name.action[.data] format
This looks a bit nicer than #name#action[.data]
2020-11-26 20:53:53 +01:00
bc1b86c584 actions: Separate data from action string
Modules now no longer need to manually parse the action string and
extract data from it.
2020-11-26 20:53:53 +01:00
8acedeef87 modules: Fix resolving of type of disabled modules 2020-11-26 20:53:53 +01:00
002112df64 actions: Forward data of legacy actions
Some actions have data attached (e.g. xworkspaces-focus=N), the
forwarding logic now matches the keys in the legacy_actions map as
prefixes and everything afterwards is considered additional data and
appended to the new action string.
2020-11-26 20:53:53 +01:00
a2b312cc84 actions: Add mapping for all legacy action names 2020-11-26 20:53:53 +01:00
ae2350167b actions: Switch all modules over to new system
All modules now expose their actions as public static constants

Issues: The menu module no longer closes when an item is clicked (before
it would intercept any executed command and look if it matches one of
its exec commands)
2020-11-26 20:53:53 +01:00
816b73a95f actions: Add utility functions to produce action tags 2020-11-26 20:53:53 +01:00
b2ba21c75d actions: Forward legacy actions to the right module
All the information about which action has to be delivered to which
module is kept in once place to make cleanup easier once the deprecated
actions are removed.

Right now only the date module is added as a proof of concept.
2020-11-26 20:53:53 +01:00
d592eea966 refactor: Move module type string into modules
This allows us to identify module by their type and it is also better to
store the module type as part of the module instead of having it
hardcoded in factory.hpp
2020-11-26 20:53:53 +01:00
06012af3aa controller: Deliver inputs to all input handlers
This is more natural, especially if the same module appears twice in the
module list
2020-11-26 20:53:53 +01:00
a287fb5e8c fix: Use module name in action string
Action strings now have the form '#MODULE#ACTION'

For example to trigger the action 'toggle' in the 'module/date' module
one would now use '%{A1:#date#toggle:}'

With this action strings can now be uniquely assigned to one module.

Fixes #1172
2020-11-26 20:53:53 +01:00
e309253fc8 clang-format 2020-10-19 10:32:41 +02:00
4944a5179c fix(net): Float interval for network speed
Before the time difference between two measurements was always an
integer number, so for intervals < 1, you would always get 0 and for any
other non-integer interval you would get skewed results.
2020-10-19 10:32:41 +02:00
3895ace12a temp: Use first/last ramp only for edge temps (#2197)
ramp-0 is used for everything <= base-temperature and ramp-N is used for everything >= warn-temperature

* [Temperature, Ramp] fix wrong icon for temperatures near base and warn temps

* [Temperature, Ramp] fix wrong icon for temperatures near base and warn temps

* Fix minor error

* explicitly check percentage in get_by_percentage_with_borders

* Fixed silly error
2020-10-09 14:05:50 +02:00
8dbd1740a7 feat(config): include-directory directive (#2196)
Closes #1946
2020-10-08 17:44:29 +02:00
bb15e33a2a fix(alsa): Remove upper bound to get_volume (#2184)
Fixes #2173 

* feat(alsa): Remove upper bound to get_volume

* Add tests. Trim unnecessary function.
2020-09-20 14:26:17 +02:00
2f4cffc0fb fix(config_parser): Gracefully handle BOM (#2166)
* fix(config_parser): Gracefully handle BOM

* Move check to parse_line function

And clarify the error message

Closes #2075
2020-08-15 12:02:23 +02:00
be64da3bda battery: Prioritize full-at over state (#2019)
* Prioritize battery full-at over state

The `full-at` option should take priority 
over the charging state of the battery.

Closes #1622 (issue for Thinkpad laptops)

* Remove typo from clamp_percentage
2020-06-09 21:15:36 +02:00