Commit Graph

118 Commits

Author SHA1 Message Date
patrick96
39a640d5d0 Move banner to doc folder 2022-03-13 21:26:54 +01:00
patrick96
b04f636bab doc: Mention XDG_RUNTIME_DIR for IPC 2022-03-05 13:59:27 +01:00
Samuel Henrique
40cbe7ed97 Skip manpage and html doc installation if they weren't generated
Otherwise we get errors like this:

 CMake Error at doc/cmake_install.cmake:46 (file):
  file INSTALL cannot find
  "/<<PKGBUILDDIR>>/build/doc/html": No such file or
  directory.
 Call Stack (most recent call first):
  cmake_install.cmake:59 (include)
2022-03-02 23:46:46 +01:00
patrick96
4350e356a7 Documentation update for 3.6 2022-03-02 14:58:49 +01:00
patrick96
fce5c4445f
Release 3.6.0 2022-02-26 21:42:34 +01:00
patrick96
f1490a13ca Use points in default config
Allows people to better scale by setting the dpi
2022-02-25 04:38:07 +01:00
Michał Górny
a33e8de922 doc: Defer parsing version_txt to fix an obscure bug
Defer parsing the version read from version.txt until it's about
to be used, in order to fix an obscure bug involving indirect
pkg_resources.

When pkg_resources are imported, they override packaging with their own
pkg_resources.extern.packaging.  Depending on the system, this could
either wrap the vendored pkg_resources._vendor.packaging or system
packaging.  For some reason, in the latter case the Version objects
created prior to the wrapping are incompatible with the objects created
afterwards.  This causes the doc build to fail with:

```
Exception occurred:
  File "/tmp/polybar/build/doc/conf.py", line 249, in run
    if directive_version > version_txt:
TypeError: '>' not supported between instances of 'Version' and 'Version'
```

This happens because apparently pkg_resources are imported indirectly
somewhere between conf.py processing and running VersionDirective.
Deferring version parsing until the latter guarantees that both objects
are constructed at the same point in program flow and therefore use
the same packaging package.
2022-01-31 01:20:18 +01:00
patrick96
f428b7bb2f Install manpage for polybar-msg 2022-01-24 13:47:49 +01:00
Patrick Ziegler
3356188056
Use sockets for IPC (#2539)
Deprecates not using `polybar-msg` for IPC.

Fixes #2532
Closes #2465
Fixes #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
2022-01-22 20:35:37 +01:00
dvermd
231af35354
feat(ipc): hook, prev, next, reset module actions (#2528)
* 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>
2021-10-10 20:22:24 +02:00
dvermd
47b5910eda
Allow running polybar without BAR argument (#2526)
* 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
2021-10-07 14:48:47 +02:00
Patrick Ziegler
282b0f4e73
Create default config (#2511)
* 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>
2021-10-05 13:07:19 +02:00
Patrick Ziegler
a520fead94
doc: Update description of polybar -m/-M (#2487)
It should be clear that `polybar -M` represents all valid monitor names.
2021-09-02 18:18:52 +02:00
Vincent Bernat
5f3462240c
feat(ipc): allow receiving arbitrary text on IPC socket (#2463)
This adds the 'send' action to the ipc module that can be used to send arbitrary text to the module:

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

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

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

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

Fix #2455

* Use actions for sending data to ipc module

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

* Update src/modules/ipc.cpp

Co-authored-by: patrick96 <p.ziegler96@gmail.com>
2021-07-11 20:42:28 +02:00
patrick96
55509efa1d
doc: Add version to module visibility actions 2021-07-10 21:22:17 +02:00
Nolan Prochnau
06932007a0
Universal Visibility Action (#2320 cont'd) (#2426)
* Add toggle_visible action

* Add set_visible and set_invisible actions

* Rename toggle_visible method to match

`action_toggle_visible` -> `action_toggle_visibility`

Matches with `EVENT_TOGGLE_VISIBILITY`

* Update CHANGELOG

* Revert #2320 IPC commands

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

* Add logging and change action names

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

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

* Update documentation
2021-07-07 21:43:49 +02:00
Patrick Ziegler
3247a57a63
Change over all IRC mentions to libera (#2450) 2021-06-16 17:02:58 +02:00
patrick96
c65f6857e1
Merge branch 'hotfix/3.5.6' 2021-05-24 01:07:24 +02:00
patrick96
1ddd8bd1e1 fix(build): Disable sphinx manpage section dirs
Before sphinx 4.0, this was the default but was changed in 4.0.
Now by default the folder structure looks like this:

man
├── 1
│   └── polybar.1
└── 5
    └── polybar.5

This restores the old behavior where there weren't individual folders
for the different sections.

Fixes #2424
Ref: https://www.sphinx-doc.org/en/master/changes.html#id14
2021-05-09 21:28:22 +02:00
patrick96
8ca154caaa
Merge branch 'hotfix/3.5.5' 2021-03-01 21:39:16 +01:00
patrick96
6b1c5489a2 fix(build): Only change VersionDirective if supported
The VersionChange class is not available in older versions of sphinx, so
we just disable it

Fixes #2356
2021-03-01 21:27:59 +01:00
Filip Banák
4ded401aab
Add initial support for an escape character (#2361)
Add a config parser method which, for now, deals only with escaping the
literal backslash character and logs an error message to inform the user
of the coming change.

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

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

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

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

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

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

Resolves: First step in #2354

Improve value parsing

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

Add escape character documentation to manpages

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

Add info about the esacape character to changelog

Add test cases for ParseLineKeyTest

Fix ParseLineKeyTest test cases

Also make config parser method parse_escaped_value private.

Add tests for escaped_value_parser method

Also remove unsued include statement

Simplify parse_escaped_value in config_parser

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

Fix ParseEscapedValueTest test cases

Fix parse_escaped_value

Add more test cases for ParseLineKeyTest

Update CHANGELOG.md

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

Adress review

 - Adjust documentation
 - Small code changes

Improve parse_escaped_value

Add initial support for an escape character

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

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

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

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

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

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

Resolves: First step in #2354

Improve value parsing

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

Add info about the esacape character to changelog

Add test cases for ParseLineKeyTest

Fix ParseLineKeyTest test cases

Also make config parser method parse_escaped_value private.

Add tests for escaped_value_parser method

Also remove unsued include statement

Simplify parse_escaped_value in config_parser

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

Fix ParseEscapedValueTest test cases

Add more test cases for ParseLineKeyTest

Adress review

 - Adjust documentation
 - Small code changes

Remove duplicate testcase from ParseLineKeyTest

Add initial support for an escape character

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

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

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

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

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

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

Resolves: First step in #2354

Improve value parsing

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

Fix ParseLineKeyTest test cases

Also make config parser method parse_escaped_value private.

Remove duplicate testcase from ParseLineKeyTest
2021-01-26 19:16:29 +01:00
patrick96
ad2d3652f9 Add items for milestones and readthedocs to release workflow 2021-01-07 20:48:04 +01:00
patrick96
3ac93845fc Install changelog file as part of the documentation 2021-01-07 20:48:04 +01:00
patrick96
50b567f070 sphinx: Turn on nit-picky mode 2021-01-07 20:48:04 +01:00
patrick96
ca8fbe5c86 doc: Exclude .buildinfo file from installation
The file contains information about the build itself (hashed) and is not
really useful.
2021-01-07 20:48:04 +01:00
patrick96
b49f325e1e doc: Add language to code-blocks 2020-12-24 12:46:02 +01:00
patrick96
ddfec6fc8f build: Add option to enable/disable html/manpages 2020-12-24 02:20:38 +01:00
patrick96
923d9ae061 Add cmake files for configuring individual targets
This makes the code a bit less messy. We barely need if(BUILD_...)
guards inside the cmake files, just the root CMakeLists.txt.
2020-12-24 02:20:38 +01:00
patrick96
c24a6999a4 refactor(cmake): Allow targets to be enabled individually
Each major target of polybar can now be enabled/disabled while
configuring (even polybar itself).

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

This allows us to for example just build the documentation without
having to run all the cmake code related to compilation or having the
polybar dependencies installed (other than sphinx).
2020-12-24 02:20:38 +01:00
patrick96
16b2970bd7 build: Bump cmake version to 3.5.0
This includes the changes from polybar/xpp#30 which also updates the
minimum cmake version in the xpp submodule
2020-12-24 02:20:38 +01:00
Kamui
89a723a4d9
feat(config): Try to load config.ini (#2324)
* Added .ini extension check to default config

* Added change to changelog and man page

* Added change to changelog and man page

* removed .vscode folder

* removed new lines in changelog
2020-12-23 17:52:30 +01:00
patrick96
218911c463
Merge remote-tracking branch 'origin/hotfix/3.5.3' 2020-12-23 17:42:12 +01:00
Patrick Ziegler
1bf89e8b76
fix(docs): Support out-of-tree builds (#2312)
Searching up from the conf.py only works if it is inside the repository
and not for out-of-tree builds (because conf.py gets configured in the
build directory).
2020-12-17 14:02:48 +01:00
Patrick Ziegler
cec463e830
doc: Don't use git for checking version number (#2311)
If git is not available (and it doesn't have to be when building from a
source archive) building the documentation fails because we use
`git rev-parse` to determine whether a certain version is unreleased.

We now use the version.txt file to do this check

This uses the packaging library, but this should not introduce a new
dependency because sphinx depends on setuptools which also depends on
that library.

Fixes #2309
2020-12-17 05:12:09 +01:00
Patrick Ziegler
d63bf294b7
Adopt "keep a changelog" (#2308)
* Adopt keep a changelog

Ref: https://keepachangelog.com/en/1.0.0/

* Add changelog to release and contributing docs

* Use H2 for automatically added Download section

The individual changelog subsections use H3 and the changelog section
uses H2, so the Download section should use the same heading

* Add already present changes to changelog

* Mention changelog issue references in CONTRIBUTING.md
2020-12-16 16:04:10 +01:00
Patrick Ziegler
1168ef36a0
github: Add action to create release archive (#2277)
Whenever a release is published, this action will create a release
archive and update the release body with a download section.

This also integrates the suggestions from #2276

Resolves #2276
2020-12-06 18:16:17 +01:00
Patrick Ziegler
26a9bc5964
fix(doc): Typo (#2257)
Thanks to u/TheNextPoetician for reporting on reddit

Ref: https://www.reddit.com/r/Polybar/comments/k4llsx/typo_in_the_man_page/
2020-12-01 17:12:02 +01:00
patrick96
1afb333858 doc(actions): Point user to doc when using legacy actions 2020-11-26 20:53:53 +01:00
patrick96
0a1b58a2ed doc(actions): Finish migration documentation 2020-11-26 20:53:53 +01:00
patrick96
c427ec06d7 doc(actions): Finish list of available actions 2020-11-26 20:53:53 +01:00
patrick96
5e64361ed8 doc(actions): Start supported actions table 2020-11-26 20:53:53 +01:00
patrick96
d45ae7954a doc: Finish legacy action migration table 2020-11-26 20:53:53 +01:00
patrick96
1d9365e74f doc: Allow using rtd theme locally 2020-11-26 20:53:53 +01:00
patrick96
3e4f8d402e doc: Initial action documentation 2020-11-26 20:53:53 +01:00
patrick96
c34f013e5f doc: Reflect config fallback in config
This should reflect the changes from #2026
2020-11-23 13:16:37 +01:00
patrick96
df15a4062a doc: Write new release workflow
We now use OneFlow [1] for releases 3.5.0 and onwards.

Closes #1780

[1]: https://www.endoflineblog.com/oneflow-a-git-branching-model-and-workflow
2020-11-22 23:32:41 +01:00
patrick96
91e31317a7 doc: Set SPHINX_BUILD in standalone doc builds
If we build only the documentation by invoking `cmake` on the `doc`
folder, the `SPHINX_BUILD` variable is not set and instead of

```
sphinx-build -b html ...
```

it will just execute

```
-b html ...
```

This produces an error but doesn't fail the build because apparently if
the command starts with a dash an error is non-fatal.

Fixes #2191
2020-10-03 15:37:17 +02:00
Patrick Ziegler
b0e9e3ff61
doc: Add '(unreleased)' tag for unreleased versions (#2118)
The tag is added to the 'deprecated', 'versionadded', and the
'versionchanged' directives.
2020-06-07 21:54:04 +02:00
patrick96
cae3848030 logger: Add default logging level 'notice'
Between info and warning. Should be for things the user should be aware
of but not imply anything has to be done about it.
2020-04-22 00:38:31 +02:00