diff options
author | nicolargo <nicolas@nicolargo.com> | 2021-07-24 17:56:50 +0200 |
---|---|---|
committer | nicolargo <nicolas@nicolargo.com> | 2021-07-24 17:56:50 +0200 |
commit | 1b549041fc1f81115abcf9ba57e347fbda114892 (patch) | |
tree | a8ec88c57b3f366a6ce9d3dce6d3e21487c51480 | |
parent | 5c0540ee9a8d5a0c831e1899e085f6eee4121d9f (diff) |
[3.2.0/3.2.1] keybinding not working anymore #1904
-rw-r--r-- | glances/outputs/glances_curses.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/glances/outputs/glances_curses.py b/glances/outputs/glances_curses.py index e968c420..38bde0cf 100644 --- a/glances/outputs/glances_curses.py +++ b/glances/outputs/glances_curses.py @@ -351,14 +351,19 @@ class _GlancesCurses(object): logger.debug("Keypressed (code: {})".format(self.pressedkey)) for hotkey in self._hotkeys: if self.pressedkey == ord(hotkey) and 'switch' in self._hotkeys[hotkey]: - if self._hotkeys[hotkey]['switch'].startswith('enable_') or \ - self._hotkeys[hotkey]['switch'].startswith('disable_'): - # Enable / Disable switch - # Get the option name - # Ex: disable_foo return foo - # enable_foo_bar return foo_bar - option = '_'.join( - self._hotkeys[hotkey]['switch'].split('_')[1:]) + # Get the option name + # Ex: disable_foo return foo + # enable_foo_bar return foo_bar + option = '_'.join(self._hotkeys[hotkey]['switch'].split('_')[1:]) + if self._hotkeys[hotkey]['switch'].startswith('disable_'): + # disable_ switch + if getattr(self.args, + self._hotkeys[hotkey]['switch']): + enable(self.args, option) + else: + disable(self.args, option) + elif self._hotkeys[hotkey]['switch'].startswith('enable_'): + # enable_ switch if getattr(self.args, self._hotkeys[hotkey]['switch']): disable(self.args, option) |