If a script module is waiting on a non-tailed script to finish, polybar
cannot shut down until the script has terminted.
To remedy this, we use the same polling loop as for tailed scripts which
checks if it needs to terminate after every iteration.
If any action block contains a negative offset, it can cause text to be
theoretically be rendered outside of the block, making that text not
clickable.
To fix this, we ensure that an action block starts at the lowest
observed position while the block is open and ends at the highest
observed position while it is open.
Fixes#1814
When polybar is remapped (either through IPC or something like xdo
show), openbox positions it somewhere on the screen using the same
positioning algorithm as it would for regular windows.
If the position and size is set in the WM_SIZE_HINTS atom, openbox will
respect the position and size declared by the window.
Fixes#2021
* add units support (POINT, PIXEL, SPACE) for polybar
- add a size_with_unit struct
- add a geometry_format_values struct
- move dpi initialisation from renderer.cpp to bar.cpp
- add a string to size_with_unit converter
- add point support (with pt)
- add pixel support (with px)
* Fix unit test compilation
* clang-format
* Better names
The old names didn't really capture the purpose of the structs and
function.
space_type -> spacing_type
space_size -> spacing_val
size_type -> extent_type
geometry -> extent_val
geometry_format_values -> percentage_with_offset
* Remove parse_size_with_unit
No longer needed. The convert<spacing_val> function in config.cpp
already does all the work for us and always setting the type to pixel
was wrong.
In addition, line-size should not be of type spacing_val but extent_val.
* Cleanup
I tried to address most of my comments on the old PR
* Fix renderer width calculation
We can't just blindly add the x difference to the width because for
example the width should increase if x < width and the increase keeps
x < width.
Similarly, we can't just add the offset to the width.
* Rename geom_format_to_pixels to percentage_with_offset_to_pixel
* Cleanup
* Apply suggested changes from Patrick on GitHub
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/bar.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/config.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* config: Use stod for parsing percentage
* Use stof instead of strtof
* units: Fix test edge cases
* Remove unnecessary clang-format toggle
* Use percentage_with_offset for margin-{top,bottom}
* Support negative extent values
* Rename unit to units and create a cpp file
* Move percentage_with_offset_to_pixel unit test to units
* Add unit tests for units_utils
* Clarify when and how negative spacing/extent is allowed
Negative spacing is never allowed and produces a config error.
Extents allow negative values in theory, but only a few use-cases accept
it.
Only the extent value used for the `%{O}` tag and the offset value in
percentage_with_offset can be negative. Everything else is capped below
at 0.
The final pixel value of percentage_with_offset also caps below at 0.
* Fix parsing errors not being caught in config
* Print a proper error message for uncaught exceptions
* Cleanup module::get_output
All changes preserve the existing semantics
* Stop using remove_trailing_space in module::get_output
Instead, we first check if the current tag is built, and only if it is,
the spacing is prepended.
* Remove unused imports
* Restore old behavior
If there are two tags and the second one isn't built (module::build
returns false), the space in between them is removed.
For example in the mpd module:
format-online = <toggle> <label-song> foo
If mpd is not running, the mpd module will return false when trying to
build the `<label-song>` tag. If we don't remove the space between
`<toggle>` and `<label-song>`, we end up with two spaces between
`<toggle>` and `foo`.
This change is to match the old behavior where at least one trailing
space character was removed from the builder.
* Add changelog entry
* Remove unused setting
* Use percentage with offset for tray-offset
Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
Co-authored-by: Joe Groocock <github@frebib.net>
If two processes call `mkdir` at the same time, the second one will fail
and wrongly assume the folder wasn't created properly.
We now first check if the folder really doesn't exist and we also catch
any IPC initialization errors and disable IPC instead of crashing the
whole bar.
* eventloop: Use eventloop namespace in cpp files
* changelog: Add missing deprecated hook message
* Make eventloop and ipc classes non-copyable and non-movable
* Remove functional.hpp
* eventloop: Don't close handles in error cases
Client should be responsible for closing handles.
* eventloop: Address invalidation of handle references
Deprecates not using `polybar-msg` for IPC.
Fixes#2532Closes#2465Fixes#2504
* Create FIFO specific NamedPipeHandle subclass to PipeHandle
* Prototype SocketHandle
* Move mainloop up to main.cpp
* Pass eventloop to ipc class
* Deprecate sending ipc over the named pipe
Unfortunately, we can only show the warning in the polybar log and not
give the user any feedback because the pipe is one-way
* Move eventloop into its own namespace
* Prototype ipc socket handling
* Remove handles from ipc_client
Should be independent from eventloop logic
* Remove ipc clients when finished
* Add tests for ipc_client decoding
* Add callback for complete ipc messages
* Remove template param from mixins
* Move signal handler to new callback system
* Move poll handle to new callback system
* Move FSEventHandle to new callback system
* Move TimerHandle and AsyncHandle to new callback system
* Move PipeHandle to new callback system
* Implement socket functionality in new callback system
* Correctly reset ipc named pipe handle
* Let client close handles in error callback
* Wrap client pipe and ipc::client in connection class
* Better decoder log messages
* Socket path logic
* Fix CI warnings
* Remove UVHandleGeneric
* Fix error when socket folder already exists
* Proof of concept message writeback
* Restructure ipc files
* polybar-msg: Use sockets
* polybar-msg: Better syntax for actions
* Fix memory leak with fifo
After EOF, the pipe wasn't closed and EOF was called all the time, each
time allocating a new pipe.
* Make polybar-msg compile on its own
* Rudimentary writeback for polybar-msg
* Fix payload reference going out of scope.
* Add IPC documentation
* Cleanup polybar-msg code
* Specify the v0 ipc message format
* Close ipc connection after message
* Fix ipc tests
* Properly close ipc connections
* Fix polybar-msg not working with action string
* Write polybar-msg manpage
* polybar-msg: Stop using exit()
* ipc: Print log message with PID
* Add tests for ipc util
* polybar-msg: Print PID with success message
* ipc: Propagate message errors
* Rename ipc::client to ipc::decoder
* Rename ipc.cpp to polybar-msg.cpp
* ipc: Write encoder function and fix decoder bugs
* ipc: Use message format for responses
* ipc: Handle wrong message types
* ipc: Write back error message if ipc message cannot be processed
This only happens for commands and empty actions.
Non-empty actions are not immediately executed, but deferred until the
next loop iteration.
* Remove TODO about deleting runtime directory
The socket file is not deleted after socket.close() is called, only
after libuv executes the close callback.
So we can't just call rmdir because it will probably always fail.
* CLeanup WriteRequest
* Update manpage authors
* Cleanup
Improve the find_interface() to return a interface name
that is currently running if any interface of given type
is currently running, else just return the first one found.
This will allow the interface-type to work with multiple net interface
of the same type, and prefer to one that is currently connect to
a network. This works great HW with multiple ethernet port and user
expect to occasonally swap between the two.
Fixes#2563Closes#2363
* Get battery status before adapter. (#2363)
* changelog: Move to Fixed section
Co-authored-by: patrick96 <p.ziegler96@gmail.com>
This fixes#857 and #1932. Also replaces PR #1725, since we don't need
our own implementation of condition_variable anymore since people who
update their polybar should have GCC 10 by now.
The m_updated_at field of the mpd module was removed instead of having
its clock change because it became unused in commit 645a3142a1.
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
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.
* 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>
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.
* 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>
* 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>
* 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
* 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>
* 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
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
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
* 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
* 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.
The eventloop no longer uses them. libuv will coalesces multiple
uv_async_send if they happen one after another and this also leads to
coalescing of updates.
This is needed because the handle's lifetime has to be at least the
lifetime of the eventloop since the eventloop requires the handle's
memory during shutdown (for closing the handles).
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
* 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>
* 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>
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>
* 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
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#1679Fixes#2430
* 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>
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
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.
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.
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.
* 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
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
* 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
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>
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
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).
* 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
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
* 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
* Fix xkeyboard module spacing between the layout and indicators when indicators are empty.
* Simplify the empty label check.
* Remove permanently enabled SCROLL_LOCK, sorry.
* Another mistake.
* Update src/modules/xkeyboard.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/modules/xkeyboard.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update.
* Fix xkeyboard module spacing between the layout and indicators, when indicators are empty. And fix the spacing between indicators when some are empty.
* Add issue #2292 to fixed.
* Update CHANGELOG.md
Co-authored-by: Filip Banák <6111455-Filip62@users.noreply.gitlab.com>
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* 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
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
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.
This was a backwards-incompatible change introduced in #2199, however it
was caused because `module_formatter.has` throws an exception when the
format doesn't exist instead of just returning false.
Fixes#2262
Ref #2199
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
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
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
* [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
* Added WARN state for cpu module
* Implement WARN state for CPU, Memory modules, working on fs module
* Implement WARN state for fs module
* Simplify WARN state implementation for cpu and memory
* explicitly check percentage in get_by_percentage_with_borders
* Fixed silly error
* implement warn state on battery module, standardize the implementation on other modules
* minor fixes
* fix annoying error
* use more intuitive param name
* Fix percentage with borders bug
* Make requested changes
Hide the effect of warn states when unused
* Backward Compat: use no format instead of fallback label
* Reformat
* Refactor
* Reformat
* Reformat: convert tabs to spaces
* Reformat
more granular units need lower precision, while less granular need
higher precision. assume sane default of:
unit | precision
KB | 0
MB | 1
GB | 2
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
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
New config option `speed-unit = B/s` will be used to suffix the upload and download speeds.
* mod::network: udspeed-unit to set network speed unit suffix
* Changed udspeed-unit to speed-unit
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
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.
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.
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.