Commit Graph

1802 Commits

Author SHA1 Message Date
patrick96
d3d868a08c aur: Update PKGBUILD for 3.4.2 2019-12-28 10:22:34 +01:00
patrick96
5eb293cb71 doc: Add gitter room to issue template chooser 2019-12-27 17:21:14 +01:00
Jeremy Ong
34e742e000 Add missing <stdexcept> header
This is dependent on a PR to xpp that does the same. Newer compilers
(GCC10 in particular) are stricter about which headers provide the
std exception types.
2019-12-25 01:00:29 +01:00
Patrick Ziegler
fdf4d0c1a5 Revert "fix(aur): Add xorgproto package as make dependency"
This reverts commit a902b5a449.
2019-12-25 00:53:21 +01:00
patrick96
1fe679d6b3 fix(ipc): Clear content if no output is produced
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
2019-12-23 01:23:40 +01:00
patrick96
a902b5a449 fix(aur): Add xorgproto package as make dependency
xorgproto always was a make dependency (I think) but it was
automatically included indirectly by another dependency.
Arch recently cleaned up some xorg related packages which made xorgproto
no longer an indirect dependency of polybar which spams cmake with
messages like:

```
Package 'xproto', required by 'xau', not found
Package 'xproto', required by 'xdmcp', not found
Package 'xproto', required by 'xau', not found
Package 'xproto', required by 'xdmcp', not found
Package 'xproto', required by 'xau', not found
Package 'xproto', required by 'xdmcp', not found
Package 'xproto', required by 'xau', not found
Package 'xproto', required by 'xdmcp', not found
```

And during `make` finally completely fails the build because some
library's include directories are not honored because the xproto.pc file
cannot be found:

```
In file included from /home/patrick96/Projects/github.com/patrick96/polybar/include/cairo/utils.hpp:3,
                 from /home/patrick96/Projects/github.com/patrick96/polybar/src/cairo/utils.cpp:3:
/usr/include/cairo/cairo-ft.h:46:10: fatal error: ft2build.h: No such file or directory
   46 | #include <ft2build.h>
      |          ^~~~~~~~~~~~
```

Ref: https://bugs.archlinux.org/task/64892
2019-12-22 17:12:49 +01:00
patrick96
63cb05d35d fix(renderer): make center position more robust
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
2019-12-21 15:43:31 +01:00
patrick96
00274c57a9 fix(renderer): Falloff gradient
Before it did not take into account borders or a tray on the left.
It also sometimes rendered the gradient way to large
2019-12-21 15:43:31 +01:00
patrick96
ec2bad004a fix(renderer): Correctly position right block if center is empty
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 #591
Fixes #1903
2019-12-21 15:43:31 +01:00
patrick96
4bc7a09c7e refactor(builder): Remove unused condition parameter
Same as in #1952, the methods are never called with the optional
parameter, except once where it is called with the default value.

Ref: #1952
2019-12-18 21:22:47 +01:00
Tudor Brindus
bc560952e0 cpu: Consider steal time for load calculation (#1955)
* Add steal time to cpu_time struct

* Consider steal time as part of load calculations

* Typo fix
2019-12-16 17:05:18 +01:00
Tudor Brindus
ad3960e050 fix(build): GCC 6.3 discarded qualifiers (#1953)
This fixes the below error:

     /code/polybar/src/components/controller.cpp:110:117:   required from here
     /code/polybar/src/components/controller.cpp💯60: error: passing ‘const volatile std::shared_ptr<polybar::modules::module_interface>’ as ‘this’ argument discards qualifiers [-fpermissive]
          auto equal_predicate = [](auto& m1, auto& m2) { return m1->name() == m2->name(); };
2019-12-13 00:04:27 +01:00
patrick96
37628f8691 refactor(builder): Remove unused add_space parameter
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.
2019-12-12 22:08:34 +01:00
infokiller
fb6e874235 feat(label): Add minlen with alignment (#1546)
* 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>
2019-12-01 01:28:41 +01:00
Justin Dubs
70bf0339b8 feat(pulse): Add click-(middle|right) keys (#1941) 2019-11-28 17:36:14 +01:00
patrick96
7f09784548 doc: Add Gitter room
The Gitter room https://gitter.im/polybar/polybar should serve a similar
purpose as the IRC room with the benefit that messages persist and can
be received when offline.

From now on gitter should be the place where the polybar community
lives. Reddit is great for asking longer questions in the style of a
forum but not so great for quick back and forth conversations. IRC is
better in that aspect but has the serious downside that you have to stay
connected to get an answer and messages are not logged (only by your
client).

Both reddit and IRC are here to stay and I will still check them
regularly, but we should encourage people to join gitter.
2019-11-28 11:12:22 +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
8d3dedc2bd github: Add subreddit as contact link
This is yet another way to steer people towards reddit for questions
instead of using the github issue tracker

Ref: https://help.github.com/en/github/building-a-strong-community/configuring-issue-templates-for-your-repository#configuring-the-template-chooser
2019-11-03 12:55:32 +01:00
patrick96
7ee6093a6e aur: Update maintainer 2019-11-01 14:06:02 +01:00
patrick96
54381fd554 Update PKGBUILD for 3.4.1 2019-11-01 14:06:02 +01:00
patrick96
51184c7ead ipc: Remove unused global setting
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).
2019-11-01 11:12:40 +01:00
patrick96
3ea7600412 build: Move all possible variables into settings.cpp
Anything that doesn't have to be used as a macro
2019-11-01 11:12:40 +01:00
patrick96
100632cce3 fix(http): Pass char* as CURLOPT_USERAGENT 2019-11-01 11:12:40 +01:00
patrick96
6f882ba3b2 build: Move non-macro variables into settings.cpp
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
2019-11-01 11:12:40 +01:00
Michael Vetter
c6194c06eb Update spec file
Adjust version number.
Add new dependencies.
Explicitly ask for Python 3.
2019-10-31 16:07:00 +01:00
patrick96
6849b8a56b clang-format 2019-10-27 16:02:33 +01:00
patrick96
587dc6c84d bar: Make module separator a label
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
2019-10-27 16:02:33 +01:00
patrick96
a77923ea96 build: drop python2
Ref: https://github.com/polybar/xpp/pull/17
Fixes #1892
2019-10-26 22:29:04 +02: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
patrick96
bffec3d8f2 travis: update to bionic
Now we don't have to build xcb-xrm ourselves since it's available in the
repos
2019-10-26 22:28:47 +02:00
patrick96
2b31a3f112 fix(backlight): Use 'brightness' with amdgpu_bl0
The amdgpu driver seems to set 'actual_brightness' wrong.

Fixes #1870
Ref: https://github.com/Alexays/Waybar/issues/335
2019-10-21 14:37:29 +02:00
patrick96
fea579ec85 fix(bar): Configure window before remapping
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
2019-10-21 13:22:51 +02:00
Patrick Ziegler
a119c3386b
controller: Print error for duplicate modules (#1534)
* 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.
2019-10-21 10:20:45 +02:00
Matthias Viehweger
52f0623315 feat(xworkspaces): Support occupied workspaces (#882)
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 #874
Fixes #1444
Fixes #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
2019-10-21 10:00:38 +02:00
Jake Howard
4ab251f33c temperature: Use format-warn at warn-temperature not after (#1897) 2019-10-16 18:45:49 +02:00
julio-b
751c21cd37 feat(pulse): Show volume in decibels (#1894)
Adds `%decibels%` token to the pulseaudio module
2019-10-09 02:13:57 +02:00
patrick96
1fc6942482 fix(ipc): Update bar when making bar visible
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
2019-10-03 22:49:19 +02:00
Matthias Viehweger
b162e17583 Add Code Triage-Badge
I added the repo to code triage to get regular mails about open issues of polybar.
2019-09-28 13:51:30 +02:00
Hayden Sartoris
3e83fb9fb2 net: Don't disable when linkspeed not detected (#1772)
Shows "N/A" instead.

Fixes #1211
2019-09-27 17:01:45 +02:00
patrick96
99e823bd0a fix(file): Don't add slash to relative path
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
2019-09-27 16:58:03 +02:00
patrick96
5a309f0e33 fix(aur): Add sphinx as a build dependency 2019-09-18 16:22:23 +02:00
patrick96
4ea188b3f9 fix(modules): Only add reset tag on non-empty modules
Adding the reset tag to empty modules makes polybar add margins and
separators for that empty module.

Fixes #1857

Ref #1596
2019-08-22 22:42:30 +02:00
patrick96
211b0bbfd8 Incorporate Reviews 2019-08-06 21:36:20 +02:00
patrick96
57d364a2fc Reset all tags at the end of a module
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)
2019-08-06 21:36:20 +02:00
patrick96
928cd92a4f refactor(builder): Don't track raw tags
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
2019-08-06 21:36:20 +02:00
patrick96
ddb40db490 builder: Cleanup label over-/underline handling
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.
2019-08-06 21:36:20 +02:00
patrick96
3ebb0b0b03 builder: Simplify open tag tracking
Using a bit vector to track the active attributes does not really give a
significant speed increase, especially for only two attributes

Checking if a syntaxtag or an attribute exists in the map just adds
unnecessary code
2019-08-06 21:36:20 +02:00
patrick96
f967cd5f59 builder: remove BUILDER_SPACE_TOKEN
Was around since the first commit but no documentation why. It was only
used in the text module and doesn't appear in any public documentation,
so this doesn't break anything.
2019-08-06 21:36:20 +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
58d72c4f19 feat(github): add support for github enterprise (#1841) 2019-08-04 20:58:25 +02:00