New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xkeyboard: add icons for layouts and indicators #1048
Conversation
…plememnted) and support for indicator icons
Great work, thank you! |
Any chance for this being reviewed anytime soon? This is great stuff, essentially allowing to have a Mac-like behavior where languages are associated with country flags and displayed as such. |
So sorry, this one must have slipped through the cracks. @ozelis Would you still be around to maybe make changes after I reviewed this? |
What is the status on this? |
@TheFelixR work is being done over at #1559 since the author doesn't seem to be around anymore. |
* `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>
* `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 polybar#1558 Closes polybar#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>
* In the `internal/memory` module all of the megabyte values no longer have decimal places (polybar#1606). **New Config Options** The following config options were added: In the `[bar/*]` section: * `monitor-exact`, use exact name matching for monitors otherwise ignore dashes. In formats: * `format-NAME-font` to set the font for that format (same as `label-NAME-font`) In `internal/bspwm`: * `label-marked` for the new `marked` node flag introduced in baskerville/bspwm@d0138af In `internal/xkeyboard`: * `label-indicator-(on|off)` is uses once for every indicator (caps lock, etc.), supports `%name%` and `%icon%` * `label-indicator-(on|off)-(capslock|numlock|scrolllock)` overwrites `label-indicator-(on|off)` for the given indicator * `layout-icon-*` is a list that maps layout names to icons to be used with the `%icon%` token in `label-layout` * `indicator-icon-*` is a list that maps indicator names to icons to be used with the `%icon%` token in `label-indicator-*` In `internal/temperature`: * `base-temperature` is the counterpart to `warn-temperature` and controls the lower bound for the ramp. **Deprecations** * xkeyboard: `label-indicator` is deprecated in favor of the new `label-indicator-on` **Features** * bar: * make exact monitor matching configurable (polybar#1533), see polybar#1532 * `border-size` now supports the same mixed percentage/pixel sizes as `width` and `height` (polybar#1592), see polybar#1567 * Use primary monitor if no monitor is specified (polybar#1426), polybar#1412 * bspwm: Support for the new `marked` node flag. (polybar#1557), see polybar#1552 * format: Formats now support the `-font` property just as labels (polybar#1602), see polybar#19 * network: Support for all tokens in all labels (polybar#1597) * xkeyboard: Indicator names can be customized. Also adds icon mappings for layouts and indicators (polybar#1559, polybar#1048), see polybar#1558 * temperature: The ramp now starts at `base-temperature` instead of 0°C (polybar#1706), see polybar#1703 * battery: `%percentage_raw%` token that displays the real percentage regardless of `full-at` (polybar#1756), see polybar#1753 **Fixes** * network: Display `N/A` when no IPv4 address can be found (polybar#1597) * xworkspaces: Properly handle when desktops are removed from `_NET_DESKTOP_NAMES` (polybar#1713), see polybar#1710 * backlight: Read the right brightness value (polybar#1689), see polybar#1180 * pulseaudio: Allow volume increase when it is close to the maximum. Before it did not allow that when adding `interval` would go over the max. (polybar#1765) * i3: fix workspace change for workspaces with special characters in the name (polybar#1798), see polybar#1797 * font: Characters no longer vanish when the `size` or `pixelsize` property is 0 (polybar#1646) * build: * Compilation error under gcc9 (polybar#1729), see polybar#1728 * Compilation no longer fails when new flags are introduced that produce new warnings (polybar#1735)
* In the `internal/memory` module all of the megabyte values no longer have decimal places (polybar#1606). **New Config Options** The following config options were added: In the `[bar/*]` section: * `monitor-exact`, use exact name matching for monitors otherwise ignore dashes. In formats: * `format-NAME-font` to set the font for that format (same as `label-NAME-font`) In `internal/bspwm`: * `label-marked` for the new `marked` node flag introduced in baskerville/bspwm@d0138af In `internal/xkeyboard`: * `label-indicator-(on|off)` is uses once for every indicator (caps lock, etc.), supports `%name%` and `%icon%` * `label-indicator-(on|off)-(capslock|numlock|scrolllock)` overwrites `label-indicator-(on|off)` for the given indicator * `layout-icon-*` is a list that maps layout names to icons to be used with the `%icon%` token in `label-layout` * `indicator-icon-*` is a list that maps indicator names to icons to be used with the `%icon%` token in `label-indicator-*` In `internal/temperature`: * `base-temperature` is the counterpart to `warn-temperature` and controls the lower bound for the ramp. **Deprecations** * xkeyboard: `label-indicator` is deprecated in favor of the new `label-indicator-on` **Features** * bar: * make exact monitor matching configurable (polybar#1533), see polybar#1532 * `border-size` now supports the same mixed percentage/pixel sizes as `width` and `height` (polybar#1592), see polybar#1567 * Use primary monitor if no monitor is specified (polybar#1426), polybar#1412 * bspwm: Support for the new `marked` node flag. (polybar#1557), see polybar#1552 * format: Formats now support the `-font` property just as labels (polybar#1602), see polybar#19 * network: Support for all tokens in all labels (polybar#1597) * xkeyboard: Indicator names can be customized. Also adds icon mappings for layouts and indicators (polybar#1559, polybar#1048), see polybar#1558 * temperature: The ramp now starts at `base-temperature` instead of 0°C (polybar#1706), see polybar#1703 * battery: `%percentage_raw%` token that displays the real percentage regardless of `full-at` (polybar#1756), see polybar#1753 **Fixes** * network: Display `N/A` when no IPv4 address can be found (polybar#1597) * xworkspaces: Properly handle when desktops are removed from `_NET_DESKTOP_NAMES` (polybar#1713), see polybar#1710 * backlight: Read the right brightness value (polybar#1689), see polybar#1180 * pulseaudio: Allow volume increase when it is close to the maximum. Before it did not allow that when adding `interval` would go over the max. (polybar#1765) * i3: fix workspace change for workspaces with special characters in the name (polybar#1798), see polybar#1797 * font: Characters no longer vanish when the `size` or `pixelsize` property is 0 (polybar#1646) * build: * Compilation error under gcc9 (polybar#1729), see polybar#1728 * Compilation no longer fails when new flags are introduced that produce new warnings (polybar#1735)
Breaking Changes: * In the `internal/memory` module all of the megabyte values no longer have decimal places (polybar#1606). Changelog **New Config Options** The following config options were added: In the `[bar/*]` section: * `monitor-exact`, use exact name matching for monitors otherwise ignore dashes. In formats: * `format-NAME-font` to set the font for that format (same as `label-NAME-font`) In `internal/bspwm`: * `label-marked` for the new `marked` node flag introduced in baskerville/bspwm@d0138af In `internal/xkeyboard`: * `label-indicator-(on|off)` is used once for every indicator (caps lock, etc.), supports `%name%` and `%icon%` * `label-indicator-(on|off)-(capslock|numlock|scrolllock)` overwrites `label-indicator-(on|off)` for the given indicator * `layout-icon-*` is a list that maps layout names to icons to be used with the `%icon%` token in `label-layout` * `indicator-icon-*` is a list that maps indicator names to icons to be used with the `%icon%` token in `label-indicator-*` In `internal/temperature`: * `base-temperature` is the counterpart to `warn-temperature` and controls the lower bound for the ramp. **Deprecations** * xkeyboard: `label-indicator` is deprecated in favor of the new `label-indicator-on` **Features** * bar: * make exact monitor matching configurable (polybar#1533), see polybar#1532 * `border-size` now supports the same mixed percentage/pixel sizes as `width` and `height` (polybar#1592), see polybar#1567 * Use primary monitor if no monitor is specified (polybar#1426), polybar#1412 * bspwm: Support for the new `marked` node flag. (polybar#1557), see polybar#1552 * format: Formats now support the `-font` property just as labels (polybar#1602), see polybar#19 * network: Support for all tokens in all labels (polybar#1597) * xkeyboard: Indicator names can be customized. Also adds icon mappings for layouts and indicators (polybar#1559, polybar#1048), see polybar#1558 * temperature: The ramp now starts at `base-temperature` instead of 0°C (polybar#1706), see polybar#1703 * battery: `%percentage_raw%` token that displays the real percentage regardless of `full-at` (polybar#1756), see polybar#1753 **Fixes** * network: Display `N/A` when no IPv4 address can be found (polybar#1597) * xworkspaces: Properly handle when desktops are removed from `_NET_DESKTOP_NAMES` (polybar#1713), see polybar#1710 * backlight: Read the right brightness value (polybar#1689), see polybar#1180 * pulseaudio: Allow volume increase when it is close to the maximum. Before it did not allow that when adding `interval` would go over the max. (polybar#1765) * i3: fix workspace change for workspaces with special characters in the name (polybar#1798), see polybar#1797 * font: Characters no longer vanish when the `size` or `pixelsize` property is 0 (polybar#1646) * build: * Compilation error under gcc9 (polybar#1729), see polybar#1728 * Compilation no longer fails when new flags are introduced that produce new warnings (polybar#1735)
Breaking Changes: * In the `internal/memory` module all of the megabyte values no longer have decimal places (#1606). Changelog **New Config Options** The following config options were added: In the `[bar/*]` section: * `monitor-exact`, use exact name matching for monitors otherwise ignore dashes. In formats: * `format-NAME-font` to set the font for that format (same as `label-NAME-font`) In `internal/bspwm`: * `label-marked` for the new `marked` node flag introduced in baskerville/bspwm@d0138af In `internal/xkeyboard`: * `label-indicator-(on|off)` is used once for every indicator (caps lock, etc.), supports `%name%` and `%icon%` * `label-indicator-(on|off)-(capslock|numlock|scrolllock)` overwrites `label-indicator-(on|off)` for the given indicator * `layout-icon-*` is a list that maps layout names to icons to be used with the `%icon%` token in `label-layout` * `indicator-icon-*` is a list that maps indicator names to icons to be used with the `%icon%` token in `label-indicator-*` In `internal/temperature`: * `base-temperature` is the counterpart to `warn-temperature` and controls the lower bound for the ramp. **Deprecations** * xkeyboard: `label-indicator` is deprecated in favor of the new `label-indicator-on` **Features** * bar: * make exact monitor matching configurable (#1533), see #1532 * `border-size` now supports the same mixed percentage/pixel sizes as `width` and `height` (#1592), see #1567 * Use primary monitor if no monitor is specified (#1426), #1412 * bspwm: Support for the new `marked` node flag. (#1557), see #1552 * format: Formats now support the `-font` property just as labels (#1602), see #19 * network: Support for all tokens in all labels (#1597) * xkeyboard: Indicator names can be customized. Also adds icon mappings for layouts and indicators (#1559, #1048), see #1558 * temperature: The ramp now starts at `base-temperature` instead of 0°C (#1706), see #1703 * battery: `%percentage_raw%` token that displays the real percentage regardless of `full-at` (#1756), see #1753 **Fixes** * network: Display `N/A` when no IPv4 address can be found (#1597) * xworkspaces: Properly handle when desktops are removed from `_NET_DESKTOP_NAMES` (#1713), see #1710 * backlight: Read the right brightness value (#1689), see #1180 * pulseaudio: Allow volume increase when it is close to the maximum. Before it did not allow that when adding `interval` would go over the max. (#1765) * i3: fix workspace change for workspaces with special characters in the name (#1798), see #1797 * font: Characters no longer vanish when the `size` or `pixelsize` property is 0 (#1646) * build: * Compilation error under gcc9 (#1729), see #1728 * Compilation no longer fails when new flags are introduced that produce new warnings (#1735)
Added icon support for layouts and indicators in a similar way as it is done for i3 workspaces.
First of all a new
%icon%
token is available for the<label-layout>
tag. Default icon (though not very useful) is specified with:layout-icon-default = some-icon
and layout icons with a
';'
-separated list of pairslayout-icon-0 = us;some-icon-1
layout-icon-1 = lt;some-icon-2
The value on the lhs of
';'
will match%layout%
token for a particular layout, eg. this list will work for layouts set up with$ setxkbmap -layout "us,lt" -option "grp:alt_shift_toggle"
For indicators,
<label-indicator>
also gets%icon%
token and two states:'on'
and'off'
. Default icons for indicators are specified with:indicator-icon-default = some-icon-1;some-icon-2
where the first value is for the
'off'
state and the second is for the'on'
state. Individual indicator icons can be specified with a list of';'
-separated triples:indicator-icon-0 = caps lock;some-icon-1;some-icon-2
indicator-icon-1 = num lock;some-icon-3;some-icon-4
indicator-icon-2 = scroll lock;some-icon-5;some-icon-6
Again, the first icon is for
'off'
state and the second one is for the'on'
state.<label-indicator>
states can now be configured individually like this:label-indicator-on = %icon%
label-indicator-on-foreground = #0f0
...
label-indicator-off = %icon%
label-indicator-off-foreground = #f00
...
If these states are not explicitly specified,
label-indicator-on
will inherit values fromlabel-indicator
andlabel-indicator-off
will be empty so that existing user configs are not broken (who expect nothing to be shown when indicator is off). Otherwise values set forlabel-indicator-*
are ignored (though the tag is itself is still named<label-indicator>
).Also
scroll lock
indicator was missing from the implementation even though it was mentioned in the wiki, so I added that.I've tested this with my old configs and a dozen or so other dotfiles i found on /r/unixporn and nothing breaks except maybe
scroll lock
indicator would now pop up if it was not blacklisted before (though every config I've seen have indicators disabled anyway).Going forward I would also like to use a whitelist mode instead of a blacklist mode for two reasons:
keyboard::indicator::type
enum
. With a whitelist, we could render them in the order they appear in this list.In case this gets merged there's an updated wiki page in my repo:
https://github.com/ozelis/polybar/wiki/xkeyboard