Commit Graph

2085 Commits

Author SHA1 Message Date
Jeremy Fleischman
f488a889bc
Add support for a tray-foreground setting. (#2552)
This adds a new `tray-foreground` config option, and uses it instead of
the `tray-background` setting to build up the `_NET_SYSTEM_TRAY_COLORS`
property. I'm pretty sure that the previous behavior was a mistake (this
was introduced in 94298741b6 which is a
pretty large diff).  For me and some other people, this results in a
black icon being drawn on top of a black background, which is pretty
useless! I would say that this diff fixes
https://github.com/polybar/polybar/issues/2235. Note: the old code dealt
with `unsigned int` and maxed values out at 0xff. The new code deals
with `uint16_t` and maxes values out at 0xffff. I haven't found the
relevant documentation to justify this change, but from manually
testing, I'm pretty confident this is the right change.

This all matches pretty closely with this code from i3:
[`i3bar/src/xcb.c::init_tray_colors`
code](43e805a00d/i3bar/src/xcb.c (L1490-L1522)),
which you can see also uses the bar's foreground color and maxes values
out at 0xffff, not 0xff.

If you merge this up, I think we should also update
https://github.com/polybar/polybar/wiki/Configuration#bar-settings to
mention the new settings.

Fixes #2235
2021-11-17 11:41:40 +01:00
Jeremy Fleischman
a3b5e3e7ed
Make it possible to run tests. (#2553)
I followed the instructions on
https://github.com/polybar/polybar/wiki/Testing, and this happened to
me:

    $ cmake .. -DBUILD_TESTS=ON
    ...
    [ 11%] Creating directories for 'googletest'
    [ 22%] Performing download step (git clone) for 'googletest'
    Cloning into 'googletest-src'...
    fatal: invalid reference: master
    CMake Error at googletest-download/googletest-prefix/tmp/googletest-gitclone.cmake:40 (message):
      Failed to checkout tag: 'master'

    make[2]: *** [CMakeFiles/googletest.dir/build.make:99: googletest-prefix/src/googletest-stamp/googletest-download] Error 1
    make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/googletest.dir/all] Error 2
    make: *** [Makefile:91: all] Error 2
    CMake Error at tests/CMakeLists.txt:19 (message):
      Build step for googletest failed: 2

It looks like the problem is that
[googletest](https://github.com/google/googletest/) changed their branch from
`master` to `main` at some point.

I also fixed a broken link
https://github.com/polybar/polybar/wiki/Testing. Hopefully it's
intentional that random members of the public such as myself are allowed
to do that?
2021-11-17 11:14:18 +01:00
Jean-Luc Bastarache
542f70efa3
fix(ipc): don't format empty strings (#2549)
* fix(ipc): don't format empty strings

* Add a description of the change to `CHANGELOG.md`

* Rephrasing
2021-11-04 16:55:16 +01:00
Patrick Ziegler
9b5611af3f
Fix message for deprecated config name (#2548) 2021-10-31 11:53:23 +01:00
Patrick Ziegler
3c5b2b61a6
ipc: Move running initial hook to update function (#2547) 2021-10-30 21:00:52 +02:00
Patrick Ziegler
9e3b537817
feat: Support reading config from non-regular files (#2545)
We had a check that restricted config files to "regular files".
This check was to restrictive as it didn't allow for things like:

```
polybar -c <(gen_config)
gen_config | polybar -c /dev/stdin
```

Now, polybar can easily read config data from stdin.
2021-10-24 11:25:05 +02:00
TheDoctor314
6d1ff41d37
Handle relative includes (#2535)
* Handle relative includes

We change to the directory of the given config file before parsing.
This allows us to handle relative includes.
TODO: Maybe improve the name of the change_dir() function.

* Fix unused result warning

* Add `relative_to` parameter to expand()

If the path is relative, we resolve it by prepending
dirname(config) to the path.

Add dirname() - Returns the parent directory of the file or an empty
string.

* Resolve relative paths

Handle paths relative to the current file being parsed.

* Remove unneeded change_dir()

* Fix expand()

`is_absolute` is calculated after we expand the path.
`relative_to` must be a directory.

Add test for expand() with relative paths

* Recalculate `is_absolute` after expanding `path`

* Add more file_util::expand tests

* Add changelog

Co-authored-by: patrick96 <p.ziegler96@gmail.com>
2021-10-20 12:31:15 +02:00
Patrick Ziegler
b5fb44220d
ci: Use new codecov uploader (#2541)
* ci: Use new codecov uploader

The bash uploader is deprecated

Ref: https://about.codecov.io/blog/codecov-uploader-deprecation-plan/

* Collect coverage report using lcov

* Remove branch coverage

There are a lot of hidden branches in the C++ code which doesn't make it
very useful
2021-10-16 19:58:34 +02:00
Patrick Ziegler
4d90ac2f4c
fix(net): Use canonical interface name (#2540)
One can define an 'altname' for an interface. That name is valid of
if_nametoindex but it doesn't appear in `/sys/class/net`:

```
sudo ip link property add dev enp0s31f6 altname eno
```

This creates an altname eno for the existing interface enp0s31f6

Before, using eno, would lead to an error in `realpath`.

Ref: https://www.reddit.com/r/Polybar/comments/q8f0ye/error_disabling_module_network_reason_realpath/hgqpq1m/?context=3
2021-10-15 17:36:32 +02:00
Patrick Ziegler
abd96eb089
Enable module in start funcion (#2538)
Before it was enabled by default. That means if the constructor fails,
the destructor will complain that the module was not stopped before
deconstructing.

We can't just call stop if module creation fails because the module is
only partially initialized.
2021-10-15 10:33:10 +02:00
Patrick Ziegler
76ae61f892
xkb: Use xpp for xcb calls (#2536) 2021-10-14 15:57:46 +02:00
Patrick Ziegler
b1c97e42cc
Include fd_stream in command.hpp (#2533)
On older gcc versions, the incomplete type can lead to a compilation
error because unique_ptr requires the complete type for its destructor.
2021-10-12 19:33:15 +02:00
Tim Schumacher
281fdf6382
The xworkspaces module should wait for EWMH to become available (#2429)
* The xworkspaces module should wait for EWMH to become available

Before this change if EWMH wasn't available the xworkspaces module was
permanently disabled. When polybar was started alongside the window
manager e.g. from .xinitrc this caused a race condition between polybar
and the window manager and the xworkspaces module may or may not be
displayed. After this change polybar will wait for EWMH to become
available. This change closes #1915, see that issue for more details.

Curiously this only required the removal of the error condition which
used the be raised when EWMH wasn't available. The xworkspaces module
will show up on the bar as soon as the first EWMH event is processed by
the existing event handling code. I can't argue much about the
correctness of this patch but it seems to work flawlessly in my testing
with xmonad. I didn't test any other window managers. Note that removing
the error condition below which checks that _NET_DESKTOP_VIEWPORT is
available might make this work with pin-workspaces=true. I couldn't test
the effects of that change because I only tested with xmonad and xmonad
doesn't support _NET_DESKTOP_VIEWPORT, so I didn't make that change.

* xworkspaces: Remove check fo _NET_DESKTOP_VIEWPORT

Implementations that don't support it will just return an empty list for
get_desktop_viewports and pin-workspaces won't do anything.

* Update changelog

Fixes #1915

Co-authored-by: Tim Schumacher <tim@timakro.de>
Co-authored-by: patrick96 <p.ziegler96@gmail.com>
2021-10-11 14:40:14 +02:00
dvermd
231af35354
feat(ipc): hook, prev, next, reset module actions (#2528)
* WIP ipc actions

* feat(ipc): Add hook, prev, next and reset actions

Closes: #2464

* ipc: format code

* ipc: fix comparison

* Apply suggestions from code review

Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>

* ipc: make index 0-based

* ipc: add 0-based indexing breaking change to Changelog

* ipc: restore 1-based index for  and  message

* ipc: fix initial=0 throwing an error

Co-authored-by: Martin Terneborg <martinterneborg@protonmail.com>
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
2021-10-10 20:22:24 +02:00
Patrick Ziegler
22014c70c4
Use the new GitHub issue forms (#2530)
* Use the new GitHub issue forms

This now automatically adds labels and marks certain information as
mandatory. It also automatically formats some fields (e.g. polybar
config).

Ref: https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-issue-forms

* Update bug_report issue link

* Fix bug_report description
2021-10-10 14:00:18 +02:00
dvermd
47b5910eda
Allow running polybar without BAR argument (#2526)
* Allow running polybar without BAR argument

The configuration file must declare a single bar to be able to not name
it.

* Check barname not in config and improve error message

* Revert README changes

* Add no bar in config file error detection
2021-10-07 14:48:47 +02:00
Patrick Ziegler
282b0f4e73
Create default config (#2511)
* Create default config and install to /etc/polybar

Closes #2405

* Search for config in /etc

We search in XDG_CONFIG_DIRS, /etc/xdg, and /etc but only for config.ini

Closes #2016

* Remove config installation from build.sh

* Remove userconfig cmake file

* Cleanup

* Cleanup default config

* Update CHANGELOG.md

Co-authored-by: dvermd <315743+dvermd@users.noreply.github.com>

* Update src/main.cpp

Co-authored-by: dvermd <315743+dvermd@users.noreply.github.com>

* Add tests for string functions

* Support loading bars from fallbacks in /etc

* Combine duplicate string_util::contains test

Co-authored-by: dvermd <315743+dvermd@users.noreply.github.com>
2021-10-05 13:07:19 +02:00
dvermd
98dffc292a
feat(xkeyboard): Icon matching using variant (#2521)
* feat(string_util): add contains_nocase

* feat(xkeyboard): Enable icon by variant

* Cleanup

* string_util: add some cases to string test

* string_util: rename contains_nocase -> contains_ignore_case

* layouticonset: use contains_ignore_case

* layouticonset: apply renamings and remove dead code

* remove VARIANT_NONE and use empty string instead

* use emplace_back and add assert

* layouticonset: precompute condition

* xkeyboard: restore missing continue

* Cleanup parse_icons

* Always choose the first case-insensitive match

* Cleanup layouticonset.get

* update the changelog

Co-authored-by: patrick96 <p.ziegler96@gmail.com>
2021-10-05 12:12:47 +02:00
dvermd
a2968127d1
fix typos (#2524) 2021-10-04 23:46:38 +02:00
Georgiy Komarov
40ae9b210b
config_parser: Improve error messages (#2522)
* config_parser: Improve error messages

This commit adds an additional context with configuration file name and
line number to some error messages in the config_parser.

* config_parser: Add file name and line number to invalid_name_error

* config_parser: Update unit tests to avoid crashes on regressions
2021-10-03 20:46:16 +02:00
Jérôme BOULMIER
2b1eb5337c fix(modules): move join in a new method 2021-10-03 12:00:41 +02:00
Madhav Prabhu C M
e5ab7e1c00
Notification string to a queue of strings (#2517)
Fixes #2469

* made inputdata to queue<string>

* changed back to front

* fixed move semantics issue while popping queue

* Removed ide file

* commented test lines

* review changes

* review changes

* Update CHANGELOG.md

* Cleanup

Co-authored-by: patrick96 <p.ziegler96@gmail.com>
2021-10-03 11:24:24 +02:00
patrick96
1a59599388 fix(modules): Avoid downcast in module constructor
The previous CAST_MOD(Impl) for the action_router constructor was
illegal because `this` is not yet of type Impl (because the subclass
constructor has not run yet).

The action_router now accepts std::function for its callbacks.

Fixes #2519
2021-10-03 03:18:39 +02:00
Patrick Ziegler
444120e664
script: Fix concurrency issues (#2518)
Fixes #1978

* Move tail and non-tail handler to method

Defining them in the constructor is ugly.

* script: Iterate over defined actions instead of fixed list

* Separate running logic and lock m_output

* Include POLYBAR_FLAGS in linker flags

* Stop using m_prev in script_runner

* Join module threads in stop function

Joining in the destructor may lead to UB because the subclass is already
deconstructed but the threads may still require it to be around (e.g.
for calling any functions on the instance)

* Cleanup script module

* Update changelog

* Remove AfterReturn class

* Remove m_stopping from script module

* Fix polybar not reading the entire line from child process.

For every `readline` call we created a new fd_streambuf. This means once
`readline` returns, the streambuf is destructed and and pending data in
its temporary buffer discarded and we never actually read it.

* Remove unused includes
2021-10-03 01:27:11 +02:00
patrick96
4f8f076714 Remove atomic members from static modules 2021-09-30 15:38:18 +02:00
patrick96
6b6bcf5080 Stop ipc_module subclassing static_module 2021-09-30 15:38:18 +02:00
patrick96
f55f584ef7 Remove main thread from static_module
This removes the need for any kind of synchronization because static
modules are completely running in the controller thread.
2021-09-30 15:38:18 +02:00
patrick96
626c55f8e5 Template value type for get_with_prefix 2021-09-28 22:16:07 +02:00
TheDoctor314
c7ffa60866 Update CHANGLELOG.md 2021-09-28 22:16:07 +02:00
TheDoctor314
e798ed57a2 Implement 'env-*' option in script_module
This stores the key-value pairs specified for the script module.
The command to be executed must pass on this argument.
2021-09-28 22:16:07 +02:00
TheDoctor314
37cd63a356 Add env parameter in command::exec() 2021-09-28 22:16:07 +02:00
TheDoctor314
a7b978412c Add env parameter to exec_sh()
Before passing the cmd to exec() we set the required environment
variables.

Also add the test for it.
2021-09-28 22:16:07 +02:00
TheDoctor314
1e0e50266b Add get_with_prefix()
Returns a list of key-value pairs starting with a prefix.
If you have in config:
```
env-FOO = bar
env-CAT = dog
```

then `get_with_prefix("env-")` will return
`[{"FOO", "bar"}, {"CAT", "dog"}]`
2021-09-28 22:16:07 +02:00
Patrick Ziegler
8afd5b71df
Integrate bar taskqueue into eventloop (#2510)
* Remove DEBUG_SHADED

Was disabled by default AND behind an #if 0

* Make TimerHandle expose more libuv functions

* Prepare for moving double clicks into eventloop

* Make eventloop available to bar

* Remove bar mutex

Everything in the bar is now in the same thread

* Move double-click handling to eventloop

* Extract double click deferred function into method

* Stop throttling clicks

* Increase double click interval to 400 and add option

double-click-interval in the bar section

Closes #1441

* Implement dimming using timer handles

* Remove taskqueue

* Remove unused dependencies

* Cleanup & Comments
2021-09-27 17:35:45 +02:00
TheDoctor314
55eb19fdc7
feat(ramp): Allow specifying ramp weights (#2505)
* feat(ramp) Implement ramp weights

*Add test for ramp weights

*[drawtypes/ramp] Implement ramp weights

Simply clone `label_t` weight no. of times in the icon list
This helps us not to change any of the calculations.

*Fix silly bug

Forgot to add a hyphen for the `weight` parameter.

Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>

*doc: add #1750 to CHANGELOG

* Fix compile error in ramp test

Use std::make_shared.
2021-09-22 21:46:20 +02:00
patrick96
98d9a882ea Fix polybar-msg compilation 2021-09-21 21:43:27 +02:00
patrick96
fa1240f4b6 Remove unused file_ptr 2021-09-21 21:43:27 +02:00
patrick96
3b6a950380 Remove unused factory.hpp imports 2021-09-21 21:43:27 +02:00
patrick96
fabce6a493 Add tests for env_util 2021-09-21 21:43:27 +02:00
patrick96
0d1db206c6 Remove factory_util unique and shared
Equivalent to std::make_unique and std::make_shared
2021-09-21 21:43:27 +02:00
patrick96
560065540b Fix wrong assertion on network interface 2021-09-21 21:43:27 +02:00
patrick96
98919cbb77 Remove unused moodycamel concurrentqueue 2021-09-21 21:43:27 +02:00
patrick96
c922a94b67 Remove unused spin_lock 2021-09-21 21:43:27 +02:00
patrick96
0f72a2e0ea Remove unused throttle_util 2021-09-21 21:43:27 +02:00
patrick96
069036fa5a Add libuv to polybar-git PKGBUILD 2021-09-21 20:36:23 +02:00
patrick96
c29e4837df clang-format 2021-09-21 20:36:23 +02:00
patrick96
21f6f7818a Update CHANGELOG.md 2021-09-21 20:36:23 +02:00
patrick96
85d308cec8 Use libuv >= 1.3.0 2021-09-21 20:36:23 +02:00
patrick96
386eb57ba7 Reopen pipe path on EOF 2021-09-21 20:36:23 +02:00
patrick96
77b9cffaf8 Cleanup 2021-09-21 20:36:23 +02:00