Commit Graph

1221 Commits

Author SHA1 Message Date
tchici
c676d7e6f5
add reverse-scroll option for xworkspaces module (#2365)
* 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
2021-01-28 10:11:33 +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
4154943f69 fix(xworkspaces): Handle -1 value for _NET_WM_DESKTOP
Fixes #2352
2021-01-15 20:34:15 +01:00
patrick96
74dcb4649d
Merge branch 'hotfix/3.5.4' 2021-01-07 13:52:28 +01:00
Patrick Ziegler
26be83f893
module: Implement action router (#2336)
* 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
2021-01-04 10:25:52 +01:00
Bruno Cooper
7521da900f
Add support for %nwin% in xworkspaces label (#2329)
%nwin% tells the number of windows in a workspace
2021-01-04 10:17:27 +01:00
devsnek
f7c2d83ef2
feat(net): interface discovery (#2025) 2021-01-03 11:48:15 +01:00
Patrick Ziegler
412f4c723f
feat(xworkspaces): Persistent urgent hint (#2340)
* add urgent hint

* feat(xworkspaces): Fully implement urgency hint

Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
2020-12-31 15:49:39 +01:00
Nolan Prochnau
8e46e54cb3
feat: Module Visibility (#2320)
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>
2020-12-27 16:05:26 +01:00
patrick96
e30d2c4c1f Remove tag compaction "optimizations"
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
2020-12-25 00:33:32 +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
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
patrick96
1dc8d2f30e cmake: Make xrandr and xcomposite required
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
2020-12-22 00:37:07 +01:00
patrick96
374716d329 cmake: Remove unused variables 2020-12-22 00:37:07 +01:00
patrick96
4f2a145f4f cmake: Update list of source files 2020-12-22 00:37:07 +01:00
Jérôme BOULMIER
b143e43491 enhancement(cmake): remove all mentions of "dirs" variable 2020-12-22 00:37:07 +01:00
Jérôme BOULMIER
cb728ac7c4 fix(cmake): restoring output directory 2020-12-22 00:37:07 +01:00
Jérôme BOULMIER
31fafa86f7 feat(cmake): removing globs and using imported targets 2020-12-22 00:37:07 +01:00
Nolan Prochnau
0d2838fcd5
feat(xkeyboard): Add variant support to layout label (#2163)
* 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
2020-12-19 18:22:27 +01:00
Patrick Ziegler
33e691301d
fix(config): Don't treat an empty value as invalid (#2315)
An empty color value in the config should be treated as if no color was
specified (explicitly). This is the same behavior as before.
2020-12-18 23:33:03 +01:00
Filip Banák
6f13fe93a3
xkeyboard: Fix indicator spacing (#2306)
* 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>
2020-12-17 20:49:10 +01:00
Patrick Ziegler
fd556525a8
New Tag Parser (#2303)
* 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
2020-12-17 20:37:28 +01:00
Bjoern Hiller
7c662ec44f feat(conf) Properties for {bottom,top}-{left,right} radius 2020-12-13 17:02:23 +01:00
patrick96
1c554dd0e0
Merge branch 'hotfix/3.5.1' 2020-12-12 13:28:57 +01:00
quandangv
ae1c6ca1b7 Fix 2283: Replace tokens at build() instread of update() 2020-12-12 12:33:21 +01:00
patrick96
47483a94f1 fix(process): fork_detached created zombie processes
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
2020-12-12 02:37:21 +01:00
patrick96
54e2490aa5 fix(logger): Wrong conversion function called
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.
2020-12-12 01:43:12 +01:00
patrick96
a45b5d0424 fix(build): UB when converting strings in logger
The memory returned was no longer valid because arg is destructed after
the function returns.
2020-12-12 01:43:12 +01:00
patrick96
df485f0a60 fix(module_formatter): Remove double moves 2020-12-07 15:35:38 +01:00
patrick96
bc87eb3b69 fix(battery): Crash when format-low not defined
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
2020-12-07 15:35:38 +01:00
Patrick Ziegler
037f6e6c45
fix(xworkspaces): Never swallow updates (#2275)
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
2020-12-05 23:28:48 +01:00
Patrick Ziegler
82ebad5e7a
fix(timer_module): Ensure that interval > 0 (#2274)
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
2020-12-05 22:58:38 +01:00
Patrick Ziegler
b2c515c73c
fix(config): Reintroduce multiple inheritance (#2271)
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
2020-12-05 02:48:18 +01:00
Patrick Ziegler
c198859cd5
fix(menu): Wrong printf token in error message (#2264)
'level' is a string, not an integer
2020-12-03 15:12:59 +01:00
patrick96
11d1c2c5c7
Merge branch 'release/3.5.0' 2020-12-02 18:12:53 +01:00
Quan
39c73a8234
feat: Warn state for cpu, memory, fs, battery modules (#2199)
* [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
2020-12-02 15:55:13 +01:00
Jan Palus
9f2459be8c
net: increase speedrate precision (#2054)
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>
2020-12-01 17:54:54 +01:00
Vlad Glagolev
5f67a8a12b
Respect interval default for tail = true (#2240) 2020-12-01 16:35:48 +01:00
patrick96
e89da58940
fix(builder): Properly apply alpha for fg and bg
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
2020-12-01 14:53:41 +01:00
Thibaut CHARLES
50d8a1ba06
feat(network): Ability to change speed unit text (B/s) (#2068)
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
2020-11-29 14:15:27 +01:00
patrick96
52eee95bf8 controller: Detach shell commands from polybar
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
2020-11-29 03:53:59 +01:00
Michał Drozd
0416093edc
Display correct(binary) unit prefixes in memory module (#2211) 2020-11-27 23:30:09 +01:00
patrick96
5007dae35a If bar bg, fg, border, or line color is alpha only, apply to default 2020-11-27 22:08:03 +01:00
patrick96
53c6f3b042 refactor(color): Better channel function names
(alpha|red|green|blue)_(d|i) are used for the four channels using
doubles or integers, respectively.
2020-11-27 22:08:03 +01:00
patrick96
477189e443 Cleanup 2020-11-27 22:08:03 +01:00
patrick96
4dfbba11c4 Make rgba class immutable 2020-11-27 22:08:03 +01:00
patrick96
413c911cd1 Move apply_alpha functionality into rgba 2020-11-27 22:08:03 +01:00
patrick96
eeab4f0d45 Print error message for invalid color strings 2020-11-27 22:08:03 +01:00
patrick96
c9efd09f71 Load rgba from config instead of strings. 2020-11-27 22:08:03 +01:00
patrick96
8e10c046fa Move all channel functions into rgba class
Since we use rgba everywhere, extracting channels from uint32_t directly
is not necessary anymore.
2020-11-27 22:08:03 +01:00
patrick96
3655106a14 Adapt the renderer side to always use rgba 2020-11-27 22:08:03 +01:00
patrick96
64fa6469ab Remove unused hex function
This allows us to also remove the cache class which was only used here
2020-11-27 22:08:03 +01:00
patrick96
b238ec3403 Move most color_util functions into rgba class
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.
2020-11-27 22:08:03 +01:00
patrick96
75eb41f5ad config: Better error messages when opening files
If a config file is a directory, ifstream would just read it as an empty
file without any errors.

Failing early here is a good idea.
2020-11-26 21:06:35 +01:00
patrick96
ff3340e062 controller: Cleanup process_inputdata 2020-11-26 20:53:53 +01:00
patrick96
1afb333858 doc(actions): Point user to doc when using legacy actions 2020-11-26 20:53:53 +01:00
patrick96
191fb2972c actions: Integrate input_handler into module
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.
2020-11-26 20:53:53 +01:00
patrick96
658ed6974d Do not use reverse-scroll for prev/next actions
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.
2020-11-26 20:53:53 +01:00
patrick96
1193b78e43 controller: Use unordered_map for legacy actions 2020-11-26 20:53:53 +01:00
patrick96
41ffc3607d controller: Make action shell command local 2020-11-26 20:53:53 +01:00
patrick96
9fb75779f3 Incorporate reviews 2020-11-26 20:53:53 +01:00
patrick96
5ddb6fc0c5 Move legacy action handling to separate function 2020-11-26 20:53:53 +01:00
patrick96
c60b488501 clang-format 2020-11-26 20:53:53 +01:00
patrick96
507004df87 actions: Move parsing to utility file 2020-11-26 20:53:53 +01:00
patrick96
0db8376222 menu: Emit exec actions
Now the menu closes properly again if any actions on it are clicked
2020-11-26 20:53:53 +01:00
patrick96
ef8f7c9d94 feat(menu): Add exec action to menu module
Can be used to execute menu actions through ipc and will also be used to
make sure the menu closes when an action on it is clicked.
2020-11-26 20:53:53 +01:00
patrick96
af5af1e497 Fix unused argument warning 2020-11-26 20:53:53 +01:00
patrick96
a30ac5f4a3 fix(actions): Separate data from action properly 2020-11-26 20:53:53 +01:00
patrick96
6618320947 actions: Use #name.action[.data] format
This looks a bit nicer than #name#action[.data]
2020-11-26 20:53:53 +01:00
patrick96
bc1b86c584 actions: Separate data from action string
Modules now no longer need to manually parse the action string and
extract data from it.
2020-11-26 20:53:53 +01:00
patrick96
8acedeef87 modules: Fix resolving of type of disabled modules 2020-11-26 20:53:53 +01:00
patrick96
002112df64 actions: Forward data of legacy actions
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.
2020-11-26 20:53:53 +01:00
patrick96
a2b312cc84 actions: Add mapping for all legacy action names 2020-11-26 20:53:53 +01:00
patrick96
ae2350167b actions: Switch all modules over to new system
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)
2020-11-26 20:53:53 +01:00
patrick96
816b73a95f actions: Add utility functions to produce action tags 2020-11-26 20:53:53 +01:00
patrick96
b2ba21c75d actions: Forward legacy actions to the right module
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.
2020-11-26 20:53:53 +01:00
patrick96
d592eea966 refactor: Move module type string into modules
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
2020-11-26 20:53:53 +01:00
patrick96
06012af3aa controller: Deliver inputs to all input handlers
This is more natural, especially if the same module appears twice in the
module list
2020-11-26 20:53:53 +01:00
patrick96
a287fb5e8c fix: Use module name in action string
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
2020-11-26 20:53:53 +01:00
patrick96
e309253fc8 clang-format 2020-10-19 10:32:41 +02:00
patrick96
4944a5179c fix(net): Float interval for network speed
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.
2020-10-19 10:32:41 +02:00
Quan
3895ace12a
temp: Use first/last ramp only for edge temps (#2197)
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
2020-10-09 14:05:50 +02: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
Nolan Prochnau
2f4cffc0fb
fix(config_parser): Gracefully handle BOM (#2166)
* fix(config_parser): Gracefully handle BOM

* Move check to parse_line function

And clarify the error message

Closes #2075
2020-08-15 12:02:23 +02:00
Richard
be64da3bda
battery: Prioritize full-at over state (#2019)
* 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
2020-06-09 21:15:36 +02:00
nicey0
b8a1354117
backlight: Just match amdgpu_bl prefix (#2122)
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".
2020-06-05 21:48:17 +02:00
Patrick Ziegler
ba0a156bbe
refactor: Deprecate throttle-input-for setting (#2117)
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.
2020-05-30 22:45:36 +02:00
Justin R. St-Amant
5cd7295a41
fix(menu) wrong spacing for left expansion (#1656)
* Fixed minor menu item-spacing issue

* Changes to menu-item spacing as requested

* refactor: Remove redundant else-if condition

Co-authored-by: patrick96 <p.ziegler96@gmail.com>
2020-05-16 23:19:12 +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
5e5d8faf04 fix(command): broken pipe when ignoring output. 2020-05-08 23:24:29 +02:00
patrick96
0dffca98cb xworkspaces: Remove desktop offset member 2020-05-01 18:46:02 +02:00
patrick96
7658c1b9f1 fix(xworkspaces): Assign desktops to correct viewport
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 #1849
Fixes #1764
2020-05-01 18:46:02 +02:00
patrick96
b2613fa269 logger: Use notices for config file and fonts
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.
2020-04-22 00:38:31 +02:00
patrick96
3f60561ae3 logger: Downgrade some warning messages
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`
2020-04-22 00:38:31 +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
patrick96
ecbe77bbda fix(monitor): Reload when any monitor changes
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
2020-04-21 23:59:01 +02:00
patrick96
18fc64f881 monitor: Remove sort in get_monitors
The lambda returns the wrong values and sorting isn't really necessary
2020-04-21 23:59:01 +02:00
patrick96
fbbb5922da doc: Reword -m and -M description 2020-04-21 23:59:01 +02:00
patrick96
33b68ec7cb fix(randr): Undefined behavior when removing clones
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
2020-04-21 23:59:01 +02:00
patrick96
52000c194a fix(xrandr): Fetch cloned monitors where possible
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
2020-04-21 23:59:01 +02:00
patrick96
2edd8275ff Add -M CLI argument to display cloned monitors
Works the same as -m but doesn't purge cloned monitors
2020-04-21 23:59:01 +02:00
patrick96
cc36350849 xrandr: Allow not to purge cloned monitors 2020-04-21 23:59:01 +02:00
patrick96
b5e7078d93 fix(monitor): Remove realloc from get_monitors
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.
2020-04-21 23:59:01 +02:00
Jan Palus
61dfe739d5 net: allow shortening of linespeed to Gbit/s 2020-04-14 01:32:21 +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
patrick96
15e79b09d3 fix(iconset): Try exact match before fuzzy match
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
2020-03-19 20:52:41 +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
Patrick Ziegler
5a695c7065
doc: Update links to https (#2012) 2020-02-21 15:39:39 +01:00
Cooper Pierce
683cfc0738
feat(github): offline label (#1825)
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>
2020-02-21 13:58:23 +01:00
patrick96
3854fc91b5 fix(xworkspaces): Show _NET_NUMBER_OF_DESKTOPS desktops
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
2020-01-24 16:56:38 +01:00
Jérôme BOULMIER
51f9f35599 cleanup(logger): use universal references to avoid useless copies 2020-01-24 16:32:26 +01:00
Jérôme BOULMIER
982a22cd62 use steady clock instead of system clock 2020-01-23 23:45:56 +01:00
Jérôme BOULMIER
e6e010e45b fix(battery): animation framerate 2020-01-23 23:45:56 +01:00
Christoph Schiessl
d3844c40b6 refactor(battery): simplify animation subthread 2020-01-23 23:45:56 +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
patrick96
0dbcb28a2c fix(net): Query IP addresses for tun/ tap devices
Before tuntap devices would never call the generic `network::query`
method and just return true.

Fixes #1986
2020-01-12 15:03:18 +01:00
patrick96
e43ba9bd3a controller: Stop printing errors for non-unique modules
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.
2020-01-12 13:08:45 +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
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
Jérôme BOULMIER
e5783d4113 Include empty tokens when splitting if necessary (#1893)
Fixes #1881
2019-11-21 22:26:53 +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
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
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
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
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
Brice Waegeneire
0740382851 fix(msg): use stdout when exiting with code 0 2019-06-19 16:09:56 +02:00
Jérôme BOULMIER
c650513b67 fix(i3): Surround ws names with quotes (#1798)
Fixes #1797
2019-06-04 23:34:16 +02:00
patrick96
a3e2e51ac9 build: remove xdamage extension
Unused

Ref: #1730
2019-06-03 00:46:12 +02:00
patrick96
38af08d29a build: remove xsync extension
Unused

Ref: #1730
2019-06-03 00:46:12 +02:00
patrick96
6ff2b2b37f build: remove xrender extension
Some build recipes (exherbo, sourcemage) for some reason enable this
even though it doesn't do anything any only causes compilation issues.

Ref: #1730
2019-06-03 00:46:12 +02:00
Sebastian Graf
cb75857ff6 pulse: Set volume to max when the increase was too huge (#1765)
Previously, when volume was in close proximity to n_max_volume, a larger
increase would not do anything. After this patch, volume is set to
m_max_volume in such scenarios. If the volume already is at
n_max_volume, we mirror the old behavior and emit a warning.

So, for example, consider m_max_volume was 100%, but the volume prior
to the increase was 96%. An increase of 5% would do nothing (emit a
warning, even) instead of setting the volume to 100%.

Note that this might happen even if the volume is at 95% according to
%percentage% due to rounding errors.
2019-05-14 22:06:14 +02:00
Roberto Santalla
b2b73b5d91 feat(battery): add %percentage_raw% token (#1756)
Displays real percentage instead of being set to 100 if percentage > full-at

* battery: added percentage_raw token, which ignores full-at

* battery: current_percentage returns raw, added clamping function instead

* battery: clamp percentage used by build()
Made clamp_percentage() const to allow its usage inside build()

* battery: read and return percentage in one line
2019-05-14 15:01:54 +02:00
patrick96
0ab9fcdc38 refactor: Remove all mentions of icon_t
Is exactly the same label_t
2019-04-08 09:01:48 +02:00
Kazufumi NOTO
7414e98008 feat(temp): Configurable lower bound for ramp (#1706)
Similar to warn-temperature, temps below `base-temperature` will use the first ramp icon.

Closes #1703
2019-04-07 18:36:09 +02:00
Jérôme BOULMIER
fca4151f36 fix(window): remove useless operator= and add default copy cstr (#1729)
Fixes compilation under GCC 9

The default copy constructor implicit generation is deprecated by C++ standard.

The window& operator=(const xcb_window_t win); operator seems to be useless.

Fixes #1728
Ref jaagr/xpp#16
2019-04-07 17:32:55 +02:00
patrick96
fc2d2db76f refactor(cmake): Determine version in cmake
We need to have the version string available in multiple places not just
the source code. It is now hardcoded in the root CMakeLists.txt and all
files that need it will be configured with cmake.

This also removed the unecessary duality of GIT_TAG and APP_VERSION and
GIT_TAG_NAMESPACE and APP_VERSION_NAMESPACE.
2019-04-05 23:43:37 +02:00
DrunkenChicken
25f99c0a61 fix(xworkspaces): active ws upon ws deletion (#1713)
Active desktop was tracked via it's index, but when desktops are removed from `_NET_DESKTOP_NAMES` that index may become invalid.

Fixes #1710
2019-04-01 18:04:44 +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
Kazufumi NOTO
82b9ea8a09 fs: Fix incorrect size report on 32bit machines (#1699)
Cast before multiplication to avoid overflow.

Fixes #743
2019-03-18 18:16:42 +01:00
Jérôme BOULMIER
e3b84c9595 fix(controller): ignore SIGUSR1 until polybar is fully reloaded. (#1678)
To avoid polybar from being killed by SIGUSR1 during reloading, SIGUSR1 is ignored until the signal is registered in the new polybar process.

As stated in signal(7) man page, the ignored signals are still ignored after a call to a function of the execvX family.

    During an execve(2), the dispositions of handled signals are reset to the default;
    the dispositions of ignored signals are left unchanged.

Fixes #428
2019-03-13 07:55:02 +01:00
patrick96
b3f7cd08e9 fix(xkeyboard): Only update indicators when used
Was causing a segfault if `format = <label-layout>`
2019-03-06 20:29:12 -08:00
patrick96
de3240b861 fix(xkeyboard): Print deprecation message
`config::warn_deprecated` does not accept keys of the form `<...>` and
strips the surrounding brackets like `load_label` does
2019-03-06 20:29:12 -08:00
patrick96
fbd870c343 fix(xkeyboard): Use correct indicator label field
Fixes #1660
2019-03-06 20:29:12 -08:00
Gilad Naaman
db9a83a83b feat(xkeyboard): Customizable indicators and layouts (#1559)
* `layout-icon-*` list that maps layouts to icons.
* `indicator-icon-*` list that maps indicators to off and on icons
* `label-indicator-off`
* `label-indicator-on` which replaces the now deprecated `label-indicator`
* `label-indicator-[on|off]-*` for each indicator. Overrides `label-indicator-on` and `label-indicator-off` 

Fixes #1558 
Closes #1048

* add icon support for xkeyboard layouts

* removed unneeded #include

* add sperate %icon% token that can be used in <label-layout>

* removed unneeded #include

* added caps lock indicator (was mentioned in wiki, but not actually implememnted) and support for indicator icons

* a few more fixes to make sure existing user configs are not broken

* ready to go

* Added an option to replace xkb indicator names

* Added labels for each indicator state

* Removed print left on accident

* Fixed review comments

* Update src/modules/xkeyboard.cpp

Co-Authored-By: Gilnaa <gilad@naaman.io>
2019-02-24 22:35:39 +01:00
striker.sh
ca4426a962 fix(xworkspace): Fully support _NET_DESKTOP_NAMES spec (#1579)
Ref https://specifications.freedesktop.org/wm-spec/wm-spec-latest.html#idm140200472706208

Fixes #1491
Fixes #248
Closes #904
2019-02-08 13:32:31 +01:00
patrick96
b3ceedde76 refactor(bar): Remove bar_settings.center
Not used anywhere
2019-02-05 11:50:25 +01:00
Patrick Ziegler
a7ad68da31
fix(randr): Check if there is a primary monitor (#1621)
* fix(randr): Check if there is a primary monitor

primary_info.name() throws an error if get_output_info is called with
XCB_NONE

Fixes #1620
2019-01-24 21:17:35 +01:00
NBonaparte
1145681cf5
feat(monitor): use primary monitor as default (#1426)
If the monitor option isn't set, the primary monitor (if connected) is chosen as the default display.
2019-01-20 11:20:30 -08:00
patrick96
b03f14400a fix(net): buffer overflow when gathering ipv6 addr 2019-01-20 15:12:22 +01:00
Benno Fünfstück
f74c524fff fix(renderer): Handling of missing root pixmap (#1608)
Polybar had issues when there is no background set or set by a tool like imagemagick which doesn't add the root pixmap to the root window properties.

There's not much we can do about it, but at least polybar doesn't crash anymore.

Fixes #1582 
Fixes #1585 

* fix(tray_manager): only enable transparency if neccessary

Previously, we always enabled transparency

* fix(background_manager): avoid needless fetching

* fix(renderer): move logging message to correct place

* fix(background_manager): handle dummy pixmap (_XSETROOT_ID) right

* fix(background_manager): more initialization + don't free on error

Freeing on error is incorrect, since we could still be called again later in
which case we still need the resources.

* fix(background_manager): add more infos to trace logs

* fix(background): correct typo (XROOTMAP -> XROOTPMAP)

* fix(background_manager): do not report "no background" as error

* style(background_manager): use braces for if

Co-Authored-By: bennofs <benno.fuenfstueck@gmail.com>

* fix(background_manager): better error message for dummy pixmap

Co-Authored-By: bennofs <benno.fuenfstueck@gmail.com>

* style(background): some more style fixes

* fix(connection): initialize pixmap in all cases in root_pixmap()

* style(connection): improve readability using early return
2019-01-17 14:22:48 +01:00
patrick96
01be9b3504 feat(net): All tokens for all labels
If you have `accumulate-stats = true` it is useful to be able to display
the current network speed even if the interface is disconnected.
2019-01-17 08:35:49 +01:00
patrick96
014606294c fix(net): Display N/A when no ipv4 address 2019-01-17 08:35:49 +01:00
Patrick Ziegler
921658f331
memory: Remove decimal places for megabytes (#1606)
As requested in #1598

Two decimal places for megabytes gives you precision at the scale of tenths of kilobytes, which is quite unnecessary for RAM
2019-01-17 08:32:42 +01:00
patrick96
a0b888b5e6 fix(fs): Calculate free bytes properly
Seems this was missed in a682d2af91

This is now also consistent with what df does

Closes #743
2019-01-17 08:31:48 +01:00
patrick96
67f1ceaaca feat: format-font
Resolves #19
2019-01-17 08:31:14 +01:00
Ddone
46b8bb84ed feat(border): Percentage and pixel offset (#1592)
Uses the same X%:Z format as width, height and offset-*

Resolves #1567
2019-01-12 11:48:09 +01:00
Ddone
b728fea5be fix(i3): crash without <label-state> (#1591)
Fixes #975
2019-01-09 18:38:44 +01:00
patrick96
4a506d429d xbacklight: Use monitor-strict from bar settings
monitor-strict in the xbacklight module was never documented anywhere so
it's fine to remove it.
2019-01-08 17:23:28 +01:00
patrick96
e793082008 randr: Add separate key for exact monitor matching
This adds `monitor-exact = true` in the bar section

This also properly does best-match instead of first-match if multiple
matches exists. For example if there are two monitors HDMI2 and HDMI-2
and we try to match HDMI-2 with monitor-exact = false, until now HDMI2
would be matched. Now exact matches are always preferred.

Fixes #1532
2019-01-08 17:23:28 +01:00
patrick96
fe0b072dd0 feat(bspwm): Support marked flag for focused nodes
This adds a new label in the bspwm module `label-marked`

This flag for focused nodes of a focused desktop was introduced in [1]
and released with bspwm 0.9.4

It adds the `M` flag to `G` type items in bspwm's report format

Resolves #1552

[1]: d0138af475
2019-01-08 17:14:39 +01:00
Benno Fünfstück
7256366112 fix(tray): correctly handle transparency when using offset (#1571)
This patch adds support for observing multiple slices of the desktop background.
This is used for the tray so that it doesn't have to rely on the bar's rect to
get the desktop background. In particular, it now handles the case where the
tray is not contained fully within the bar's outer rect (for example, when using tray-offset-{x,y})

Co-Authored-By: bennofs <benno.fuenfstueck@gmail.com>
2019-01-05 01:08:18 +01:00
Matthias Viehweger
dec801a114 fix(xworkspaces): FPE when no _NET_DESKTOP_NAMES (#1576)
Fixes #1462
2019-01-03 18:59:55 +01:00
Sergey
cc8947ac01 feat(cpu): Add percentage-sum token (#1517)
Adds `%percentage-sum%` token to cpu label that contains the cumulative load of all cores.
2018-12-03 01:48:18 +01:00
NBonaparte
35c0c4a343 fix(xcb): check for composite extension (#1430)
* fix(xcb): check for composite extension

* fix(travis): add xcb-composite to deps

* fix(xcb): always include composite when building
2018-12-02 16:39:14 +01:00
sunil
22af69545a feat(net): Support bridge interfaces (#1528)
Bridge interfaces don't provide linkspeed via ethtool but everything else works the same as with ethernet links.

Fixes #1522
2018-11-28 16:09:00 +01:00
sam-lunt
d3e37918e5 CMake refactor (#1510)
* Clean up CMake logic

- removed logic to find CppUnit (no longer used)
- removed "dirs" variable used to pass include directories
- removed add_library function (no longer used)
- removed make_executable function
    * only used in 2 places (polybar and polybar-msg)
    * it was more general than needed, logic is simpler without it
- split polybar into static library and executable
    * this allows linking unit tests to the library

* rename library

* add coverage build

- Added a CMake build type "Coverage" that builds C and C++
  code with the "--coverage" flag (recognized by both GCC and Clang)
- removed "-Wno-missing-field-initializers" from test flags,
  since it didn't seem to be needed any more
- removed logic from tests/CMakeLists to disable "-Werror" and "-pedantic-errors"
  since there didn't seem to be any warnings during the build

* fix whitespace

* update travis

* remove O2 from defalt flags

* allow tests to be built by default make target

* disable Werror for debug builds
2018-11-21 18:46:33 +01:00
patrick96
f8e4a5932a refactor: Unescape action cmd before emitting 2018-11-16 18:12:26 -08:00
patrick96
38f551f884 test(parser): Add tests for parse_action_cmd 2018-11-16 18:12:26 -08:00
patrick96
18e2609f11 fix(builder): Escape all colons in action command
Fixes #984
2018-11-16 18:12:26 -08:00
Denis Kasak
fa693aecf8 feat(script): Add double-click to script module (#1442) 2018-11-16 16:06:04 +01:00
patrick96
6ca4f06785 doc: Convert @ to \ doxygen commands
Ref #1377
2018-11-04 19:28:27 -08:00
patrick96
3c504bb913 fix(build): remove side-effects of iwlib.h
wireless_tools 29 redefines inline in iwlib.h as:
    #define inline inline __attribute__((always_inline))

which conflicts with POLYBAR_NS, which is defined as:

    #define POLYBAR_NS    \
      namespace polybar { \
        inline namespace APP_VERSION_NAMESPACE {

In version 30.pre9 this #define is moved into a source file and thus
cannot conflict.

The error only occurs when building with clang, so it seems gcc and
clang handle this differently

Fixes #1492
2018-10-31 17:00:13 -07:00
patrick96
3b32f5899a fix: Move return value of parse_layout_symbol
Fixes #1469
2018-10-16 11:05:14 -07:00
Patrick Ziegler
b80023fd41
feat(cpu): Add ramp-coreload-spacing (#1472)
Resolves #1389
2018-10-16 01:11:05 +02:00
Patrick Ziegler
6d0cfbdfde Revert "feat(cpu): Add ramp-coreload-spacing (#1472)"
This reverts commit 06adef1055.
2018-10-16 01:01:11 +02:00
Ryan Geary
06adef1055 feat(cpu): Add ramp-coreload-spacing (#1472)
Resolves #1389
2018-10-16 00:59:45 +02:00
patrick96
abdd5f9233 fix(script): Avoid duplicate action tags for tailed
If a tailed command is used polybar would generate two action tags, one
with %counter% replaced and one with %pid% replaced, but never both

This is a bug that was introduced in #934
2018-10-08 21:38:25 -07:00
patrick96
13b0ee7454 tray: Properly deprecate tray-transparent 2018-10-04 15:52:03 +02:00
Benno Fünfstück
70807a5a9f fix(renderer): remove debug code, add comment 2018-10-04 15:52:03 +02:00
Benno Fünfstück
6237e2d419 fix(renderer): fix pseudo-transparency wrong compositing
The idea is that pseudo-transparency should behave like real transparency as
much as possible. To achieve this, we now render the bar the same way in both
cases. The only part where pseudo-transparency differs is at the very end, where
the rendered bar is captured and composited against the desktop background
image. This should ensure that both modes behave the same.
2018-10-04 15:52:03 +02:00
Benno Fünfstück
9a92772617 fix(renderer): default m_comp_bg to OVER if pseudo-transparent 2018-10-04 15:52:03 +02:00
Benno Fünfstück
2d385150bd fix(background_manager): more cleanup in deactivate
This has no effects on bar behaviour, as `deactivate` is currently not used anywhere.
2018-10-04 15:52:03 +02:00
Benno Fünfstück
4221da71bf fix(renderer): render transparent blocks correctly
This reverts some behaviour differences introduced by the pseudo-transparency
implementation. The new implementation is much closer to the
non-pseudo-transparent case and thus keeps original behaviour.

For the new method we simply fill the bar with the background image fetched from
the root window if in pseudo-transparent mode, otherwise we do nothing. This
means that everything will work as in the fully-transparent mode.
2018-10-04 15:52:03 +02:00
Benno Fünfstück
35aca5b368 fix(tray): correctly compute background for tray if bar pos != (0,0)
We need to use positions relative to the position of the bar for indexing into
the background image slice, but the code used absolute ones.

This worked fine as long as absolute positions are the same as relative
positions (this is the case for a bar located at (0,0), so if bottom = false).
But for bottom bars (where the bar position is not (0,0)) this was wrong which
caused the tray background to be black (out of bounds for the background slice).
2018-10-04 15:52:03 +02:00
Benno Fünfstück
eacf5ce5ba fix(tray): fix transparency after background manager changes
The systray only supports pseudo transparency (real transparency would require
much larger changes) so the real transparency should only be used for the bar itself.
2018-10-04 15:52:03 +02:00
Benno Fünfstück
061fe83b2f feat(background_manager): option to disable pseudo-transparency
This adds a new config option to select between pseudo transparency and real transparency.
2018-10-04 15:52:03 +02:00
Benno Fünfstück
59c0ccef50 fix(tray): remove tray-transparent option
This option is no longer necessary because the tray background color can now
simply be set to any (semi-)transparent color (just like the bar background).
2018-10-04 15:52:03 +02:00
Benno Fünfstück
66cf9b8b99 docs(renderer): fix stale comment 2018-10-04 15:52:03 +02:00
Benno Fünfstück
51d58e7518 fix(render): support stacked bars
We now take the bar position that the window manager gives us instead of trying
to calculate it ourselves. This is more correct when multiple bars are attached
to the same edge, as the window manager may move some of them in that
case (assuming override redirect is not enabled)
2018-10-04 15:52:03 +02:00
Benno Fünfstück
eb742e228b fix(render): correctly handle semi-transparency for borders
We need to fetch the outer area from the root window, not just the inner area
because we paint the background below the borders as well.

This has the nice effect of supporting semi-transparency for borders as well.
2018-10-04 15:52:03 +02:00
Benno Fünfstück
3de914abca feat(render): support pseudo-transparency
This adds pseudo-transparency for the background of the bar and the
background of the systray.
2018-10-04 15:52:03 +02:00
james9837
654c667698 fix(build): replace caddr_t with char* (#1454)
caddr_t isn't defined on all systems

Fixes #1447
2018-10-03 16:35:31 +02:00
Vasili Karaev
2fba443f56 fix(cpu): Replace %percentage-cores% normally (#1282) 2018-09-19 19:58:09 -07:00
Roel Postelmans
11d66ee78d feat(mem): Add ramp and bar for swap (#1325)
Now all the tokens in the memory module also have ramp and bar counterparts.

These can be used exactly the same as `bar-used` and `ramp-used`, they are named `<bar-swap-used>`, `<bar-swap-free>`, `<ramp-swap-used>`, and `<ramp-swap-free>`
2018-09-14 20:42:04 +02:00
Vasili Karaev
a2ab4699ab refactor(temperature): Do not use 'm_' prefix with local variable 2018-09-04 14:07:22 -07:00
Vasili Karaev
68ae7a869a fix(mpd): Get format-online-{prefix,suffix} explicitly (#1399) 2018-09-01 00:46:06 -07:00
Patrick Ziegler
676d9d7e1a
fix(tray): Reconfigure tray on error (#1392)
This will fix the issue of the tray container not being
properly reconfigured when a tray client fails to be added
or removed.
2018-08-21 21:06:58 +02:00
BO41
238f8fb592 refactor: Simplify if statements (#1381) 2018-08-14 23:31:44 +02:00
patrick96
2a3b2b2b99 refactor(logger): Use better contrast for trace
The current colors are barely legible
2018-08-13 12:21:14 -07:00
taschenb
0daae86fc9 fix(net): Allow all characters for the SSID
Don't filter out any character that is not part of the current C
locale, since it might drop some wanted characters
2018-08-09 14:09:50 -07:00
NBonaparte
fba87227c7 feat(pulseaudio): add volume interval option 2018-08-07 11:52:38 +02:00
NBonaparte
83784fde14 feat(alsa): add volume interval option 2018-08-07 11:52:38 +02:00
patrick96
0421b5b05f refactor: Remove unnecessary quote trim operations
Trimming the quotes in labels and the date module are not needed at all,
because surrounding quotes are removed when loading the values from the
config.

Removing the quotes in the builder also doesn't seem to serve any
purpose at all.
2018-08-05 08:50:54 +02:00
NBonaparte
4cb0b18389 fix(controller): don't draw window if writing to stdout (#1322)
fixes #1314.
2018-07-24 19:39:32 +02:00
Tim Smith
01fc545e09 fix(i3): Play nice with workspace_auto_back_and_forth (#1312)
This makes polybar play nice with the i3wm feature `workspace_auto_back_and_forth`, and it is harmless when that option isn't set.
2018-07-23 15:51:42 +02:00
memeplex
1d6d44f4e9 feat(token): Zero pad when min val starts with '0' (#1341)
Closes #1332
2018-07-23 15:49:02 +02:00
memeplex
1808ca3c51 fix(ramp): Evenly distribute states (#1340)
Fixes #1328
2018-07-23 15:42:42 +02:00
patrick96
4a494e61e1 refactor(label): Throw exception with small maxlen
This now makes label-maxlen < len(ellipsis) (= 3) a fatal error
disabling the whole module that uses the offending label
2018-07-22 14:02:15 -07:00
patrick96
0346a965a7 refactor(builder): No exception when maxlen < 3
The check of the maxlen and ellipsis condition was also moved to the
label creation, this way get_label_text doesn't need to care about the
restrictions placed on maxlen and ellipsis
2018-07-22 14:02:15 -07:00
patrick96
7dc42f543f fix(builder): Respect label-ellipsis option
This slightly changes the existing behavior of maxlen. Before with a
maxlen of 4 'abcde' used to yield 'abcd...' now it yields 'a...'
2018-07-22 14:02:15 -07:00
patrick96
4b83468eb9 refactor(builder): Add failing test for ellipsis
Adds failing tests for the bug described in #1194
2018-07-22 14:02:15 -07:00
patrick96
028b1413ef refactor(mpd): Replace icon-repeatone with icon-single
The repeatone button doesn't influence repeating behaviour at all, so
the name is misleading.

This deprecates icon-repeatone for now, until we can completely remove
it

Fixes #1279
2018-06-23 10:14:30 +02:00
taschenb
3afc341c7b feat(net): Add nl80211 support (#1009)
This patch enables support for nl80211. In case the libnl-genl-3.0
library isn't found, it will fall back to Wext instead.
The library to use can also be manually set with the CMake option
WITH_LIBNL.

The Wireless-Extensions (WE or Wext) are deprecated and long replaced
by cfg80211.

Although Wext isn't used by WiFi drivers anymore, CFG80211_WEXT allows
old tools to communicate with modern drivers by providing a wrapper
API.
2018-06-18 20:16:09 -07:00
patrick96
f7a6e5ba98 refactor(build): Build wihtout xkb
The only reason polybar couldn't build without xkb is because the
xkeyboard module's source file was not removed during compilation.
xkeyboard already has an entry in unsupported.hpp

This effectively makes xcb-util-xkb optional
2018-06-18 11:49:31 +02:00
patrick96
943fd1aaec fix(build): Build without xrm
When xrm was disabled, main.cpp was missing the complete defintion of
connection from connection.hpp, which was included xresources.hpp when
xrm was enabled.
2018-06-18 11:49:31 +02:00
sqwishy
d1d307d500 feat(net): Add local_ip6 token (#1239)
It's queried the same way ipv4 addresses are queried, but here it displays globally routable addresses. If there are multiple such addresses, it picks one (same as with ipv4). It's possible that an address discovered this way is not in fact globally reachable but still marked as global.
2018-06-10 22:51:43 +02:00
NBonaparte
067aac1ac7 fix(bspwm): use monitor focus only when pinned 2018-06-06 17:38:17 +02:00
tamago
b70d5b55d8 feat(mpd): add support for MPD_TAG_ALBUM_ARTIST 2018-05-31 20:12:23 -07:00
patrick96
930be72c89 refactor(tray): Log restack failure as error
I suspect that people that are seeing the tray above their fullscreen
windows get this exception
2018-05-15 16:01:07 -07:00
patrick96
20f3d9a141 refactor: Don't initialize forward declared members
Using brace initialization here causes bar.hpp to not compile when
included on its own, forcing all clients to also include
tray_manager.hpp and so on, which defeats the purpose of forward
declaring those classes.

This also allows us to remove the tray_manager.hpp, renderer.hpp and
parser.hpp includes from the clients of bar.hpp
2018-05-10 00:05:18 +02:00
lukediamond
c2ac93db55 Added support for mixed percent/pixel geometry. 2018-05-10 00:05:18 +02:00
patrick96
3408db3475 fix(builder): Don't truncate colors with same channels
The builder would convert bg and fg colors like #00000000 to #000 which
would make it loose its alpha channel.

Fixes #1183
2018-05-07 00:12:29 +02:00
patrick96
8173a6473e fix(gcc): Fix -Wstringop-truncation warning
As mentioned in #1215, gcc >=8 will complain, if strncpy truncates the
source string or gcc can prove there is no NUL terminating byte.

This also updates the i3ipcpp submodule where there was a similar error

Fixes #1215
2018-05-06 14:17:10 -07:00
NBonaparte
f2010edf94 fix(pulseaudio): fix max_volume naming 2018-05-05 10:57:01 +02:00
NBonaparte
4bf73ddd81 fix(pulseaudio): listen for default sink changes, and use @DEFAULT_SINK@
Using @DEFAULT_SINK@ macro avoids having to retrieve default sink name
2018-05-05 10:57:01 +02:00
patrick96
095d68fad0 fix: Stop using ato* for string to num conversion
atoi, atof and so on have undefined behavior if anything goes wrong. We
now use strto*, but without error checking. In most places overflows and
the like *should* not happen. String to number conversions are only used
when reading data from other applications or from the config, if another
application gives unparsable strings or too large numbers, then most
likely there is something wrong with that application. If the error
comes from the user config, then the user has to live with values
provided by strto* on error (which are very reasonable)

Fixes #1201
2018-05-03 11:07:37 -07:00
Christoph Schiessl
cc334e5040 fix(battery): check current state to decide which framerate to use 2018-05-02 11:44:55 +02:00
Christoph Schiessl
2a9d5db179 feat(battery): implement animation-discharging 2018-05-02 11:44:55 +02:00
patrick96
7eb1f61080 fix(net): Mark not connected on querying failure
Fixes #1163
2018-04-18 09:27:12 +02:00
Kajzer
688658c306 (pulseaudio) Add max volume configuration 2018-04-09 20:27:55 -07:00
patrick96
36ea6fbff8 Revert "fix(pulseaudio): add mutex for queue"
This reverts commit d430174f0b.
Mutual exclusion is already guaranteed by the lock on
pa_threaded_mainloop

Fixes #1139
2018-04-07 13:52:48 -07:00
patrick96
428e54e0f6 log(mpd): typo 2018-04-07 12:10:10 -07:00
patrick96
ddb1fb4c3a log(mpd): Use __func__ instead of __FUNCTION__ 2018-04-07 12:10:10 -07:00
patrick96
57a2f95ff9 log(mpd): Log mpd input events 2018-04-07 12:10:10 -07:00
patrick96
bbe5769bb0 log(mpd): trace log setting boolean options 2018-04-07 12:10:10 -07:00
Keno Goertz
d31570fe2f feat(xwindow): Add label-empty
Allows for custom text, when window title is empty
2018-04-02 00:00:16 +02:00
NBonaparte
10632178a8 fix(pulseaudio): add fallthrough marking 2018-03-31 00:52:17 +02:00
NBonaparte
d430174f0b fix(pulseaudio): add mutex for queue 2018-03-31 00:52:17 +02:00
NBonaparte
5f88cd44c7 fix(pulseaudio): get default sink on new events when using default 2018-03-31 00:52:17 +02:00
Jon Gjengset
224ffa97c1 feat(config): Support fractional size and offset
Fixes #953.
2018-03-28 10:59:22 -07:00
NBonaparte
39c12edc8a fix(cursor): add lock to motion handler 2018-03-27 22:03:38 +02:00
patrick96
3ea60ace91 fix(pulse): Use distinct event names
volup, voldow, volmute, are caught by the alsa module, if there is an
alsa module on the bar.
2018-03-27 11:28:54 -07:00
Jan Holthuis
a2ce4ed725 fix(i3): Reconnect i3 IPC socket on restart/error (#762) 2018-03-25 23:06:03 +02:00
NBonaparte
0a8a326730 feat(net): Add unknown-as-up option
Fixes #457
2018-03-04 23:09:18 +01:00
Florian Brinker
692e6d9b4a Loglevel info for "No matching input area" (#1059) 2018-02-27 17:45:24 +01:00
Alexander
4f6e37449b feat(memory): Add swap tokens (#1018) 2018-02-25 12:12:38 +01:00
patrick96
2f62a6fbad feat(memory): Add memory used/free ramp
Closes #1037
2018-02-19 14:30:30 -08:00
patrick96
0fd614b0a9 refactor(controller): Print error message on select fail 2018-02-15 19:26:35 -08:00
patrick96
c30159abc6 feat(temp): Add units option
Avoids having lots of tokens
2018-02-15 18:50:59 -08:00
patrick96
a9014e31dc refactor(temp): Mark %temperature% token as deprecated 2018-02-15 18:50:59 -08:00
patrick96
e4634ce95f feat(temp): Add temperature tokens without unit 2018-02-15 18:50:59 -08:00
kokan
cb4111383f fix(github): libcurl stuck at curl_easy_perform
Signed-off-by: kokan <peter.kokai@balabit.com>
2018-02-15 10:50:05 +01:00
patrick96
482876b63a refactor(config): Print filename at very beginning
There have now been several instances of people reporting that their
bars are not found and polybar not printing the config file name because
the error is thrown first, making it very difficult to debug
2018-02-15 08:43:19 +01:00
patrick96
d2a7b0269c refactor(mpd): Print error on mpd_exception 2018-02-14 14:27:25 -08:00
patrick96
81d2d09ba9 fix(mpd): Clear mpd error after getting error info
Before, polybar would crash, trying to throw a server error because
mpd_connection_get_server_error asserts that the error is of type server
error, but it isn't because it was cleared
2018-02-14 14:27:25 -08:00
patrick96
f531613723 fix(alsa): Use proper speaker mixer name and soundcard
The old code causes a segmentation fault, if the speaker and headphone
soundcards differ.
2018-02-13 09:44:16 -08:00
NBonaparte
4d48ffed83 fix(battery): check without using path_battery 2018-02-11 20:21:43 +01:00
NBonaparte
539e2e09cf fix(cmake): look for and remove alsa.cpp if not used 2018-02-11 17:25:21 +01:00
NBonaparte
1ac5c23fd2 fix(xbacklight): respect enable-scroll 2018-02-11 17:22:44 +01:00
Vlad Glagolev
a5b310872c Respect 'enable-scroll' setting for xworkspaces module 2018-02-03 14:43:34 -08:00
Kareem El-Faramawi
2f113446c0 fix(battery): capture path_battery by copy (#992)
path_battery goes out of scope, so the stack reference becomes garbage

Fixes #985
2018-02-02 10:42:20 +01:00
patrick96
26abd0f6c4 fix(mpd): Check m_status before dereferencing it
This bug was introduced in 645a3142a1

Fixes #979
2018-01-31 22:17:25 -08:00
NBonaparte
2a056d5b23 fix(power): add comments to explain current/power_now 2018-01-30 21:24:51 +01:00
NBonaparte
95d3b4f1eb fix(battery): use power_now correctly 2018-01-30 21:24:51 +01:00
patrick96
5c7ff09ed6 fix(config): Use proper token object
When using the same token multiple times in the same label with
different length properties, polybar would always use the settings for
the first token. This now replaces the tokens one by one, so that a new
token object is used for the length settings each time a token is used
again. Because the token objects are added in order, the replacement
always uses the right token object for the token that is replaced.

Fixes #971
2018-01-27 23:40:19 -08:00
NBonaparte
06dee3dedd fix(volume): Warn instead of throw 2018-01-23 14:33:11 +01:00
NBonaparte
e16227ca43 refactor(alsa): rename and move volume -> alsa 2018-01-23 14:33:11 +01:00
patrick96
1d9dd719bc refactor(script): Loop over buttons and replace tokens 2018-01-21 14:41:52 -08:00
patrick96
f79aeac872 feat(script): Add %pid% token for tail commands
Is replaced with the pid of the exec command
2018-01-21 14:41:52 -08:00
NBonaparte
3af3aea534 fix(pulseaudio): warn only if default sink is not same as specified sink 2018-01-20 12:37:41 -08:00
NBonaparte
10656a94cb fix(pulseaudio): prevent nonresponsiveness and remove redundant getters 2018-01-20 12:37:41 -08:00
NBonaparte
1f35b9dc89 fix(pulseaudio): Add logging 2018-01-20 12:37:41 -08:00
NBonaparte
0eac7f5d04 fix(pulseaudio): use PA_VOLUME_UI_MAX 2018-01-20 12:37:41 -08:00
NBonaparte
8be5427c33 refactor(pulseaudio): remove headphone ramp 2018-01-20 12:37:41 -08:00
NBonaparte
1792090d66 refactor(pulseaudio): remove wait timeout, fix indents 2018-01-20 12:37:41 -08:00
NBonaparte
6e8b9dea29 fix(pulseaudio): Move pulseaudio to separate module 2018-01-20 12:37:41 -08:00
NBonaparte
a08c5c710a fix(pulseaudio): fix get_name(), cleanup 2018-01-20 12:37:41 -08:00
NBonaparte
5c6b56614e fix(pulseaudio): Rewrite error checking 2018-01-20 12:37:41 -08:00
NBonaparte
916c7b6852 refactor(pulseaudio): Use index instead of name to track sinks 2018-01-20 12:37:41 -08:00
NBonaparte
23ee9afb6f fix(pulseaudio): Use inc_volume() instead of set_volume() 2018-01-20 12:37:41 -08:00
NBonaparte
318a6d83cf refactor(pulseaudio): Move loop to inline function 2018-01-20 12:37:41 -08:00
NBonaparte
4f15f42f2c fix(build): Only use one volume backend 2018-01-20 12:37:41 -08:00
NBonaparte
81913cf181 wip(pulseaudio): create pulseaudio backend 2018-01-20 12:37:41 -08:00
patrick96
6ed4838738 fix(mpd): Update on MPD_IDLE_QUEUE events
MPD_IDLE_PLAYLIST is deprecated since 2009, it has the same value as
MPD_IDLE_QUEUE, so we are now using that
2018-01-15 19:32:02 +01:00
patrick96
645a3142a1 fix(mpd): Always update mpd data
Only updating when an mpd event occurred would cause issues when mpd was
playing and the machine was put to sleep because the elapsed time was
calculated by taking the time difference of the last update and now
which would give you wrong numbers, if the machine was in standby in
between.

Since the update function on the module is only called once a second (or
when an event happens), we can just update the data every time without a
huge performance hit.

Fixes #915
2018-01-15 19:32:02 +01:00
Patrick Ziegler
d8414c6ec5 feat(i3): Add workspace separator (#938)
Puts a label-separator node between workspaces on the bar. Since the
separator uses a label it can be configured like any other label

Closes: #929
2018-01-06 16:19:02 -08:00
Patrick Ziegler
a7eb7b3576 feat(bspwm): Add workspace separator (#942)
Same as the i3 workspace separator
2018-01-06 16:18:09 -08:00
Jens Henniges
d3abcc97f6 feat(mpd): Add support for icon-consume (#861) 2017-12-04 11:38:17 -08:00
NBonaparte
c348c3e917 fix(mpd): get format-online options for format-{playing,paused,stopped} (#868) 2017-11-30 21:58:34 +01:00
Vasili Karaev
5d2deb1a99 fix(renderer): Only draw text bg if color differs from bar bg (#831)
Fixes #759 by only drawing text background when its color is different from the background color of the bar itself.

Explicitly setting a module's background to `background-0` now stops working.
2017-11-12 09:53:54 +01:00
NBonaparte
3092a1b18f
feat(mpd): Get name and/or uri if title not found (#823) 2017-11-08 21:12:44 -08:00
Kókai Péter
3f9f2dc37f fix(github): Handle curl exceptions and bad status codes (#811)
If any error occurs, a warning is logged and -1 
is displayed as the number of notifications
2017-11-07 23:29:44 +01:00
Vasili Karaev
dc0edfb994 fix(i3): Check whether current ws is found (#826)
Fixes dereference of end() iterator in case current workspace is not found (#824).

Fixes #824
2017-11-01 16:47:07 +01:00
NBonaparte
d4d571425d refactor(mpd): Keep tag getters consistent 2017-10-23 15:07:03 -07:00
Chris Snell
5737156ae5 feat(temperature): Fahrenheit and Celsius tokens (#804)
%temperature-f% and %temperature-c%
2017-10-18 22:29:53 +02:00
Pier
cbd87efc64 fix(build): pow10 not defined on Fedora Rawhide (#807)
pow10 is a GNU extension and not available everywhere
2017-10-15 19:16:07 +02:00
NBonaparte
5b7d7b8232 Merge pull request #729 from NBonaparte/fix-prefix-suffix
fix(modules): Separate prefix/suffix tags, revert tag stack
2017-09-24 14:00:34 -07:00
patrick96
c7cb5ebf94
fix(renderer): Handle nested actions events properly
For nested actions, the inner action should override the outer action.
But because the list of actions was not iterated in reverse the outer
action was matched first.

Fixes #760
2017-09-23 16:53:04 +02:00
patrick96
251c3e874a
fix(renderer): Only close a single action
Before the renderer would close all active matching actions. That way
nested actions would also close their surrounding action block
2017-09-23 16:49:39 +02:00
NBonaparte
89fccde765 fix(modules): Apply format settings to pre/suffix 2017-09-22 23:40:31 -07:00
Patrick Ziegler
4663d01a51 Merge pull request #727 from NBonaparte/change-cursor
feat: Change cursors over clickable/scrollable areas
2017-09-17 22:33:32 +02:00
NBonaparte
27f53eb129 Merge pull request #745 from patrick96/issues/744
fix(date): date and time string limited to 63 chars
2017-09-17 13:20:55 -07:00
NBonaparte
70023b07c1 refactor(cursor): Include double clicks and fix scroll to click changes 2017-09-16 19:48:38 -07:00
NBonaparte
e612fe1624 refactor(cursor): use map for cursor list 2017-09-16 15:31:24 -07:00
NBonaparte
b7f1960a0a fix(cursor): change arrow_names to default_names 2017-09-16 15:31:24 -07:00
NBonaparte
1886cf97a8 fix: pass action by reference 2017-09-16 15:31:24 -07:00
NBonaparte
1dc111c0fa fix: make xcb-cursor optional for now 2017-09-16 15:31:24 -07:00
NBonaparte
65edba3321 feat: add cursor change 2017-09-16 15:31:24 -07:00
patrick96
b6a2c575fd
refactor(date): Use cpp string comparison 2017-09-16 00:09:26 +02:00
patrick96
0024e1e9e7
refactor(date): Remove obsolescent setlocale call 2017-09-15 14:22:42 +02:00
patrick96
1bc9933a88
refactor(date): Use single stringstream
Reduces code repetition and removes the need for setting the locale in
every update
2017-09-15 14:21:38 +02:00
patrick96
6e9e739d81
fix(date): Remove string length limitation
Fixes #744
2017-09-15 14:13:35 +02:00
Chase Geigle
a682d2af91
fix(fs): Use f_frsize in filesystem calculations
This is consistent with the documentation of
std::experimental::filesystem, so I think it is the more "correct"
thing to be doing here.
2017-09-14 19:02:55 -05:00
NBonaparte
9da06c0ec2 fix(modules): Remove redundant if statement 2017-09-06 20:16:08 -07:00
NBonaparte
3ce06585ab fix(parser): Revert tag stacks 2017-09-06 20:16:08 -07:00
NBonaparte
f3bddc5af4 fix(modules): Separate prefix and suffix from output 2017-09-06 20:15:28 -07:00
NBonaparte
138f5faed8 fix(fs): Calculate used, percentages according to df
Fixes #710.
2017-09-06 17:20:10 -07:00
Patrick Ziegler
a255a022a7 fix(renderer): Correct center module position (#673)
The changes introduced in 389bae2669 to
address #551 did not consider the left border

Now center modules are centered regardless of border (left or right)
settings or tray position

Fixes #672
2017-09-04 23:46:47 -07:00
NBonaparte
e329a8150a fix(config): Expand all environment variables and file references (#724) 2017-09-04 14:00:35 -07:00
NBonaparte
ce05aa36a1 feat(temperature): Add hwmon sysfs support (#688) 2017-08-29 15:10:28 -07:00
Patrick Ziegler
8c1ba8358d feat(menu): Add expand-right option (#658)
expand-right defaults to true to preserve the current functionality
If set to false, the items in the menu will be added to the left of the
toggle label (instead of the right side)

Should resolve the issue discussed in #655
2017-08-29 13:25:41 -07:00