Commit Graph

887 Commits

Author SHA1 Message Date
patrick96
47483a94f1 fix(process): fork_detached created zombie processes
Since the forked processes are still our children, we need to wait on
them, otherwise they become zombie processes.

We now fork twice, let the first fork immediately return and wait on it.
This reparents the second fork, which runs the actual code, to the init
process which then collects it.

Ref #770
2020-12-12 02:37:21 +01:00
patrick96
54e2490aa5 fix(logger): Wrong conversion function called
For some reason when passing some non-const strings to convert, the
convert(T&& arg) method was used instead of the one specialized for
strings.

This caused an error in clang because you can't pass objects with
non-trivial types to varargs functions.

The best solution I found was to just add a specialized function for
non-const strings.
2020-12-12 01:43:12 +01:00
patrick96
a45b5d0424 fix(build): UB when converting strings in logger
The memory returned was no longer valid because arg is destructed after
the function returns.
2020-12-12 01:43:12 +01:00
Patrick Ziegler
037f6e6c45
fix(xworkspaces): Never swallow updates (#2275)
If two WM events arrive withing 25ms of one-another, the second one does
not trigger a bar update.
The module state is still correct, it is just not reflected in the bar.

This somehow caused updates being swallowed in fluxbox, but only after
PR #882 was merged, even though that 25ms restriction existed long
before that.

Fixes #2272
2020-12-05 23:28:48 +01:00
Patrick Ziegler
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
Patrick Ziegler
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
Patrick Ziegler
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
patrick96
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
patrick96
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
Michał Drozd
0416093edc
Display correct(binary) unit prefixes in memory module (#2211) 2020-11-27 23:30:09 +01:00
patrick96
5007dae35a If bar bg, fg, border, or line color is alpha only, apply to default 2020-11-27 22:08:03 +01:00
patrick96
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
patrick96
477189e443 Cleanup 2020-11-27 22:08:03 +01:00
patrick96
4dfbba11c4 Make rgba class immutable 2020-11-27 22:08:03 +01:00
patrick96
413c911cd1 Move apply_alpha functionality into rgba 2020-11-27 22:08:03 +01:00
patrick96
eeab4f0d45 Print error message for invalid color strings 2020-11-27 22:08:03 +01:00
patrick96
c9efd09f71 Load rgba from config instead of strings. 2020-11-27 22:08:03 +01:00
patrick96
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
patrick96
3655106a14 Adapt the renderer side to always use rgba 2020-11-27 22:08:03 +01:00
patrick96
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
patrick96
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
patrick96
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
patrick96
ff3340e062 controller: Cleanup process_inputdata 2020-11-26 20:53:53 +01:00
patrick96
1afb333858 doc(actions): Point user to doc when using legacy actions 2020-11-26 20:53:53 +01:00
patrick96
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
patrick96
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
patrick96
1193b78e43 controller: Use unordered_map for legacy actions 2020-11-26 20:53:53 +01:00
patrick96
41ffc3607d controller: Make action shell command local 2020-11-26 20:53:53 +01:00
patrick96
9fb75779f3 Incorporate reviews 2020-11-26 20:53:53 +01:00
patrick96
5ddb6fc0c5 Move legacy action handling to separate function 2020-11-26 20:53:53 +01:00
patrick96
c60b488501 clang-format 2020-11-26 20:53:53 +01:00
patrick96
507004df87 actions: Move parsing to utility file 2020-11-26 20:53:53 +01:00
patrick96
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
patrick96
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
patrick96
af5af1e497 Fix unused argument warning 2020-11-26 20:53:53 +01:00
patrick96
a30ac5f4a3 fix(actions): Separate data from action properly 2020-11-26 20:53:53 +01:00
patrick96
6618320947 actions: Use #name.action[.data] format
This looks a bit nicer than #name#action[.data]
2020-11-26 20:53:53 +01:00
patrick96
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
patrick96
8acedeef87 modules: Fix resolving of type of disabled modules 2020-11-26 20:53:53 +01:00
patrick96
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
patrick96
a2b312cc84 actions: Add mapping for all legacy action names 2020-11-26 20:53:53 +01:00
patrick96
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
patrick96
816b73a95f actions: Add utility functions to produce action tags 2020-11-26 20:53:53 +01:00
patrick96
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
patrick96
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
patrick96
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
patrick96
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
patrick96
e309253fc8 clang-format 2020-10-19 10:32:41 +02:00
patrick96
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
Quan
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