Positions the bar window above the _NET_SUPPORTING_WM_CHECK window
The generic restacking strategy now first tries the ewmh strategy, the
the bottom strategy.
* Return shared_ptr from eventloop
* Add -Wdeprecated-copy-dtor warning
Produces a warning if classes don't have explicit copy operations if
they have a user-defined constructor.
This helps us stick to the rule of 5 (kinda, no warnings for missing
move operators).
* Clean up eventloop
* Fix compiler warnings
* Fix fs_event_handle_t name
* 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>
* 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
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>
* 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>
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
* 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>
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.
* build: Add -Wsuggest-override
We should always use the override specifier when overriding virtual
functions. This helps prevent errors when a subclass tries to create a
function with the same name as a virtual function in a super-class but
with a different purpose.
* clang-format
* Upload logs on failure
* Add override to unsupported.hpp
* cmake: Make -Wsuggest-override flag conditional
* 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
* 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
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