[modules/yubikey] Update to new API

This commit is contained in:
tobi-wan-kenobi 2020-04-13 09:40:24 +02:00
parent acc36a41ae
commit bfc3832428
2 changed files with 14 additions and 13 deletions

View file

@ -64,7 +64,6 @@ def main():
core.event.trigger('stop') core.event.trigger('stop')
if __name__ == "__main__": if __name__ == "__main__":
main()
try: try:
main() main()
except Exception as e: except Exception as e:

View file

@ -11,23 +11,25 @@ the corresponding serial number.
import yubico import yubico
import bumblebee.input import core.module
import bumblebee.output import core.widget
import bumblebee.engine import core.decorators
class Module(bumblebee.engine.Module): class Module(core.module.Module):
def __init__(self, engine, config): @core.decorators.every(seconds=1)
super(Module, self).__init__(engine, config, def __init__(self, config):
bumblebee.output.Widget(full_text=self.keystate)) super().__init__(config, core.widget.Widget(self.keystate))
self._keystate = "No YubiKey" self.__keystate = 'No YubiKey'
def keystate(self, widget): def keystate(self, widget):
return self._keystate return self.__keystate
def update(self, widget): def update(self):
try: try:
self._keystate = "YubiKey: " + str(yubico.find_yubikey(debug=False).serial()) self.__keystate = "YubiKey: " + str(yubico.find_yubikey(debug=False).serial())
except yubico.yubico_exception.YubicoError: except yubico.yubico_exception.YubicoError:
self._keystate = "No YubiKey" self.__keystate = "No YubiKey"
except Exception:
self.__keystate = 'n/a'
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4