also allows the lock keys to be toggled with mouse clicks, which could be
useful for keyboards without Scroll lock keys or malfunctioning keyboards.
-**Note**: This indicator is known to not work on Xfce / Xubuntu.
-For more details, see [#6](https://github.com/adrianiainlam/indicator-keyboard-led/issues/6).
-
## Screenshots
![indicator default][sc1]
Menu of the indicator, shown on click. The locks can be toggled by clicking
the respective item in the menu.
-![indicator short][sc3]
-Alternative (short) appearance of the indicator.
-
## Installation from Ubuntu PPA
sudo add-apt-repository ppa:adrianiainlam/indicator-keyboard-led
After installation the postinst script will prompt you for preferences
configuration. These config are explained here:
-### Short label
-
-The default appearance of the indicator has long labels:
-![⚫Num ⚫Caps ⚫Scroll][sc1]
-
-On small displays it may be preferable to use short labels:
-![⚫N ⚫C ⚫S][sc3]
-
### Order
This option allows you to reorder the locks and also to hide
characters 'N', 'C' and 'S' to set this option.
For exampe, the default order is "Num Caps Scroll".
-![⚫Num ⚫Caps ⚫Scroll][sc1]
+![Num Caps Scroll][sc1]
**CNS** changes this to "Caps Num Scroll".
-![⚫Caps ⚫Num ⚫Scroll][sc4]
+![Caps Num Scroll][sc4]
**NC** hides Scroll lock from the default appearance.
-![⚫Num ⚫Caps][sc5]
-
-**C**, combined with the previous *short* option,
-would give a very compact Caps lock indicator.
-![⚫C][sc6]
+![Num Caps][sc5]
[sc1]: screenshots/sc1.png
[sc2]: screenshots/sc2.png
-[sc3]: screenshots/sc3.png
[sc4]: screenshots/sc4.png
[sc5]: screenshots/sc5.png
-[sc6]: screenshots/sc6.png
### xdotool
To solve this, do the following (assuming US keyboard):
> # backup your symbols file
- > sudo cp /usr/share/X11/xkb/symbols/us{,.distribution}
+ > sudo cp /usr/share/X11/xkb/symbols/us{,.distribution}
>
> Add the following line in the `xkb_symbols "basic" {` section. Do not worry
> if that second line is not there, it is only there for some languages and
>
> ...
> modifier_map Mod3 { Scroll_Lock }; <==<< Add this line
- >
+ >
> include "level3(ralt_switch)" <==<< before this line
> };
>
## Localization
-As motivated by Issue #1, this script has been localized to French (with
-the assistance of Wikipedia and Google Translate). Corrections to the
-translation, as well as translations to other languages, are welcome.
-Feel free to create a pull request or open an issue.
+Unfortunately, in order to work-around labels not being shown on newer
+non-Unity-based Ubuntus, I have re-designed the indicators to be based
+purely on icons instead. This means there will no longer be labels to
+localize, and I instead have hardcoded icons.
+
+The icons are SVGs so you can still manually edit them if you want.
+Look for the `<text>` tag at the end of the SVGs.
+
+The menu items shown on click are still localized.
+
+I have included a screenshot below to show the old design (version 1.1)
+which you can still install manually if you wish.
-![indicator default, French locale][sc7]
-Default appearance in a French locale.
+> As motivated by Issue #1, this script has been localized to French (with
+> the assistance of Wikipedia and Google Translate). Corrections to the
+> translation, as well as translations to other languages, are welcome.
+> Feel free to create a pull request or open an issue.
+>
+> ![indicator default, French locale][sc7]
+> Default appearance in a French locale.
[sc7]: screenshots/sc7.png
The program "indicator-keyboard-led.py" is released under the MIT License.
Please refer to the file for the full text of the license.
-The icon "indicator-keyboard-led.svg" is released to the public domain.
+The icons "indicator-keyboard-led*.svg" are released to the public domain.
## Credits
[indicator-chars](https://github.com/tobyS/indicator-chars) which I used
as a reference when writing this software.
-The icon used in the indicator (indicator-keyboard-led.svg) is modified
+The icons used in the indicator (indicator-keyboard-led*.svg) are modified
from the file "emblem-readonly.svg" by
[Jakub Steiner](http://jimmac.musichall.cz)
who released it to the public domain for the
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="48px"
+ height="48px"
+ id="svg11300"
+ sodipodi:version="0.32"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)"
+ sodipodi:docname="indicator-keyboard-led-C-on.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ version="1.1">
+ <defs
+ id="defs8" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1855"
+ inkscape:window-height="1056"
+ id="namedview6"
+ showgrid="false"
+ showguides="false"
+ inkscape:zoom="9.8333333"
+ inkscape:cx="8.4441852"
+ inkscape:cy="20.424683"
+ inkscape:window-x="65"
+ inkscape:window-y="24"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="layer1" />
+ <metadata
+ id="metadata4">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:creator>
+ <dc:Agent>
+ <dc:title>Jakub Steiner</dc:title>
+ </dc:Agent>
+ </dc:creator>
+ <dc:contributor>Adrian I Lam</dc:contributor>
+ <dc:source>http://jimmac.musichall.cz</dc:source>
+ <cc:license
+ rdf:resource="http://creativecommons.org/licenses/publicdomain/" />
+ <dc:title></dc:title>
+ <dc:subject>caps lock</dc:subject>
+ </cc:Work>
+ <cc:License
+ rdf:about="http://creativecommons.org/licenses/publicdomain/">
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#Reproduction" />
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#Distribution" />
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
+ </cc:License>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer">
+ <path
+ style="fill:#303030"
+ d="M 22.9375,3.0058594 C 15.653591,3.2371063 10.824219,6.7870543 10.824219,14.107422 v 7.470703 H 9.1855469 C 7.9827519,21.578125 7,22.41744 7,23.46875 V 43.109375 C 7,44.160685 7.9827519,45.000002 9.1855469,45 H 38.84375 C 40.046563,45 41,44.160684 41,43.109375 V 23.46875 c 0,-1.051308 -0.953437,-1.890625 -2.15625,-1.890625 h -1.667969 l 0.0293,-7.349609 c 0,-7.7707365 -5.240554,-11.1267423 -13.173828,-11.2226566 -0.369866,-0.00453 -0.735515,-0.011424 -1.09375,0 z m 0.728516,4.9101562 c 0.133854,-0.00308 0.287293,0 0.425781,0 8.802152,0 8.12589,6.3440594 8.255859,8.2343754 v 5.427734 H 15.773438 v -5.396484 c -0.03131,-1.875307 -0.545506,-8.0727377 7.892578,-8.2656254 z"
+ id="path2086"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cscssscsssscccccccccccc" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:24px;line-height:125%;font-family:Arial;-inkscape-font-specification:Arial;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ x="23.882812"
+ y="42.305084"
+ id="text4520">C</text>
+ </g>
+</svg>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="48px"
+ height="48px"
+ id="svg11300"
+ sodipodi:version="0.32"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)"
+ sodipodi:docname="indicator-keyboard-led-C-on.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ version="1.1">
+ <defs
+ id="defs8" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1855"
+ inkscape:window-height="1056"
+ id="namedview6"
+ showgrid="false"
+ showguides="false"
+ inkscape:zoom="9.8333333"
+ inkscape:cx="8.4441852"
+ inkscape:cy="20.424683"
+ inkscape:window-x="65"
+ inkscape:window-y="24"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="layer1" />
+ <metadata
+ id="metadata4">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:creator>
+ <dc:Agent>
+ <dc:title>Jakub Steiner</dc:title>
+ </dc:Agent>
+ </dc:creator>
+ <dc:contributor>Adrian I Lam</dc:contributor>
+ <dc:source>http://jimmac.musichall.cz</dc:source>
+ <cc:license
+ rdf:resource="http://creativecommons.org/licenses/publicdomain/" />
+ <dc:title></dc:title>
+ <dc:subject>caps lock</dc:subject>
+ </cc:Work>
+ <cc:License
+ rdf:about="http://creativecommons.org/licenses/publicdomain/">
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#Reproduction" />
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#Distribution" />
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
+ </cc:License>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer">
+ <path
+ style="fill:#dfdbd2"
+ d="M 22.9375,3.0058594 C 15.653591,3.2371063 10.824219,6.7870543 10.824219,14.107422 v 7.470703 H 9.1855469 C 7.9827519,21.578125 7,22.41744 7,23.46875 V 43.109375 C 7,44.160685 7.9827519,45.000002 9.1855469,45 H 38.84375 C 40.046563,45 41,44.160684 41,43.109375 V 23.46875 c 0,-1.051308 -0.953437,-1.890625 -2.15625,-1.890625 h -1.667969 l 0.0293,-7.349609 c 0,-7.7707365 -5.240554,-11.1267423 -13.173828,-11.2226566 -0.369866,-0.00453 -0.735515,-0.011424 -1.09375,0 z m 0.728516,4.9101562 c 0.133854,-0.00308 0.287293,0 0.425781,0 8.802152,0 8.12589,6.3440594 8.255859,8.2343754 v 5.427734 H 15.773438 v -5.396484 c -0.03131,-1.875307 -0.545506,-8.0727377 7.892578,-8.2656254 z"
+ id="path2086"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cscssscsssscccccccccccc" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:24px;line-height:125%;font-family:Arial;-inkscape-font-specification:Arial;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ x="23.882812"
+ y="42.305084"
+ id="text4520">C</text>
+ </g>
+</svg>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="48px"
+ height="48px"
+ id="svg11300"
+ sodipodi:version="0.32"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)"
+ sodipodi:docname="indicator-keyboard-led-N-on.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ version="1.1">
+ <defs
+ id="defs8" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1855"
+ inkscape:window-height="1056"
+ id="namedview6"
+ showgrid="false"
+ showguides="false"
+ inkscape:zoom="9.8333333"
+ inkscape:cx="8.4441852"
+ inkscape:cy="20.424683"
+ inkscape:window-x="65"
+ inkscape:window-y="24"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="layer1" />
+ <metadata
+ id="metadata4">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:creator>
+ <dc:Agent>
+ <dc:title>Jakub Steiner</dc:title>
+ </dc:Agent>
+ </dc:creator>
+ <dc:contributor>Adrian I Lam</dc:contributor>
+ <dc:source>http://jimmac.musichall.cz</dc:source>
+ <cc:license
+ rdf:resource="http://creativecommons.org/licenses/publicdomain/" />
+ <dc:title>Caps Lock icon</dc:title>
+ <dc:subject>caps lock</dc:subject>
+ </cc:Work>
+ <cc:License
+ rdf:about="http://creativecommons.org/licenses/publicdomain/">
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#Reproduction" />
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#Distribution" />
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
+ </cc:License>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer">
+ <path
+ style="fill:#303030"
+ d="M 22.9375,3.0058594 C 15.653591,3.2371063 10.824219,6.7870543 10.824219,14.107422 v 7.470703 H 9.1855469 C 7.9827519,21.578125 7,22.41744 7,23.46875 V 43.109375 C 7,44.160685 7.9827519,45.000002 9.1855469,45 H 38.84375 C 40.046563,45 41,44.160684 41,43.109375 V 23.46875 c 0,-1.051308 -0.953437,-1.890625 -2.15625,-1.890625 h -1.667969 l 0.0293,-7.349609 c 0,-7.7707365 -5.240554,-11.1267423 -13.173828,-11.2226566 -0.369866,-0.00453 -0.735515,-0.011424 -1.09375,0 z m 0.728516,4.9101562 c 0.133854,-0.00308 0.287293,0 0.425781,0 8.802152,0 8.12589,6.3440594 8.255859,8.2343754 v 5.427734 H 15.773438 v -5.396484 c -0.03131,-1.875307 -0.545506,-8.0727377 7.892578,-8.2656254 z"
+ id="path2086"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cscssscsssscccccccccccc" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:24px;line-height:125%;font-family:Arial;-inkscape-font-specification:Arial;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ x="23.882812"
+ y="42.305084"
+ id="text4520">N</text>
+ </g>
+</svg>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="48px"
+ height="48px"
+ id="svg11300"
+ sodipodi:version="0.32"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)"
+ sodipodi:docname="indicator-keyboard-led-N-on.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ version="1.1">
+ <defs
+ id="defs8" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1855"
+ inkscape:window-height="1056"
+ id="namedview6"
+ showgrid="false"
+ showguides="false"
+ inkscape:zoom="9.8333333"
+ inkscape:cx="8.4441852"
+ inkscape:cy="20.424683"
+ inkscape:window-x="65"
+ inkscape:window-y="24"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="layer1" />
+ <metadata
+ id="metadata4">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:creator>
+ <dc:Agent>
+ <dc:title>Jakub Steiner</dc:title>
+ </dc:Agent>
+ </dc:creator>
+ <dc:contributor>Adrian I Lam</dc:contributor>
+ <dc:source>http://jimmac.musichall.cz</dc:source>
+ <cc:license
+ rdf:resource="http://creativecommons.org/licenses/publicdomain/" />
+ <dc:title>Caps Lock icon</dc:title>
+ <dc:subject>caps lock</dc:subject>
+ </cc:Work>
+ <cc:License
+ rdf:about="http://creativecommons.org/licenses/publicdomain/">
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#Reproduction" />
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#Distribution" />
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
+ </cc:License>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer">
+ <path
+ style="fill:#dfdbd2"
+ d="M 22.9375,3.0058594 C 15.653591,3.2371063 10.824219,6.7870543 10.824219,14.107422 v 7.470703 H 9.1855469 C 7.9827519,21.578125 7,22.41744 7,23.46875 V 43.109375 C 7,44.160685 7.9827519,45.000002 9.1855469,45 H 38.84375 C 40.046563,45 41,44.160684 41,43.109375 V 23.46875 c 0,-1.051308 -0.953437,-1.890625 -2.15625,-1.890625 h -1.667969 l 0.0293,-7.349609 c 0,-7.7707365 -5.240554,-11.1267423 -13.173828,-11.2226566 -0.369866,-0.00453 -0.735515,-0.011424 -1.09375,0 z m 0.728516,4.9101562 c 0.133854,-0.00308 0.287293,0 0.425781,0 8.802152,0 8.12589,6.3440594 8.255859,8.2343754 v 5.427734 H 15.773438 v -5.396484 c -0.03131,-1.875307 -0.545506,-8.0727377 7.892578,-8.2656254 z"
+ id="path2086"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cscssscsssscccccccccccc" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:24px;line-height:125%;font-family:Arial;-inkscape-font-specification:Arial;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ x="23.882812"
+ y="42.305084"
+ id="text4520">N</text>
+ </g>
+</svg>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="48px"
+ height="48px"
+ id="svg11300"
+ sodipodi:version="0.32"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)"
+ sodipodi:docname="indicator-keyboard-led-S-on.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ version="1.1">
+ <defs
+ id="defs8" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1855"
+ inkscape:window-height="1056"
+ id="namedview6"
+ showgrid="false"
+ showguides="false"
+ inkscape:zoom="9.8333333"
+ inkscape:cx="8.4441852"
+ inkscape:cy="20.424683"
+ inkscape:window-x="65"
+ inkscape:window-y="24"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="layer1" />
+ <metadata
+ id="metadata4">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:creator>
+ <dc:Agent>
+ <dc:title>Jakub Steiner</dc:title>
+ </dc:Agent>
+ </dc:creator>
+ <dc:contributor>Adrian I Lam</dc:contributor>
+ <dc:source>http://jimmac.musichall.cz</dc:source>
+ <cc:license
+ rdf:resource="http://creativecommons.org/licenses/publicdomain/" />
+ <dc:title></dc:title>
+ <dc:subject>caps lock</dc:subject>
+ </cc:Work>
+ <cc:License
+ rdf:about="http://creativecommons.org/licenses/publicdomain/">
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#Reproduction" />
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#Distribution" />
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
+ </cc:License>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer">
+ <path
+ style="fill:#303030"
+ d="M 22.9375,3.0058594 C 15.653591,3.2371063 10.824219,6.7870543 10.824219,14.107422 v 7.470703 H 9.1855469 C 7.9827519,21.578125 7,22.41744 7,23.46875 V 43.109375 C 7,44.160685 7.9827519,45.000002 9.1855469,45 H 38.84375 C 40.046563,45 41,44.160684 41,43.109375 V 23.46875 c 0,-1.051308 -0.953437,-1.890625 -2.15625,-1.890625 h -1.667969 l 0.0293,-7.349609 c 0,-7.7707365 -5.240554,-11.1267423 -13.173828,-11.2226566 -0.369866,-0.00453 -0.735515,-0.011424 -1.09375,0 z m 0.728516,4.9101562 c 0.133854,-0.00308 0.287293,0 0.425781,0 8.802152,0 8.12589,6.3440594 8.255859,8.2343754 v 5.427734 H 15.773438 v -5.396484 c -0.03131,-1.875307 -0.545506,-8.0727377 7.892578,-8.2656254 z"
+ id="path2086"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cscssscsssscccccccccccc" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:24px;line-height:125%;font-family:Arial;-inkscape-font-specification:Arial;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ x="23.882812"
+ y="42.305084"
+ id="text4520">S</text>
+ </g>
+</svg>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="48px"
+ height="48px"
+ id="svg11300"
+ sodipodi:version="0.32"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)"
+ sodipodi:docname="indicator-keyboard-led-S-on.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ version="1.1">
+ <defs
+ id="defs8" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1855"
+ inkscape:window-height="1056"
+ id="namedview6"
+ showgrid="false"
+ showguides="false"
+ inkscape:zoom="9.8333333"
+ inkscape:cx="8.4441852"
+ inkscape:cy="20.424683"
+ inkscape:window-x="65"
+ inkscape:window-y="24"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="layer1" />
+ <metadata
+ id="metadata4">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:creator>
+ <dc:Agent>
+ <dc:title>Jakub Steiner</dc:title>
+ </dc:Agent>
+ </dc:creator>
+ <dc:contributor>Adrian I Lam</dc:contributor>
+ <dc:source>http://jimmac.musichall.cz</dc:source>
+ <cc:license
+ rdf:resource="http://creativecommons.org/licenses/publicdomain/" />
+ <dc:title></dc:title>
+ <dc:subject>caps lock</dc:subject>
+ </cc:Work>
+ <cc:License
+ rdf:about="http://creativecommons.org/licenses/publicdomain/">
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#Reproduction" />
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#Distribution" />
+ <cc:permits
+ rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
+ </cc:License>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer">
+ <path
+ style="fill:#dfdbd2"
+ d="M 22.9375,3.0058594 C 15.653591,3.2371063 10.824219,6.7870543 10.824219,14.107422 v 7.470703 H 9.1855469 C 7.9827519,21.578125 7,22.41744 7,23.46875 V 43.109375 C 7,44.160685 7.9827519,45.000002 9.1855469,45 H 38.84375 C 40.046563,45 41,44.160684 41,43.109375 V 23.46875 c 0,-1.051308 -0.953437,-1.890625 -2.15625,-1.890625 h -1.667969 l 0.0293,-7.349609 c 0,-7.7707365 -5.240554,-11.1267423 -13.173828,-11.2226566 -0.369866,-0.00453 -0.735515,-0.011424 -1.09375,0 z m 0.728516,4.9101562 c 0.133854,-0.00308 0.287293,0 0.425781,0 8.802152,0 8.12589,6.3440594 8.255859,8.2343754 v 5.427734 H 15.773438 v -5.396484 c -0.03131,-1.875307 -0.545506,-8.0727377 7.892578,-8.2656254 z"
+ id="path2086"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cscssscsssscccccccccccc" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:24px;line-height:125%;font-family:Arial;-inkscape-font-specification:Arial;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ x="23.882812"
+ y="42.305084"
+ id="text4520">S</text>
+ </g>
+</svg>
Name=indicator-keyboard-led
Type=Application
Exec=/usr/bin/indicator-keyboard-led.py
-Icon=indicator-keyboard-led
+Icon=indicator-keyboard-led-C-on
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
# -*- coding: utf-8 -*-
#
# indicator-keyboard-led - simulate keyboard lock keys LED
-# Copyright (c) 2017 Adrian I Lam <me@adrianiainlam.tk>
+# Copyright (c) 2017-2023 Adrian I Lam <spam@adrianiainlam.tk> s/spam/me/
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
from gi.repository import Gdk, Gtk, AppIndicator3
APP_NAME = 'indicator-keyboard-led'
-APP_VERSION = '1.1'
+APP_VERSION = '1.2'
-ICON_LOCATION = '/usr/share/icons/hicolor/scalable/apps/' + APP_NAME + '.svg'
+ICON_FOLDER = '/usr/share/icons/hicolor/scalable/apps/'
import gettext
t = gettext.translation(APP_NAME, '/usr/share/locale')
_ = t.gettext
class IndicatorKeyboardLED:
- def __init__(self, short=False, order='NCS', xdotool=None):
+ def __init__(self, order='NCS', xdotool=None):
self.validate_order(order)
- self.indicator = AppIndicator3.Indicator.new(
- APP_NAME, ICON_LOCATION,
- AppIndicator3.IndicatorCategory.APPLICATION_STATUS)
- self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
+ self.indicators = {}
- if short:
- self.locks = { 'N': _('N'), 'C': _('C'), 'S': _('S') }
- else:
- self.locks = { 'N': _('Num'), 'C': _('Caps'), 'S': _('Scroll') }
+ count = 0
+ for i in order:
+ self.indicators[i] = AppIndicator3.Indicator.new(
+ '-'.join([APP_NAME, str(count), i]),
+ os.path.join(ICON_FOLDER, '-'.join([APP_NAME, i, 'off.svg'])),
+ AppIndicator3.IndicatorCategory.APPLICATION_STATUS)
+ self.indicators[i].set_status(AppIndicator3.IndicatorStatus.ACTIVE)
+
+ count += 1
keymap = Gdk.Keymap.get_default()
keymap.connect('state-changed', self.update_indicator, order)
self.create_menu(xdotool, order)
def create_menu(self, xdotool, order):
- menu = Gtk.Menu()
xdotool = xdotool or shutil.which('xdotool')
- if xdotool and os.access(xdotool, os.X_OK) and os.path.isfile(xdotool):
- def send_keypress(menuitem, keystroke):
- subprocess.call([xdotool, 'key', keystroke])
- def new_menu_item(itemtype):
- if itemtype == 'N':
- item = Gtk.MenuItem.new_with_label(_('Num Lock'))
- item.connect('activate', send_keypress, 'Num_Lock')
- elif itemtype == 'C':
- item = Gtk.MenuItem.new_with_label(_('Caps Lock'))
- item.connect('activate', send_keypress, 'Caps_Lock')
- elif itemtype == 'S':
- item = Gtk.MenuItem.new_with_label(_('Scroll Lock'))
- item.connect('activate', send_keypress, 'Scroll_Lock')
- else:
- raise ValueError('Invalid itemtype')
- return item
-
- for i in order:
+ def send_keypress(menuitem, keystroke):
+ subprocess.call([xdotool, 'key', keystroke])
+ def new_menu_item(itemtype):
+ if itemtype == 'N':
+ item = Gtk.MenuItem.new_with_label(_('Num Lock'))
+ item.connect('activate', send_keypress, 'Num_Lock')
+ elif itemtype == 'C':
+ item = Gtk.MenuItem.new_with_label(_('Caps Lock'))
+ item.connect('activate', send_keypress, 'Caps_Lock')
+ elif itemtype == 'S':
+ item = Gtk.MenuItem.new_with_label(_('Scroll Lock'))
+ item.connect('activate', send_keypress, 'Scroll_Lock')
+ else:
+ raise ValueError('Invalid itemtype')
+ return item
+
+ for i in order:
+ menu = Gtk.Menu()
+
+ if xdotool and os.access(xdotool, os.X_OK) and os.path.isfile(xdotool):
menu.append(new_menu_item(i))
- menu.append(Gtk.SeparatorMenuItem())
- quit_item = Gtk.MenuItem.new_with_label(_('Quit'))
- menu.append(quit_item)
- quit_item.connect('activate', Gtk.main_quit)
+ quit_item = Gtk.MenuItem.new_with_label(_('Quit'))
+ menu.append(quit_item)
+ quit_item.connect('activate', Gtk.main_quit)
- self.indicator.set_menu(menu)
- menu.show_all()
+ self.indicators[i].set_menu(menu)
+ menu.show_all()
def update_indicator(self, keymap, order):
- labels = []
for i in order:
if i == 'N':
state = keymap.get_num_lock_state()
state = keymap.get_scroll_lock_state()
else:
raise ValueError('Invalid value in ORDER')
- labels += [('⚫' if state else '⚪') + self.locks[i]]
- self.indicator.set_label(' '.join(labels), '')
+
+ icon = os.path.join(ICON_FOLDER, '-'.join([APP_NAME, i, 'on.svg' if state else 'off.svg']))
+ self.indicators[i].set_icon(icon)
+
def validate_order(self, order):
order = order.upper()
parser = argparse.ArgumentParser(
description='indicator-keyboard-led - simulate keyboard lock keys LED',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
- parser.add_argument('-s', '--short', required=False, action='store_true',
- help='use short label, i.e. ⚫N ⚫C ⚫S instead of ⚫Num ⚫Caps ⚫Scroll')
parser.add_argument('-o', '--order', required=False, default='NCS',
help='specify the order of the locks displayed, e.g. CSN for '
- '⚫Caps ⚫Scroll ⚫Num, or NC for ⚫Num ⚫Caps without Scroll lock')
+ 'Caps Scroll Num, or NC for Num Caps without Scroll lock')
parser.add_argument('-x', '--xdotool', required=False,
help='provide full path to xdotool executable, '
'e.g. "/usr/bin/xdotool"; '
'if not specified, search in PATH')
args = parser.parse_args()
- IndicatorKeyboardLED(short=args.short, order=args.order,
+ IndicatorKeyboardLED(order=args.order,
xdotool=args.xdotool)
Gtk.main()
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="48px"
- height="48px"
- id="svg11300"
- sodipodi:version="0.32"
- inkscape:version="0.91 r13725"
- sodipodi:docname="icon.svg"
- inkscape:output_extension="org.inkscape.output.svg.inkscape"
- version="1.1">
- <metadata
- id="metadata4">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:creator>
- <dc:Agent>
- <dc:title>Jakub Steiner</dc:title>
- </dc:Agent>
- </dc:creator>
- <dc:contributor>Adrian I Lam</dc:contributor>
- <dc:source>http://jimmac.musichall.cz</dc:source>
- <cc:license
- rdf:resource="http://creativecommons.org/licenses/publicdomain/" />
- <dc:title>Caps Lock icon</dc:title>
- <dc:subject>caps lock</dc:subject>
- </cc:Work>
- <cc:License
- rdf:about="http://creativecommons.org/licenses/publicdomain/">
- <cc:permits
- rdf:resource="http://creativecommons.org/ns#Reproduction" />
- <cc:permits
- rdf:resource="http://creativecommons.org/ns#Distribution" />
- <cc:permits
- rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
- </cc:License>
- </rdf:RDF>
- </metadata>
- <g
- id="layer1"
- inkscape:label="Layer 1"
- inkscape:groupmode="layer">
- <path
- style="fill:#dfdbd2;"
- d="M 22.9375 3.0058594 C 15.653591 3.2371063 10.824219 6.7870543
- 10.824219 14.107422 L 10.824219 21.578125 L 9.1855469 21.578125 C
- 7.9827519 21.578125 7 22.41744 7 23.46875 L 7 43.109375 C 7 44.160685
- 7.9827519 45.000002 9.1855469 45 L 38.84375 45 C 40.046563 45 41
- 44.160684 41 43.109375 L 41 23.46875 C 41 22.417442 40.046563
- 21.578125 38.84375 21.578125 L 37.175781 21.578125 L 37.205078
- 14.228516 C 37.205078 6.4577795 31.964524 3.1017737 24.03125
- 3.0058594 C 23.661384 3.0013294 23.295735 2.9944354 22.9375 3.0058594
- z M 23.666016 7.9160156 C 23.79987 7.9129356 23.953309 7.9160156
- 24.091797 7.9160156 C 32.893949 7.9160156 32.217687 14.260075
- 32.347656 16.150391 L 32.347656 21.578125 L 15.773438 21.578125 L
- 15.773438 16.181641 C 15.742128 14.306334 15.227932 8.1089033
- 23.666016 7.9160156 z M 22.21875 24 L 25.75 24 C 26.442384 25.281385
- 27.114759 26.580467 27.767578 27.896484 C 28.420397 29.212502
- 29.073744 30.598189 29.726562 32.052734 C 30.399164 33.50728
- 31.083007 35.048076 31.775391 36.675781 C 32.487557 38.303487
- 33.228487 40.077922 34 42 L 29.964844 42 C 29.68789 41.290043
- 29.400252 40.589125 29.103516 39.896484 C 28.80678 39.203844
- 28.521094 38.492898 28.244141 37.765625 L 19.578125 37.765625 C
- 19.301171 38.492898 19.015486 39.211918 18.71875 39.921875 L
- 17.886719 42 L 14 42 C 14.771513 40.077922 15.502929 38.303487
- 16.195312 36.675781 C 16.887696 35.048076 17.560072 33.50728
- 18.212891 32.052734 C 18.885492 30.598189 19.548353 29.212502
- 20.201172 27.896484 C 20.853991 26.580467 21.526366 25.281385
- 22.21875 24 z M 23.910156 27.480469 C 23.455161 28.398218 22.931362
- 29.516014 22.337891 30.832031 C 21.764201 32.148049 21.16038
- 33.576062 20.527344 35.117188 L 27.292969 35.117188 C 26.659932
- 33.576062 26.046597 32.138021 25.453125 30.804688 C 24.859653
- 29.471354 24.345369 28.363586 23.910156 27.480469 z "
- id="path2086" />
- </g>
-</svg>