Commit Graph

958 Commits

Author SHA1 Message Date
Patrick Ziegler
5011e66346
fix(net): Check if interface is valid first. (#2497)
Fixes #2496
2021-09-09 21:47:23 +02:00
Patrick Ziegler
9f828800fb
fix(xworkspaces): Fix scrolling (#2492)
The scroll handler had two issues:

* It did not respect the order the desktops where displayed in
* It would not wrap around on the first desktop because of an integer
  underflow

Fixes #2491
2021-09-04 14:36:01 +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
151a263654
fix(monitor): do not include outputs when monitors are supported (#2485)
* fix(monitor): do not include outputs when monitors are supported

Previously, when splitting an output into two monitors, `polybar -m`
would report both the splitted monitors and the output. This was not
caught by the the clone detection as the detection works by removing
monitors contained into another monitors (and monitors were excluded
from that logic) and we want the other way around: outputs covered by
monitors should be ignored.

Instead of trying to detect covered outputs, the solution is quite
simple: when monitors are supported, do not consider outputs, unless
we request all outputs. A monitor can be set primary (and RandR
reports primary outputs as primary monitors). The only information we
would miss from monitors are things like refresh rate and EDID. We
don't need that, so we are fine.

As monitors are only created for connected output (and they are in
this case "active") or disconnected output if they are mapped (and
they are in this case "inactive"), I am a bit unsure if we have
exactly the same behaviour as previously when `connected_only` is set
to `false`.

As some modules require an output, we keep the output in the
`monitor_t` structure and we ensure it is correctly set when using
monitors. A monitor can have 0 or several outputs. We only handle the
0 and 1 cases. When a monitor has more outputs, only the first one is
used. AFAIK, only the xbacklight module needs that and I think we are
fine waiting for a user needing this module and merging monitors.

The C++ binding fail to expose the `outputs()` method to iterate over
the outputs of a monitor. This seems to be a bug in XPP. The field is
correctly defined in the RandR XML file and it works with the Python
binding.

```xml
	<struct name="MonitorInfo">
		<field type="ATOM" name="name" />
		<field type="BOOL" name="primary" />
		<field type="BOOL" name="automatic" />
		<field type="CARD16" name="nOutput" />
		<field type="INT16" name="x" />
		<field type="INT16" name="y" />
		<field type="CARD16" name="width" /> <!-- pixels -->
		<field type="CARD16" name="height" /> <!-- pixels -->
		<field type="CARD32" name="width_in_millimeters" />
		<field type="CARD32" name="height_in_millimeters" />
		<list type="OUTPUT" name="outputs">
		    <fieldref>nOutput</fieldref>
		</list>
	</struct>
```

Falling back to C only to access the list of outputs is not enough
because the list is appended to the structure and not visible through
the public API. When copied, the structure loses the list of monitors.

Also, change the mention "XRandR monitor" to "no output" when there is
no output attached. People using monitors know what it means and it is
useful to catch a future regression where we don't have an output at
all (which would break the brightness plugin).

Fix #2481

* Update CHANGELOG.md

Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
2021-09-02 18:07:21 +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
patrick96
523e4d6313 fix(fs): Only add spacing between shown mountpoints
Fixes #2458
2021-07-11 14:51:15 +02:00
patrick96
c901826317 Use CMAKE_EXE_LINKER_FLAGS
The newere target_link_options is not supported by our minimum cmake
version (3.5)
2021-07-11 14:47:26 +02:00
patrick96
3652d5fe0d cmake: Stop using CMAKE_* variables for flags
It is not recommended anyway and the -Werror flag set in CI was getting
set when compiling gtest, breaking our build.
2021-07-11 14:47:26 +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
Carlos Gonzalez
bfa9b5d53e
Adding case to ignore T@ in bspwm (#2439)
* Adding case to ignore T@ in bspwm

* Adding entry to changelog for issue #2371
2021-05-27 20:05:37 +02:00
patrick96
c65f6857e1
Merge branch 'hotfix/3.5.6' 2021-05-24 01:07:24 +02:00
patrick96
cbe4521737 tray: Do not swallow clear_window exceptions 2021-05-24 00:47:22 +02:00
patrick96
ad987098ff fix(tray): Support clients with different depths
XCB_BACK_PIXMAP_PARENT_RELATIVE requires that the client has the same
depth as the tray window.

There was an issue with dropbox having a depth of 32 and the tray window
having a depth of 24 that caused the configuration of the icon to fail.
It would then be displayed outside of the bar because the catch block
was not hit (different exception).

We now just don't configure XCB_CW_BACK_PIXMAP. This seems to work and
is also what stalonetray does.

This does not fix the issue with dropbox having an arbitrary background.

Fixes #1679
Fixes #2430
2021-05-24 00:47:22 +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
Tim Schumacher
2901e1e476
Add wm-restack=generic option that lowers polybar to the bottom of the stack (#2404)
* Add wm-restack=generic to lower polybar to the bottom of the stack

Previously wm-restack only supported bspwm and i3. Both have a special
top-level window that polybar detects and places itself directly above.
This patch adds wm-restack=generic which simply lowers polybar to the
very bottom of the stack. This option was tested and confirmed to work
with xmonad which doesn't have a special top-level window and therefore
doesn't require special handling like bspwm and i3.

Fixes #2205

* Update src/components/bar.cpp

Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
2021-04-02 00:48:48 +02:00
Ian Welker
97759ce585 Fixed issues with border corner radii 2021-03-29 20:17:48 +02: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
patrick96
cf2653c8bd cmake: Do not use TARGET_EXISTS generator exprs
The TARGET_EXISTS generator expression was introduced only in cmake 3.12
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
Patrick Ziegler
4f16a4fb6d
alsa: Call action_epilogue (#2381) 2021-02-15 23:49:21 +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
50f127f1bc Cleanup 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
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
8fcd514168 dispatch: Add simple test 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
f0ee5ab8cd renderer: fix highlight_clickable_areas 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
4154943f69 fix(xworkspaces): Handle -1 value for _NET_WM_DESKTOP
Fixes #2352
2021-01-15 20:34:15 +01:00
patrick96
74dcb4649d
Merge branch 'hotfix/3.5.4' 2021-01-07 13:52:28 +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
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
e30d2c4c1f Remove tag compaction "optimizations"
The intention was to remove tags that won't have an effect and join
together consecutive tags.
However the patterns used can just as well appear in regular text, so
this can replace characters inside user defined text and not just
formatting tags.

Fixes #2331
2020-12-25 00:33:32 +01:00
patrick96
923d9ae061 Add cmake files for configuring individual targets
This makes the code a bit less messy. We barely need if(BUILD_...)
guards inside the cmake files, just the root CMakeLists.txt.
2020-12-24 02:20:38 +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
Kamui
89a723a4d9
feat(config): Try to load config.ini (#2324)
* Added .ini extension check to default config

* Added change to changelog and man page

* Added change to changelog and man page

* removed .vscode folder

* removed new lines in changelog
2020-12-23 17:52:30 +01:00