Commit Graph

332 Commits

Author SHA1 Message Date
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
4b5007294b refactor(modules): Make all modules input handlers
By default they will return false for calls to `input`
2020-11-26 20:53:53 +01:00
patrick96
457e37faaf fix: add name_raw to unsupported modules 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
Malte Bargholz
a625e2b79a
fix(timer_module): sleep until next full interval (#2123)
Any timer_module based module would sleep for the set interval and then
continue running. Depending on the start time of polybar this
sleep pattern might not be aligned, which causes such modules to always
update in a shifted manner.
Consider the date module as an example. If the update interval is set to
60 seconds and polybar was started at 13:37:37, polybar would update the
clock at 13:38:37, 13:39:37 and so on.
To make matters worse, if a module would perform lengthy checks this
interval might drift over time, causing even more inconsistent updating.

This patch extends the base module with a sleep_until method that calls
the corresponding function on the sleephandler. Additionally the
timer_module is extended to compute the remaining time until the next
interval passes and sleep accordingly.

Closes #2064

Co-developed-by: Dominik Töllner <dominik.toellner@stud.uni-hannover.de>

Co-authored-by: Malte Bargholz <malte@screenri.de>
2020-06-20 22:15:25 +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
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
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
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
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
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
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
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
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
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
4ea188b3f9 fix(modules): Only add reset tag on non-empty modules
Adding the reset tag to empty modules makes polybar add margins and
separators for that empty module.

Fixes #1857

Ref #1596
2019-08-22 22:42:30 +02:00
patrick96
211b0bbfd8 Incorporate Reviews 2019-08-06 21:36:20 +02:00
patrick96
57d364a2fc Reset all tags at the end of a module
The %{PR} tag is introduced for this. It resets all colors as well as
the activation of the underline and overline and font.

This has become necessary because we don't track what raw tags a user
injects into the formatting string and otherwise their raw tags could
bleed through.

This doesn't touch action tags because even before raw action tags
weren't being tracked. Action tags also have the requirement that they
have to be used in pairs, so closing them prematurely could break things
(for example with click actions for the entire bar)
2019-08-06 21:36:20 +02:00
Jérôme BOULMIER
58d72c4f19 feat(github): add support for github enterprise (#1841) 2019-08-04 20:58:25 +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
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
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
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
Joost Sijm
8ca36d9e16 typo: replace 'alot' with 'a lot' (#1634)
This is bothering me alot
2019-01-29 17:54:38 +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
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
patrick96
6ca4f06785 doc: Convert @ to \ doxygen commands
Ref #1377
2018-11-04 19:28:27 -08: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
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
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
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
Christoph Schiessl
2a9d5db179 feat(battery): implement animation-discharging 2018-05-02 11:44:55 +02:00
patrick96
1d20df00e8 fix(ycm): Fix ycm error
All files that include base.inl also include base.hpp but technically
it's required for it to compile
2018-04-08 02:30:04 +02: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
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
NBonaparte
0a8a326730 feat(net): Add unknown-as-up option
Fixes #457
2018-03-04 23:09:18 +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
c30159abc6 feat(temp): Add units option
Avoids having lots of tokens
2018-02-15 18:50:59 -08:00
patrick96
078bcd5e7d Respect MPD_HOST env variable
Fixes #1007
2018-02-15 17:45:41 -08:00
NBonaparte
989bc00082 fix(alsa): use correct module_name 2018-02-11 17:04:08 +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
5ca1940629 fix(alsa): use correct name for deprecation 2018-01-27 09:12:09 +01: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
NBonaparte
818bcbd0b5 volume: use internal/alsa instead of internal/volume 2018-01-23 14:33:11 +01: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
8be5427c33 refactor(pulseaudio): remove headphone ramp 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
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
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
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
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
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
Vasili Karaev
5c41e3d045 feat(mpd): Add state-specific formats #524 2017-05-09 14:56:29 +02:00
Vasili Karaev
863c510903 fix(i3): Use ws name for click handling #520 2017-04-06 06:22:11 +03:00
Michael Carlberg
02833b7871 feat(volume): Optional event handling #84 2017-04-02 18:12:07 +02:00
raidzero
50aba85ad0 Merge remote-tracking branch 'upstream/master' 2017-02-23 14:50:09 -07:00
Adam Ransom
47bc459742 fix(bspwm): Update when focusing urgent desktops
When focusing a desktop with the urgent flag, two events are received
from `bspc` simultaneously, separated by a newline character.

This was not handled correctly and the second event was discarded causing
the urgent style to be removed, but the focused style would remain on the
previously focused desktop.

This fixes the problem by handling any number of events that arrive at the
same time (separated by newlines).
2017-02-23 13:28:26 +01:00
NBonaparte
44f12c6065 feat(xworkspaces): add urgent desktop detection 2017-02-23 13:20:26 +01:00
raidzero
93c425fdfe Add battery usage/charge in watts token %consumption% 2017-02-16 14:35:43 -07:00
Michael Carlberg
384c12a896 fix(xwindow): Lock mutexes on update #416 2017-02-05 13:37:16 +01:00
Michael Carlberg
6fa2d3943c fix(timer_module): Catch warmup exceptions
Refs #399
2017-01-31 12:38:38 +01:00
Michael Carlberg
eb5c82a5c3 fix(modules): Warmup in runner thread to avoid block 2017-01-27 13:29:10 +01:00
Michael Carlberg
042d385015 fix(i3): Add state descriptions 2017-01-27 03:23:42 +01:00
Michael Carlberg
1a25be374f refactor(xworkspaces): Cleanup 2017-01-25 04:35:56 +01:00
Michael Carlberg
6692b4a8da refactor(x11): Cleanup 2017-01-24 10:49:14 +01:00
Michael Carlberg
452afcdc68 refactor: Integral types 2017-01-24 07:11:14 +01:00
Patrick Yates
2dfdbd240e feat(bspwm,i3): Fuzzy-matching names for icons
Added support for fuzzy matching workspace names when assigning icons.
This feature is enabled/disabled through a new option, 'fuzzy-match'.
It is disabled by default.
2017-01-23 17:01:30 +01:00
Michael Carlberg
dacf36b981 refactor(ipc): Cleanup 2017-01-14 00:27:29 +01:00
Michael Carlberg
15f880eba4 fix(mpd): Handle broken connections 2017-01-13 13:02:51 +01:00
Michael Carlberg
f56bb419d2 fix: Format whitespace handling
Refs #325
2017-01-13 10:54:41 +01:00
Michael Carlberg
385572ec64 feat(xrandr): Support for monitors
Refs #280
2017-01-13 03:52:57 +01:00
Michael Carlberg
40493497de fix: Allow size_t narrowing 2017-01-13 01:14:50 +01:00
Michael Carlberg
07c0fbdcb3 fix(timer_module): Sleep at beginning since already warmed up 2017-01-12 23:33:36 +01:00
Michael Carlberg
92cc4d6f40 fix(modules): Warmup module on start 2017-01-12 20:29:08 +01:00
Michael Carlberg
c2ac7fde67 refactor: Filesize strings 2017-01-12 20:28:44 +01:00
Michael Carlberg
f72ddf9294 refactor(signals): Use full namespace 2017-01-12 16:34:14 +01:00
Michael Carlberg
5c9bfc147c fix(xbacklight): Lower inc/dec value to 5 and fix flooring 2017-01-11 04:40:10 +01:00
Michael Carlberg
8cc885c316 refactor: Cleanup 2017-01-11 03:07:28 +01:00
Michael Carlberg
30f516dd7d fix(formatting): Make formats parse specs as-is
This removes the spacing tinkering when parsing format specs.
The following example uses the old behavoir:

    format-test = <label-foo>  <label-bar>
    format-breaks = <label-foo><label-bar>/<bar-test>

`format-test` would replace all occurences of ' ' with the
a space string with defined `spacing` as its width. `format-breaks` would
not validate as the tags where split with ' ' as delimiter.

All that nonsense has been removed and each tag is extracted as is.
The `spacing` parameter can still be used to apply N extra whitespaces
between the tags, but it is now 0 by default.
2017-01-11 02:43:37 +01:00
Michael Carlberg
f4e8051e9e refactor(script): Merge back script handling 2017-01-10 05:12:53 +01:00
Michael Carlberg
946843ff59 feat(script): Configurable condition using exec-if
Add new config parameter `exec-if = cmd` that needs to
exit successfully before the main exec command will be invoked.

Closes #298
2017-01-10 03:02:00 +01:00
Michael Carlberg
7a26254844 feat(ipc): Initial exec of configured hook
Adds a new config parameter `initial = N` that will
make the hook at defined index N execute on start.
2017-01-09 23:06:41 +01:00
Michael Carlberg
5f6a1f5ae6 fix(xkeyboard): Use separate throttle timers 2017-01-09 16:40:26 +01:00
Michael Carlberg
e0688307f3 wip(systray): Add module base 2017-01-01 21:28:28 +01:00
Michael Carlberg
0c39061c98 feat(bspwm): Add option to inline mode indicators 2017-01-01 16:39:25 +01:00
Michael Carlberg
ccddf052ec refactor(script): Split non-/tail logic
Split the script module into one tailing output module and
one exec once module.

Refs #281
2017-01-01 09:05:18 +01:00