Skip to content

Commit

Permalink
Merge pull request #1006 from alexveden/main
Browse files Browse the repository at this point in the history
Layout: highlights when layout is not in default state
  • Loading branch information
tobi-wan-kenobi authored Dec 10, 2023
2 parents cde251e + e9bf04b commit f0324bd
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion bumblebee_status/modules/contrib/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
Requires the following executable:
* setxkbmap
Parameters:
* layout.highlight_if_not: Highlights layout indicator if current layout is not default value given by this parameter. Defaults to "" (no highlighting), `us` - highlights any non `us` layout.
contributed by `Pseudonick47 <https://github.com/Pseudonick47>`_ - many thanks!
contributed by `alexveden` <https://github.com/alexveden/>`_ - many thanks!
"""

import core.module
Expand All @@ -17,10 +21,12 @@

class Module(core.module.Module):
def __init__(self, config, theme):
self.__current_layout = ""
super().__init__(config, theme, core.widget.Widget(self.current_layout))

core.input.register(self, button=core.input.LEFT_MOUSE, cmd=self.__next_keymap)
core.input.register(self, button=core.input.RIGHT_MOUSE, cmd=self.__prev_keymap)
self.__highlight_if_not = self.parameter("highlight_if_not", "").strip()

def __next_keymap(self, event):
self._set_keymap(1)
Expand Down Expand Up @@ -72,7 +78,12 @@ def get_layouts(self):

def current_layout(self, widget):
layouts = self.get_layouts()
return layouts[0]
self.__current_layout = layouts[0].strip()
return self.__current_layout

def state(self, widget):
if self.__highlight_if_not:
if self.__current_layout != self.__highlight_if_not:
return "warning"

# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

0 comments on commit f0324bd

Please sign in to comment.