* 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.
Some actions have data attached (e.g. xworkspaces-focus=N), the
forwarding logic now matches the keys in the legacy_actions map as
prefixes and everything afterwards is considered additional data and
appended to the new action string.
All modules now expose their actions as public static constants
Issues: The menu module no longer closes when an item is clicked (before
it would intercept any executed command and look if it matches one of
its exec commands)
All the information about which action has to be delivered to which
module is kept in once place to make cleanup easier once the deprecated
actions are removed.
Right now only the date module is added as a proof of concept.
This allows us to identify module by their type and it is also better to
store the module type as part of the module instead of having it
hardcoded in factory.hpp
Action strings now have the form '#MODULE#ACTION'
For example to trigger the action 'toggle' in the 'module/date' module
one would now use '%{A1:#date#toggle:}'
With this action strings can now be uniquely assigned to one module.
Fixes#1172
Before the time difference between two measurements was always an
integer number, so for intervals < 1, you would always get 0 and for any
other non-integer interval you would get skewed results.
ramp-0 is used for everything <= base-temperature and ramp-N is used for everything >= warn-temperature
* [Temperature, Ramp] fix wrong icon for temperatures near base and warn temps
* [Temperature, Ramp] fix wrong icon for temperatures near base and warn temps
* Fix minor error
* explicitly check percentage in get_by_percentage_with_borders
* Fixed silly error
* Prioritize battery full-at over state
The `full-at` option should take priority
over the charging state of the battery.
Closes#1622 (issue for Thinkpad laptops)
* Remove typo from clamp_percentage
Some devices can have "amdgpu_bl1" or "amdgpu_bl2", but the code hardcoded in the value "amdgpu_bl0". This change tests based on the first characters: "amdgpu_bl".
If an input is enqueued as a response to an input, the new input will be
swallowed because it will likely be enqueued less than 30ms after the
original event.
This is not something that is an issue right now but it is required to
finish #1907 where, in order to close the menu after a click, the menu
module gets an exec action that closes the menu and adds a command to
the event queue.
The setting also isn't too useful since it will just break polybar input
handling if inputs arrive too fast instead of (possibly) slowing down
the bar.
Before the module would just try to evenly distribute desktops
(workspaces) among the viewports.
But since `_NET_DESKTOP_VIEWPORT` actually maps desktops to viewports,
we can use that information to assign workspaces to the right viewport.
Fixes#1849Fixes#1764
It is useful for people to see what config file polybar loaded.
For debugging font issues people almost always need to check what fonts
polybar loaded, for that they need to run polybar with info logging. Now
this information is always provided. This requires an update in the font
wiki page.
A warning implies something went wrong and (possibly) the user should do
something about it. However, warnings are not always used this way.
For example:
* When a fallback value for a `${..}` reference is used, this shouldn't
produce a warning (or notice) since using fallbacks is not something
bad.
* pulse telling you that it uses the default sink because no sink was
specified also does not warrant a warning (even notice may be too
high).
* Whenever polybar shuts down it produces a "Termination signal
received..." warning. Since there isn't a more proper way to shut down
polybar, it should not produce a warning. Same argument for a
`screenchange-reload`
Before it would only reload if the size changed and even that was
reliable since the method relied on the order of the monitor list.
Now if the monitor list differs in any way (pos, dimension, primary,
output, name) a reload is issued
Because of how monitors are removed inside the loop and depending on the
monitor order a cloned monitor may be assigned a width of 0 but is never
actually removed resulting in polybar saying the bar is out of bounds
Fixes#1794
Removing monitors is not really necessary when selecting the monitor
where to render the bar or choosing the backlight. Since both monitors
occupy the same coordinates rendering can be done on both and it's
better to give people felxibility for the backlight.
Fixes#1191
Premature optimization that tried to cache monitors but the cache did
not take into account the parameter values.
The call `get_monitors(..., ..., false, true);` would get all connected
and unconncected monitors a subsequent call
`get_monitors(..., ..., true, false);` would get back the same list of
monitors even though it requested only connected monitors.
Additionally `get_monitors` is never called periodically so the
optimization really didn't help much.
The github module only authenticate by query string, and this method is deprecated:
https://developer.github.com/changes/2019-11-05-deprecated-passwords-and-authorizations-api/#authenticating-using-query-parameters
There is no reason to remove it before the method stop working, so I've made possible to the user choose which authentication method he will use:
* The parameter token remain unchanged.
* If the parameter user is passed then the module will use the not deprecated method, passing user and token on the body of the requisition. Otherwise the module will use the deprecated method.
Co-authored-by: Lucas <araujo.lucasvale@gmail.com>
Fixes#2002
If an exact match was possible, fuzzy matching could still return a
non-exact match if it appeared before the exact match in the list of
icons.
Fixes#2041
Adds `format-offline` and `label-offline`
* feat(github): offline label & fixes
* Clear label if there are no notifications and empty-notifications = false
* clang-format
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
In the case where _NET_NUMBER_OF_DESKTOPS > |_NET_DESKTOP_NAMES|
the last branch of the get_desktop_names method would return a vector
with _NET_NUMBER_OF_DESKTOPS + 1 elements because we iterate until
_NET_NUMBER_OF_DESKTOPS + 1.
Fixes#1983
Functionality-wise reverts the changes from #1534
In #1907 we have decided to allow the same module to appear multiple
times (and deliver actions to all matching modules). But since that PR
will likely take longer to get merged, I want to remove the error from
polybar because the message it prints isn't really true anymore.
Before, if the command produced no output, the `m_output` field would
not have been overwritten and the old output was displayed.
But since this is an explicit trigger of the hook, the user would expect
the output to be updated to whatever the script produces (even if that
is nothing).
Ref: https://www.reddit.com/r/Polybar/comments/e9a8ww
The old code didn't really work when the right block was pushing against
the center block. Also `fixed-center` wasn't properly defined. I have
now fixed it to the following:
* `fixed-center = true`: The center block stays at the center of the bar
whenever possible. It can be pushed to the left if the right block takes
too much space and to the right if the left block takes too much space
* `fixed-center = false`: The center block will be in the middle between
the left and right block whenever possible. If there is not enough space
between those two, the center block will be directly to the right of the
left block and pushes out the right block
The issue was that it used the position of the center module to
calculate the leftmost possible position of the block. However, if the
center module is empty that position is disastrously wrong.
Fixes#591Fixes#1903
the `node` and `node_repeat` were never called with the optional
parameter add_space. And its default value is false, so the
corresponding code was never used.
I think in general it is better to just have the user of those functions
call `builder::space` when they need to instead of adding more
complexity to the `node*` functions.
* Add label minlen and alignment.
Fix build
* Update src/drawtypes/label.cpp
Co-Authored-By: infokiller <infokiller@users.noreply.github.com>
* Use existing alignment type.
* Remove redundant max_len handling in label::get.
* Fix shadowing.
* Add label alignment tests.
* Handle minlen/maxlen and alignment in same function.
Also add a test for a test case brought up in the PR discussion.
* Format files with clang-format
* Move builder::get_label_text tests into label tests
builder::get_label_text doesn't really do anything anymore
* builder: remove get_label_text
* label: Clean up label::get()
* Fix comment style.
* Set default label alignment to left.
* Update src/drawtypes/label.cpp
Co-Authored-By: Patrick Ziegler <p.ziegler96@gmail.com>
* Update include/drawtypes/label.hpp
Co-Authored-By: Patrick Ziegler <p.ziegler96@gmail.com>
None of the payload fields seem to be used. They were the only place
where EVENT_SIZE was used and why it had to be a macro (no variable
length arrays).
Since APP_VERSION is different for every commit and almost all file
include settings.hpp, the whole project has to be rebuilt for every
commit. With this, hopefully, this can be greatly reduced and only
changed files need to be rebuilt. This will also help ccache
Some people use text modules instead of the `separator` key in the bar
section to better configure the separator (colors, fonts).
Since we disallowed the same module being used multiple times in #1534,
this will now print an error message.
This should help with this a bit.
Ref #1913
Some WMs like i3 discard position information when unmapping the bar and
because of that the bar would be at the wrong position after being
remapped.
Fixes#1484
Ref: https://github.com/i3/i3/pull/3834
* refactor: Use flat module list if possible
Before if you wanted to iterate over all loaded modules you had to first
iterate over all blocks and then over their modules even if you didn't
care about alignment.
* refactor: setup modules in separate function
* controller: Print error for duplicate modules
You can't use the same name twice inside the module lists
E.g.
modules-left = a b c
modules-center = a
modules-right = b
would print an error.
We only print an error for now because we don't want to break existing
configs. But in the future this should be properly enforced.
A workspace is occupied if it is not active and there is at least one window managed by the WM (`_NET_CLIENT_LIST`) that has set `_NET_WM_DESKTOP` to that workspace.
The behavior when `_NET_WM_DESKTOP` is not set is not yet clear but this is unlikely to happen since most WMs will position windows on some desktop.
Closes#874Fixes#1444Fixes#1033
* Set Desktop OCCUPIED if a window moves there
This covers more of an edge-case. I did this first by accident, it might
vanish later on.
* Replace tracking change of WS with currently used WS
* Untrack occupied workspaces
* Track windows and their desktops in pairs
* Match type of occupied_desktops with current_desktop
Because the index needs to be matched later on, type mismatches would be non-ideal.
* Recreate the occupied desktops everytime and remove duplicates
* Readd support for moving windows to other desktops
* Use less characters to empty the vector
* Rename variable storing the desktops
* Recount windows on every occasion
This alone simplifies the management and the lookup for occupation of a
workspace
* Keep track of number of windows in every workspace
* Add debugging output that shall be removed before merging
* Remove obsolete TODO
* m_client_list should always be diff'd, since the desktop may change
Therefore we update the desktop-count tally every time the client_list
changes. It may just be a desktop-change without a change of
clients.size()...
* Add more logging-spam to understand window/desktop lifecycle
* Lock event-handler to serialize handling of events
* Fix occupied workspace counting and change to bool array
Also, performance improvements when diffing new and old client lists
* Fix crash when all clients are removed
* Conform to linter and styleguide
* Shorten conditional as it is standard enough
Since this only guards against 0-divisions, it can be shortened
without risking too much confusion down the road.
* Guard against multiple threads accessing and modifying data
Fixes#1444
Modification of internal data happens through the handle-method, while
the build-method tries to access the data structures for display. Since
some modifications clear e.g. the m_viewports, references may become
invalid between looping over them an accessing them.
The mutex should guard against this simultanuous access.
* Do not 'adopt_lock', because calls come from very different threads
To my understanding, adopt_lock has some dependency on the mutex-ownership. Since
the lock is once called from the inside (in handle) and once from the outside (in
build), there might be a problem. After brief testing, the segfaults happened fewer
times.
See #1444
* Also listen to _NET_WM_DESKTOP
In order to move a window from one desktop to another, it is sufficient
to set the desktop-property of that window. xmonad fires a lot of events
in the case of moving a window, herbstluftwm only updates the
_NET_WM_DESKTOP-atom of the window.
This change reloads the clientlist in order to correctly set the
desktop state "occupied".
* Describe need and use of mutex
It might be possible to relieve the guard in xworkspaces_module::handle,
but I am unsure about this. Since xmonad emits a lot of events on almost
every minor change, I would let the guard keep its post, avoiding
race-conditions in event-handling.
* Give temporary variables better names
* Clarify purpose of loop
About 80% of this comment are taken from
https://github.com/jaagr/polybar/pull/882#discussion_r255317363
* Remove merge-remainder
* Use a simpler method to list occupied desktops.
Co-authored-by: Jérôme Boulmier <jerome.boulmier@outlook.fr>
* Document m_clients field
While an update was forced whenever polybar was made visible, the
`m_lastinput` variable was still set to the same value as when the bar
became hidden because updates to it were prevented.
Fixes#1875
This fixes a regression introduced in
56e24992df where relative config file
paths weren't recognized because file_util::expand just added a slash
to the beginning.
That is calling `polybar -c config example` would try to load the config
file at `/config` instead of using the relative path as before.
In all other cases where expand is used this change shouldn't matter
because polybar only accepts absolute paths everyhwere else.
Theoretically this would now allow relative paths (relative to the cwd
where polybar was called) but this shouldn't used (or documented)
because that behavior will change when merging #1523 which would make
paths relative to the polybar config.
Ref #1523
Ref 56e24992df
The %{PR} tag is introduced for this. It resets all colors as well as
the activation of the underline and overline and font.
This has become necessary because we don't track what raw tags a user
injects into the formatting string and otherwise their raw tags could
bleed through.
This doesn't touch action tags because even before raw action tags
weren't being tracked. Action tags also have the requirement that they
have to be used in pairs, so closing them prematurely could break things
(for example with click actions for the entire bar)
When adding a string to the builder directly, it would parse the string
for formatting tags, delete them and readd them with the methods in the
builder that keep track of open tags so that we can properly close them
when flushing.
This parser has a bug, it parses multiple formatting tags in a single
block as a single tag, e.g.
%{F#000000 u#FFFFFF +u}
would be parsed as an `F` tag with value `#000000 u#FFFFFF +u` which is
of course wrong.
Removing the parsing step fixes this problem in the simplest way
possible. This has two benefits:
* Building of modules is sped up because we don't have to do the parsing
step in the builder and many modules use this function to add strings
from a progressbar (which already has properly closed tags).
* We don't have parser logic in two places. Until now both `parser.cpp`
and `builder.cpp` actually parsed formatting tags. This leads to a lot
of code duplication and, as we've seen, bugs.
All of the modules that use this function to add text already make sure
that they properly close formatting tags (mostly by using the builder to
generate the strings)
NOTE: This change slightly changes polybar's behavior. Raw tags (tags
added by the user through the config) can now have their effects reach
neighboring modules because the builder doesn't track and thus doesn't
close them on each flush. This can (and will) be resolved by resetting
all tags at module borders.
Fixes#1555
There really is no reason to also close over/underline tags when we have
a right margin and a non-black over/underline color.
The git blame for these lines also doesn't give us any insights as to
why it was done this way.