Commit Graph

845 Commits

Author SHA1 Message Date
patrick96
2512123a6c
Merge remote-tracking branch 'origin/hotfix/3.5.7' 2021-09-21 18:22:57 +02:00
patrick96
6136c08d42 tray: Properly handle missing _XEMBED_INFO
The icon not supporting XEMBED is not fatal, we just treat is as always
mapped.

Fixes #2479
Fixes #2442
2021-09-13 00:12:33 +02:00
Patrick Ziegler
5011e66346
fix(net): Check if interface is valid first. (#2497)
Fixes #2496
2021-09-09 21:47:23 +02:00
Luca Maltagliati
ddabe3f0f4
feat(memory): Tokens that switch between MiB and GiB (#2488)
* feat:add tokens to display memory in MiB when GiB val <= 1.0 (#2472)

* fix: correct swap_used calculation

* fix: pass variable by reference rather than by value

* fix: add precision arguments to filesize_gib_mib(); better condition

* doc: add #2472 to CHANGELOG

* fix: missing default argument values

* Apply suggestions from code review

Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
2021-09-04 13:14:13 +02:00
Vincent Bernat
5f3462240c
feat(ipc): allow receiving arbitrary text on IPC socket (#2463)
This adds the 'send' action to the ipc module that can be used to send arbitrary text to the module:

    polybar-msg action "#ipc.send.%{F#4444ff}hello%{F-}"

* feat(ipc): allow receiving arbitrary text on IPC socket

Instead of just allowing hook numbers to be executed, the user can
send arbitrary text and the IPC module will put it in the bar. The IPC
payload format is extended to accept an arbitrary string if the first
character after the module name is ':'.

    polybar-msg hook test :'%{F#4444ff}hello%{F-}'

Fix #2455

* Use actions for sending data to ipc module

* ipc: Don't use exceptions when no hooks are defined

* Update src/modules/ipc.cpp

Co-authored-by: patrick96 <p.ziegler96@gmail.com>
2021-07-11 20:42:28 +02:00
Nolan Prochnau
06932007a0
Universal Visibility Action (#2320 cont'd) (#2426)
* Add toggle_visible action

* Add set_visible and set_invisible actions

* Rename toggle_visible method to match

`action_toggle_visible` -> `action_toggle_visibility`

Matches with `EVENT_TOGGLE_VISIBILITY`

* Update CHANGELOG

* Revert #2320 IPC commands

IPC commands are no longer necessary now that the actions are
implemented. Changed some method permissions as well to reflect this.

* Add logging and change action names

- `module_toggle`
- `module_show`
- `module_hide`

Delineate common actions to all modules with a `module_` prefix (for
future actions too)

* Update documentation
2021-07-07 21:43:49 +02:00
Flexlolo
735a08ba7c
feat(bspwm): Option to scroll through occupied desktops only (#2428)
* Implement option occupied-scroll to bspwm module

* update changelog

* change default value of the setting
2021-05-13 12:59:13 +02:00
Ian Welker
97759ce585 Fixed issues with border corner radii 2021-03-29 20:17:48 +02:00
patrick96
93ab639c8a fix: unbounded_percentage always rounded down
For example if lower / upper = 0.019 (1.9%), it would return 1% instead
of 2%

Fixes #2399
2021-03-03 22:48:17 +01:00
patrick96
2fd6d20999 fix(xworkspaces): Segfault for wrong _NET_CURRENT_DESKTOP
While it shouldn't happen with compliant WMs, it was possibe to crash
polybar with _NET_CURRENT_DESKTOP >= _NET_NUMBER_OF_DESKTOPS and this
should not be possible.

Includes polybar/xpp#31
Fixes #2398
2021-03-03 22:34:38 +01:00
patrick96
3f03b671bb fix(color): Rename type() function to get_type
In gcc5, this caused compilation errors because the type enum has the
same name.
2021-03-01 00:05:44 +01:00
Simon
cd71b96cf8
feat: Rounded bar border (#2359)
* Added rounded border

* Added feature to the changelog

* Changed implementation for better customisation

* Bugfixes

* Removed commented code

* Removed unused method

* Removed duplicate lines

* Moved degree to be a private constant

Co-authored-by: Simon <simondergruber@gmail.com>
2021-02-16 23:17:16 +01:00
the
698b96d17b
feat(backlight): add use-actual-brightness option (#2380)
* add use-actual-brightness option

* added to changelog

* added to changelog 2

* added to changelog 3
2021-02-16 10:02:33 +01:00
Jérôme BOULMIER
529843b6ba
Remove undefined behaviors and clean code (#1769)
* fix: avoid memory leaks in case of exceptions.

* fix(fs): remove undefined behavior when removing mounts in m_mounts

* cleanup: remove double checks

* fix: remove memory leaks

* cleanup(xresources): capture exception by reference

Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
2021-02-15 23:32:56 +01:00
zappolowski
99900323b7
feat(conf): Option to always show urgent workspaces in i3 (#2378)
When `pin-workspaces` is set to true using `show-urgent` will show
urgent workspaces on the bar even when the workspace is not associated
with the current monitor.
2021-02-15 21:31:34 +01:00
patrick96
cfc6f3b45f Finish action_context tests 2021-02-12 20:01:22 +01:00
patrick96
c4fbf0023e Move action_context into separate file 2021-02-12 20:01:22 +01:00
patrick96
7a9f301830 Throw exception for unclosed action tags 2021-02-12 20:01:22 +01:00
patrick96
cd1d4fa183 Stop tracking action blocks in renderer
Dispatch can now directly get the current position from the renderer and
create action blocks with the proper coordinates.
2021-02-12 20:01:22 +01:00
patrick96
b5bdbdf6cb Add action_context tests 2021-02-12 20:01:22 +01:00
patrick96
d89096c191 Remove tag headers from signal.hpp 2021-02-12 20:01:22 +01:00
patrick96
7a569c4b98 Remove mousebtn argument from action_open 2021-02-12 20:01:22 +01:00
patrick96
464bedb33c Store all action info in action_context
The renderer is responsible for setting the start and end positions
while dispatch does the rest
2021-02-12 20:01:22 +01:00
patrick96
f359540b5d renderer: Move change_alignment into interface 2021-02-12 20:01:22 +01:00
patrick96
96239597ed Move most action state out of renderer
The renderer now only stores the positions of the actions because that
is specific to the renderer and because the actual position can only be
finalized after all the rendering is done because intitially the
positions are relative to the alignment and not the bar.
2021-02-12 20:01:22 +01:00
patrick96
0a474bb2f2 Move trivial formatting state into tags::context
The variables storing the current colors, attribute activations and font
were only used in a single place and can easily also be read from the
context.

This allows us to remove a lot of the state of the renderer.
2021-02-12 20:01:22 +01:00
patrick96
5d518e171e renderer: Use interface to render offset 2021-02-12 20:01:22 +01:00
tchici
c676d7e6f5
add reverse-scroll option for xworkspaces module (#2365)
* add reverse-scroll option for xworkspaces module

* move use of reverse-scroll option to when producing scroll action

* documented xworkspaces reverse-scroll option in changelog
2021-01-28 10:11:33 +01:00
Filip Banák
4ded401aab
Add initial support for an escape character (#2361)
Add a config parser method which, for now, deals only with escaping the
literal backslash character and logs an error message to inform the user
of the coming change.

The error message includes a properly escaped value for the user.

As a result of introducing an escape character('\'):

  - Warn the user of any unescaped backslashes, as they will not be
    treated as a literal character in the future

  - For now, still treat a single backslash as a literal character

  - Treat two consecutive backslashes as a single properly escaped
    literal backslash

Also:
  - Add documentation about the escape character to polybar(5) manpage
  - Add info about the escape character to changelog
  - Add testcases for ParseLineKeyTest
  - Add new test ParseEscapedValueTest

Resolves: First step in #2354

Improve value parsing

 - Take value arg in as an rvalue reference and move parsed value back
 - Remove unnecessary if statement
 - Rename function
 - Improve error message
 - Improve function description
 - Format

Add escape character documentation to manpages

Add information about the escape character to the polybar(5) manpage.

Add info about the esacape character to changelog

Add test cases for ParseLineKeyTest

Fix ParseLineKeyTest test cases

Also make config parser method parse_escaped_value private.

Add tests for escaped_value_parser method

Also remove unsued include statement

Simplify parse_escaped_value in config_parser

Remove unnecessary escaped value generation, so we do not have to keep
track of index differences.

Fix ParseEscapedValueTest test cases

Fix parse_escaped_value

Add more test cases for ParseLineKeyTest

Update CHANGELOG.md

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

Adress review

 - Adjust documentation
 - Small code changes

Improve parse_escaped_value

Add initial support for an escape character

Add a config parser method which, for now, deals only with escaping the
literal backslash character and logs an error message to inform the user
of the coming change.

The error message includes a properly escaped value for the user.

As a result of introducing an escape character('\'):

 - Warn the user of any unescaped backslashes, as they will not be
   treated as a literal character in the future

 - For now, still treat a single backslash as a literal character

 - Treat two consecutive backslashes as a single properly escaped
   literal backslash

Resolves: First step in #2354

Improve value parsing

 - Take value arg in as an rvalue reference and move parsed value back
 - Remove unnecessary if statement
 - Rename function
 - Improve error message
 - Improve function description
 - Format

Add info about the esacape character to changelog

Add test cases for ParseLineKeyTest

Fix ParseLineKeyTest test cases

Also make config parser method parse_escaped_value private.

Add tests for escaped_value_parser method

Also remove unsued include statement

Simplify parse_escaped_value in config_parser

Remove unnecessary escaped value generation, so we do not have to keep
track of index differences.

Fix ParseEscapedValueTest test cases

Add more test cases for ParseLineKeyTest

Adress review

 - Adjust documentation
 - Small code changes

Remove duplicate testcase from ParseLineKeyTest

Add initial support for an escape character

Add a config parser method which, for now, deals only with escaping the
literal backslash character and logs an error message to inform the user
of the coming change.

The error message includes a properly escaped value for the user.

As a result of introducing an escape character('\'):

 - Warn the user of any unescaped backslashes, as they will not be
   treated as a literal character in the future

 - For now, still treat a single backslash as a literal character

 - Treat two consecutive backslashes as a single properly escaped
   literal backslash

Resolves: First step in #2354

Improve value parsing

 - Take value arg in as an rvalue reference and move parsed value back
 - Remove unnecessary if statement
 - Rename function
 - Improve error message
 - Improve function description
 - Format

Fix ParseLineKeyTest test cases

Also make config parser method parse_escaped_value private.

Remove duplicate testcase from ParseLineKeyTest
2021-01-26 19:16:29 +01:00
patrick96
eaa50691fc fix(config_parser): UB in logger
Because we passed a temporary as the logger, it gets destroyed after the
config_parser constructor returns and when the logger is called in
config_parser it operates on a dangling reference.

Ref: https://stackoverflow.com/q/35770357/5363071
2021-01-26 16:20:25 +01:00
Patrick Ziegler
d5be8cad97
Add compiler warning for missing override specifier (#2341)
* build: Add -Wsuggest-override

We should always use the override specifier when overriding virtual
functions. This helps prevent errors when a subclass tries to create a
function with the same name as a virtual function in a super-class but
with a different purpose.

* clang-format

* Upload logs on failure

* Add override to unsupported.hpp

* cmake: Make -Wsuggest-override flag conditional
2021-01-04 10:38:43 +01:00
Patrick Ziegler
26be83f893
module: Implement action router (#2336)
* module: Implement proof of concept action router

Action implementation inside module becomes much cleaner because each
module just registers action names together with a callback (pointer to
member function) and the action router does the rest.

* Make input function final

This forces all modules to use the action router

* modules: Catch exceptions in action handlers

* Use action router for all modules

* Use action_ prefix for function names

The mpd module's 'stop' action overwrote the base module's stop function
which caused difficult to debug behavior.

To prevent this in the future we now prefix each function that is
responsible for an action with 'action_'

* Cleanup

* actions: Throw exception when re-registering action

Action names are unique inside modules. Unfortunately there is no way to
ensure this statically, the next best thing is to crash the module and
let the user know that this is a bug.

* Formatting

* actions: Ignore data for actions without data

This is the same behavior as before.

* action_router: Write tests
2021-01-04 10:25:52 +01:00
Bruno Cooper
7521da900f
Add support for %nwin% in xworkspaces label (#2329)
%nwin% tells the number of windows in a workspace
2021-01-04 10:17:27 +01:00
devsnek
f7c2d83ef2
feat(net): interface discovery (#2025) 2021-01-03 11:48:15 +01:00
Nolan Prochnau
eb302f96ff
Add config option for visiblity (#2320 cont'd) (#2342)
* Add option

* Undo my havoc on the example config

* Update CHANGELOG
2021-01-03 02:43:50 +01:00
Patrick Ziegler
412f4c723f
feat(xworkspaces): Persistent urgent hint (#2340)
* add urgent hint

* feat(xworkspaces): Fully implement urgency hint

Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
2020-12-31 15:49:39 +01:00
Nolan Prochnau
8e46e54cb3
feat: Module Visibility (#2320)
Modules can now also be shown and hidden using ipc commands:

    $ polybar-msg [-p PID] cmd hide.mymodule # Hides module mymodule
    $ polybar-msg [-p PID] cmd show.mymodule # Shows module mymodule
    $ polybar-msg [-p PID] cmd toggle.mymodule # Toggles visibility of mymodule

* Hopefully implement visibility checking

* Implement hide command

* Implement `show` and `toggle` commands

* Refactor and add some logging

* Run style checks and update CHANGELOG

* Get around unused parameter warnings

* Change `set_visible` to return nothing

* Make errors more informative

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

* Update bar when changing module visibility

- Called in the module to maintain dependence on the signal emitter
- Update CHANGELOG to make changes more verbose

* wrong var

* Update include/modules/unsupported.hpp

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

Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
2020-12-27 16:05:26 +01:00
patrick96
c24a6999a4 refactor(cmake): Allow targets to be enabled individually
Each major target of polybar can now be enabled/disabled while
configuring (even polybar itself).

The cmake code specific to each target will only run if the target is
enabled.

This allows us to for example just build the documentation without
having to run all the cmake code related to compilation or having the
polybar dependencies installed (other than sphinx).
2020-12-24 02:20:38 +01:00
patrick96
1dc8d2f30e cmake: Make xrandr and xcomposite required
They were required before, but could technically be deactived (the
compilation would fail, but configuration was possible).

The WITH_XRANDR and WITH_XCOMPOSITE now no longer appear in the cmake
part. It still appears in the source code, but is always set to 1

Fixes #1536
2020-12-22 00:37:07 +01:00
Jérôme BOULMIER
b143e43491 enhancement(cmake): remove all mentions of "dirs" variable 2020-12-22 00:37:07 +01:00
Jérôme BOULMIER
bb5cf0113e fix(x11): Don't include composite when disabled 2020-12-22 00:37:07 +01:00
Nolan Prochnau
0d2838fcd5
feat(xkeyboard): Add variant support to layout label (#2163)
* Add variant support to xkeyboard layout label

Solves #316

* Run style checks, I guess?

* Add comment

* Return nothing if there is no variant

* Update CHANGELOG
2020-12-19 18:22:27 +01:00
Patrick Ziegler
fd556525a8
New Tag Parser (#2303)
* refactor(color): Use enum class for color type

* Add testcases for tag parser

* Make tag parser a pull-style parser

Being able to parse single elements at a time gives us more fine-grained
error messages, we can also parse as much as possible and only stop
after an exception.

* fix(color): Parser did not check for invalid chars

* tag parser: First full implementation

* tag parser: Fix remaining failing tests

* tag parser: Replace old parser

* tag parser: Treat alignment as formatting tag

Makes the structure less complex and the alignment tags really are
formatting tags, they are structurally no different from the %{R} tag.

* tag parser: Cleanup type definitions

All type definitions for tags now live in tags/types.hpp, the parser.hpp
only contains the definitions necessary for actually calling the parser,
this shouldn't be included in many places (only places that actually do
parsing). But many places need the definitions for the tags themselves.

* Rename components/parser to tags/dispatch

* tag parser: Cleanup

* Add changelog
2020-12-17 20:37:28 +01:00
patrick96
4d2bdaa0bd
Merge branch 'hotfix/3.5.2' 2020-12-14 10:53:13 +01:00
Bjoern Hiller
7c662ec44f feat(conf) Properties for {bottom,top}-{left,right} radius 2020-12-13 17:02:23 +01:00
patrick96
94e1c64dff fix: Module type always empty string
The change in #2270 accidentally broke how we access module types.
module<Impl>::TYPE always points to the module superclass and it thus
accesses its empty TYPE field.

This mainly broke legacy action handling.

Ref #2270
2020-12-13 15:57:03 +01:00
patrick96
1c554dd0e0
Merge branch 'hotfix/3.5.1' 2020-12-12 13:28:57 +01:00
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