Commit Graph

186 Commits

Author SHA1 Message Date
patrick96
816b73a95f actions: Add utility functions to produce action tags 2020-11-26 20:53:53 +01:00
Guilherme Silva
8dbd1740a7
feat(config): include-directory directive (#2196)
Closes #1946
2020-10-08 17:44:29 +02:00
joaquin garmendia
bb15e33a2a
fix(alsa): Remove upper bound to get_volume (#2184)
Fixes #2173 

* feat(alsa): Remove upper bound to get_volume

* Add tests. Trim unnecessary function.
2020-09-20 14:26:17 +02:00
Jérôme BOULMIER
78b5f88c5f Fix gcc compilation 2020-05-14 22:45:40 +02:00
Jérôme BOULMIER
f016b99e08 Redirect process output to dev null 2020-05-08 23:24:29 +02:00
Jérôme BOULMIER
e9d2f022cd add command unit tests 2020-05-08 23:24:29 +02:00
Jérôme BOULMIER
5e5d8faf04 fix(command): broken pipe when ignoring output. 2020-05-08 23:24:29 +02:00
Lucas Araújo
15496bfb4a
Update: Using another way to authenticate github module (#2029)
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
2020-03-26 12:50:42 +01:00
Lucas Araújo
512c519f25
config: Check if config path exists (#2026)
Closes: #2016

* update: Checks if the configuration file exists

* Update: Removing the logic of the config file search from main.cpp
2020-03-01 22:03:17 +01:00
Gus Caplan
068bf5a311 feat(backlight): Add enable-scroll (#1957)
* backlight: enable changing via scroll

* squash! feedback

* Update src/modules/backlight.cpp

Co-Authored-By: Jérôme BOULMIER <jerome.boulmier@outlook.fr>

Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
2020-01-15 16:32:17 +01:00
Jérôme BOULMIER
e5783d4113 Include empty tokens when splitting if necessary (#1893)
Fixes #1881
2019-11-21 22:26:53 +01:00
patrick96
8b310cc05d fix(build): Ignore noexcept-type for malloc_ptr_t
Since all of polybar is built at once, there is no chance that this is
ever linked to an object that was compiled with another `-std=`

Ref: https://stackoverflow.com/a/46857525/5363071
2019-10-26 22:28:47 +02:00
Patrick Ziegler
56e24992df
config_parser: Introduce stricter syntax conventions (#1377)
This is the next step to merge #1237 in stages.

Currently there are barely any restrictions on how the config can be
written. This causes things like config files with DOS line endings to
not be parsed properly (#1366) because polybar splits by `\n` and when
parsing section headers, it can't deal with the `\r` at the end of the
line and thus doesn't recognize any section headers.

With this PR we introduce some rules as to what characters are allowed
in section names and keys.
Note: When talking about spaces I refer to any character for which
`isspace()` returns `true`.

The rules are as follows:
* A section name or a key name cannot contain any spaces as well as any
of there characters:`"'=;#[](){}:.$\%`
* Spaces at the beginning and end of lines are always ignored when
parsing
* Comment lines start with `;` or `#` and last for the whole line. The
whole line will be ignored by the parser. You cannot start a comment at
the end of a line.
* Section headers have the following form `[HEADER_NAME]`
* Key-value lines look like this:
`KEY_NAME{SPACES}={SPACES}VALUE_STRING` where `{SPACES}` represents any
number of spaces. `VALUE_STRING` can contain any characters. If it is
*surrounded* with double quotes (`"`), those quotes will be removed,
this can be used to add spaces to the beginning or end of the value
* Empty lines are lines with only spaces in them
* If the line has any other form, it is a syntax error

This will introduce the following breaking changes because of how
underdefined the config syntax was before:
* `key = ""` will get treated as an empty string instead of the literal
* string `""`
* Any section or key name with forbidden characters will now be syntax
errors.
* Certain strings will be forbidden as section names: `self`, `root`,
* `BAR`. Because they have a special meaning inside references and so a
* section `[root]` can never be referenced.

This replaces the current parser implementation with a new more robust
one that will later be expanded to also check for dependency cycles and
allow for values that contain references mixed with other strings.

This PR also now expands the config paths given over the command line so
that `--config=~/.config/polybar/config` resolves properly.

Closes #1032
Closes #1694

* config_parser: Add skeleton with tests

First step in the config_parser develoment. Only tests functions that
are easily testable without many outside dependencies. Integration tests
will follow.

* config_parser: Implement parse_header

* config_parser: Implement get_line_type

* feat(string): Add trim functions with predicate

Not only trimming based on single character matching but based on a
freely specifiable predicate. Will be used to trim all spaces (based on
isspace)

* config_parser: Implement parse_key

* config_parser: Implement parse_line for valid lines

* config_parser: Throw exception on invalid lines

* config_parser: Remove line_no and file_index from parse_line

Cleaner to let the caller catch and fill in the line number and file
path

* string: Clear up misleading description of trim

Before, trim would remove all characters that *didn't* match the
predicate and thus the predicate isspace wouldn't work correctly. But
because we used the inverse (isnospace_pred) it all worked out, but if
the function was used with any other function, it wouldn't have given
the desired output

* config_parser: Implement parse_file

* config_parser: Switch operation to config_parser

This changes the way the config is invoked. Now main.cpp creates a
config_parser object which then returns the singleton config object from
the parse method. Subsequent calls to config::make will return the
already created config object as before

The config_parser does not yet have all the functionality of the old
parser: `inherit` directives are not yet resolved. Other than that all
the old functionality is implemented (creating sectionmap and applying
include-file)

Any sort of dependency detection (except for include-file) are still
missing

* config: Move xrm initialization to constructor

config_parser handles the detection of xrdb references and passes that
info to the config object.

This finally allows us to delete the config::parse_file function because
everything in it has been implemented (except for xrdb detection and
file error handling)

* refactor(config_parser): Cleanup

* config_parser: Set config data after initialization

Looks much cleaner this way

* config_parser: Expand include-file paths

* config_parser: Init xrm if the config uses %{xrdb references

* config_parser: Use same type of maps as in old impl

Polybar has some weird, not yet fixed, inheriting behaviour and it
changes depending on the order in which the config stores its data.
Using the same type of maps ensures that the behaviour stays the same.

* refactor(config_parser): Clearer invalid name error message

* config_parser: Don't allow reserved section names

Sections with the names 'self', 'BAR', 'root' could never be referenced
because those strings have a special meaning inside references

* config_parser: Handle inherit directives

This uses the old copy_inherited function, so this still suffers from
crashes if there are cyclic dependencies.
This also fixes the behaviour where any key that starts with 'inherit'
would be treated as an inherit directive

* config_parser: Clearer dependency cycle error message

* refactor(config_parser): Handle file errors when parsing

This removes the need to check if the file exists separately

* fix(config): expand config file path

Now paths using ~ and environment variables can be used as the config
path

* fix(config): Properly recognize xrdb references

* config_parser: Make messages more informative

* doc(config): Improve commenting

Comments now describe what the config_parser actually does instead of
what it will do.

We also now follow the rule that single line comments inside functions
should use `//` comments

* refactor: Move else on same line as curly braces

* fix(config_parser): Don't duplicate paths in `files`

* refactor(config_parser): Use else if for clarity

* fix(config): Undefined behavior in syntax_error

Before the custom what() method produced undefined behavior because the
returned string became invalid once the function returned.

* refactor(config): descriptive name for useless lines

is_valid could easily be confused as meaning syntactically invalid
without it being clarified in a comment

* refactor(config): Use separate strings instead of key_value

Takes just as much space and is much better to read

* fix(config_parser): TestCase -> TestSuite and fix macro call

Ref: #1644

* config_parser: use const string& in method args

* config_parser: Improve comments

* config_parser: Incorporate review comments
2019-08-06 19:41:31 +02:00
Jérôme BOULMIER
31a25af3d3 fix(tray): fix offset for negative percentage (#1669)
tray-offset-{x,y} were clamped between [0, max_value] rather than [-max_value, max_value]. Therefore negative percentage were ignored.

Fixes #1666
2019-03-22 09:55:08 +01:00
patrick96
6ca4f06785 doc: Convert @ to \ doxygen commands
Ref #1377
2018-11-04 19:28:27 -08:00
Michael Carlberg
d3b0670f30 fix(config): Perform tilde expansion on include-file #603 2017-06-02 18:34:49 +02:00
Chase Geigle
73faa18cf0 fix(label): Truncate label replacements based on codepoint count
This helps ensure that when a string is truncated it is not done in the
middle of a utf8 multi-byte sequence. This doesn't 100% correspond to
user-perceived characters, but it should be pretty close in most cases.
2017-02-15 14:19:47 +01:00
Michael Carlberg
beedc5ab84 fix(color_util): Parsing 2017-01-27 13:46:27 +01:00
Michael Carlberg
874e6b0d6c feat(config): Add directive for file inclusion 2017-01-26 20:10:33 +01:00
Michael Carlberg
95d5b03fa2 refactor(file_util): Expand tilde manually 2017-01-25 17:07:55 +01:00
Michael Carlberg
c74a1647ab fix(color_util): Add missing header 2017-01-24 12:37:19 +01:00
Michael Carlberg
a5d6670121 refactor(clang-tidy): Apply fixes 2017-01-24 08:01:04 +01:00
Michael Carlberg
6cc7a2c093 fix(color_util): Use lambda 2017-01-24 07:11:14 +01:00
Michael Carlberg
452afcdc68 refactor: Integral types 2017-01-24 07:11:14 +01:00
Michael Carlberg
5e1886a312 wip(refactor): Cairo drawing 2017-01-24 07:11:14 +01:00
Chase Geigle
47a2cce03d fix: Ensure reloading when IN_IGNORED fired on config (#371)
This fixes a "bug" where polybar wouldn't reload on a configuration
file change on some configurations of vim, which don't actually issue
any IN_MODIFY events because they choose to move the file, replace it
with a new one, and then delete the file instead.

To work around this, we now also listen for IN_IGNORED which fires when
the file we are watching is destroyed. When this happens, we re-attach
the configuration file watcher to the new file and reload.
2017-01-24 07:10:55 +01:00
Michael Carlberg
6250a2b746 fix(streambuf): Buffer size 2017-01-14 09:57:09 +01:00
Michael Carlberg
dceb3606b1 refactor(stringstream): Shorten to sstream 2017-01-14 06:11:51 +01:00
Michael Carlberg
e1dbd98c40 feat(string_util): Custom stringstream 2017-01-13 13:01:22 +01:00
Michael Carlberg
6dd72aa6f7 refactor(fs): Read /proc/self/mountinfo
Refs #271
2017-01-12 23:33:32 +01:00
Michael Carlberg
c737493620 fix(mtab): Add missing header 2017-01-12 21:11:21 +01:00
Michael Carlberg
c2ac7fde67 refactor: Filesize strings 2017-01-12 20:28:44 +01:00
Michael Carlberg
5773b08cf8 fix(script): Poll file descriptors 2017-01-11 18:21:58 +01:00
Michael Carlberg
5b33ada576 refactor(common): Cleanup 2017-01-11 07:17:54 +01:00
Michael Carlberg
5c9bfc147c fix(xbacklight): Lower inc/dec value to 5 and fix flooring 2017-01-11 04:40:10 +01:00
Michael Carlberg
8cc885c316 refactor: Cleanup 2017-01-11 03:07:28 +01:00
Michael Carlberg
79856d7ed2 feat(ipc): Add polybar-msg to facilitate ipc messaging 2017-01-10 02:09:33 +01:00
Michael Carlberg
704efe05d2 fix(file_util): Explicit initialization of stream base
Clang 3.8 emits a compiler warning due to the deleted
default constructors of the base class.
2017-01-09 20:48:53 +01:00
Michael Carlberg
d9c035381e refactor(i3): Restack above global root window
Refs #293
2017-01-01 19:34:48 +01:00
Michael Carlberg
796cdb52cc refactor: Rename restack function 2017-01-01 15:45:18 +01:00
Michael Carlberg
ccddf052ec refactor(script): Split non-/tail logic
Split the script module into one tailing output module and
one exec once module.

Refs #281
2017-01-01 09:05:18 +01:00
Michael Carlberg
dd960cc5b5 refactor(fd_streambuf): Cleanup 2016-12-31 15:42:46 +01:00
Michael Carlberg
acb9ed910d fix(script): Unlock mutex before terminating command
Refs #281
2016-12-31 14:08:45 +01:00
Michael Carlberg
210695d377 refactor(x11): Merge xlib/xutils with connection 2016-12-31 10:02:32 +01:00
Michael Carlberg
e3a51b235a refactor(clang-tidy): Apply fixes 2016-12-31 04:32:11 +01:00
Michael Carlberg
ad0af86a7b refactor(battery): Abstract value readers
Refs #263, #245
2016-12-31 04:20:48 +01:00
Michael Carlberg
18cf9df86c refactor: Cleanup 2016-12-27 04:58:41 +01:00
Michael Carlberg
b7f16672ff feat: Add object cache container 2016-12-26 10:38:19 +01:00
Michael Carlberg
b9f9092bbe refactor: Cleanup 2016-12-26 10:37:14 +01:00
Michael Carlberg
334c454eec concurrency_util: Mutex wrapper 2016-12-26 10:33:23 +01:00
Michael Carlberg
f80d8ebf5b file_util: File descriptor streams 2016-12-26 10:29:32 +01:00
Michael Carlberg
3681247dc1 refactor(file_util): Move block mode helpers 2016-12-25 19:58:52 +01:00
Michael Carlberg
debb3534c7 concurrency_ytil: Thread id 2016-12-23 05:18:58 +01:00
Michael Carlberg
fa0d77f267 refactor(file_descriptor): Use unique_ptr 2016-12-23 01:07:00 +01:00
Michael Carlberg
bc9b9f0d12 refactor: Cleanup 2016-12-21 23:22:02 +01:00
Michael Carlberg
185363056a refactor(x11): Cleanup 2016-12-21 15:04:16 +01:00
Michael Carlberg
c01f111e34 refactor(modules): Move setup to constructor 2016-12-21 08:00:09 +01:00
Michael Carlberg
a89c4ef2dd refactor: Move all event handling to the controller 2016-12-20 05:16:04 +01:00
Michael Carlberg
b417c9f812 feat(github): New module
Module used to query the GitHub API for information.
Currently only supports notification count.

Ref #84
2016-12-19 22:12:31 +01:00
Michael Carlberg
a0d485f79d refactor: Initialize data 2016-12-15 09:30:31 +01:00
Michael Carlberg
f9062d031c refactor(clang-tidy): Apply fixes 2016-12-15 03:30:41 +01:00
Michael Carlberg
105e4437ff fix(memory_util): Initialize malloc ptr 2016-12-14 15:06:46 +01:00
Michael Carlberg
b156d1bbf4 refactor(bspwm): Cleanup 2016-12-14 11:01:44 +01:00
Michael Carlberg
7822f912aa feat(socket): Utility function peek() 2016-12-14 11:01:44 +01:00
Michael Carlberg
5077325044 refactor(string_util): Use rvalue references for *trim() 2016-12-14 11:01:44 +01:00
Michael Carlberg
5e2a0bd298 refactor(alsa): Forward alsa structs and split classes 2016-12-14 11:01:44 +01:00
Michael Carlberg
1a2a6e5fab refactor: Construction methods 2016-12-14 11:01:44 +01:00
Michael Carlberg
08be86fbe1 wip(refactor): Improve signal and event handling 2016-12-14 11:01:44 +01:00
Michael Carlberg
0ed173b96e refactor(i3): Output based wrapping 2016-12-14 04:45:31 +01:00
Michael Carlberg
f4529dde99 feat(i3): Conditional wrap around on scroll
Ref #242
2016-12-14 00:46:54 +01:00
Michael Carlberg
44da14755d refactor(clang-tidy): Apply fixes 2016-12-04 04:11:47 +01:00
Michael Carlberg
0cfddf7d72 feat(token): Add optional suffix to label tokens 2016-12-04 04:03:17 +01:00
Michael Carlberg
5f6d73a415 fix(command): Use execlp()
Ref #214
2016-12-03 20:52:43 +01:00
Michael Carlberg
ef9b37447b fix(xcb): Deallocate using deleter 2016-12-03 16:44:08 +01:00
Michael Carlberg
086e498388 fix: Replace process on reload 2016-12-03 15:46:48 +01:00
Michael Carlberg
0f91d3d8df fix(ewmh): Use deleter to deallocate atoms 2016-12-03 15:45:11 +01:00
Michael Carlberg
c6540a8950 refactor: Signaling 2016-12-01 08:56:16 +01:00
Michael Carlberg
6f6c5b7459 fix(string_util): Join vector of strings 2016-11-27 01:32:21 +01:00
Michael Carlberg
c5bc338ae3 feat(math_util): Templated min/max 2016-11-26 13:09:29 +01:00
Michael Carlberg
9f4638f42c refactor: Cleanup 2016-11-26 06:13:20 +01:00
Michael Carlberg
ff9be848c7 refactor(clang-tidy): Apply fixes 2016-11-25 21:58:49 +01:00
Michael Carlberg
4268817c51 fix(config): Trigger reload on correct event
Fixes #85
2016-11-25 14:17:56 +01:00
Michael Carlberg
8db3e79919 refactor(clang-format): Apply fixes 2016-11-25 14:17:41 +01:00
Michael Carlberg
84d58e7619 refactor: Cleanup handling of syntax tags 2016-11-25 04:34:24 +01:00
Michael Carlberg
0c64b64ff8 refactor: Cleanup 2016-11-22 01:22:47 +01:00
Michael Carlberg
25e33b6aab refactor: Separate render component 2016-11-21 16:16:02 +01:00
NBonaparte
4179f8b7f9 feat: added max and min values to tokens 2016-11-20 16:37:48 -08:00
Michael Carlberg
d6a5212ef3 fix(volume): Handle alsa playback range
Ref #174
2016-11-20 23:49:08 +01:00
Michael Carlberg
c6d85b2b92 refactor: Optimize build 2016-11-20 23:04:31 +01:00
Michael Carlberg
40fcabd644 fix(config): Proper dereference of ${self.key} 2016-11-19 19:18:28 +01:00
Michael Carlberg
fd57ab0f3d fix: project rename 2016-11-19 06:26:07 +01:00
Michael Carlberg
51d8f289fa feat(xwindow): New module "xwindow"
Add module to display title of active window.
Requires WM with support for the _NET_ACTIVE_WINDOW hint.

Ref #84
2016-11-19 04:05:13 +01:00
Michael Carlberg
e3065d0e6c feat(ipc): New ipc module
Add a new module that allow users to configure hooks
on received ipc messages. The hook will execute the defined
shell script and the output of the script will be used
as the module content.

Ref #84
2016-11-14 09:26:40 +01:00
Michael Carlberg
9a0df75a91 feat(fs): New filesystem module
Module that displays details about
mounted filesystems, #84

Closes #153
2016-11-13 06:14:34 +01:00
Michael Carlberg
3edd33be99 fix(build): Include poll.h instead of sys/poll.h
- Include <poll.h> to get rid of musl warnings
2016-11-12 15:50:18 +01:00
Michael Carlberg
869c5fe718 refactor: Code cleanup 2016-11-04 19:21:56 +01:00
Michael Carlberg
d74dd7f3ef fix(build): Remove disabled libs 2016-11-03 19:01:45 +01:00
Michael Carlberg
e7cb345cec wip: Separate source from definitions 2016-11-03 12:54:32 +01:00
Michael Carlberg
26c308cc19 feat(color_util): Utility functions for color handling 2016-10-31 01:25:19 +01:00
Michael Carlberg
1075144b00 refactor(eventloop): Use concurrent queue for events
Events are now enqueued using a thread safe concurrent queue
which makes the previous eventloop locking redundant.
2016-10-29 06:48:51 +02:00