From f32affa563735a64466015ed543cc384531efa85 Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Mon, 6 Apr 2020 08:23:17 +0200 Subject: [PATCH] [modules/shell] Fix missing trim of output string Remove starting/trailing whitespaces, \n etc. fixes #592 --- modules/contrib/shell.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/contrib/shell.py b/modules/contrib/shell.py index 9b4c236..2c0ac60 100644 --- a/modules/contrib/shell.py +++ b/modules/contrib/shell.py @@ -37,7 +37,7 @@ class Module(core.module.Module): def __init__(self, config): super().__init__(config, core.widget.Widget(self.get_output)) - self.__command = self.parameter('command') + self.__command = self.parameter('command', 'echo "no command configured"') self.__async = util.format.asbool(self.parameter('async')) if self.__async: @@ -57,7 +57,7 @@ class Module(core.module.Module): def update(self): # if requested then run not async version and just execute command in this thread if not self.__async: - self.__output = util.cli.execute(self.__command, ignore_errors=True) + self.__output = util.cli.execute(self.__command, ignore_errors=True).strip() return # if previous thread didn't end yet then don't do anything @@ -71,4 +71,8 @@ class Module(core.module.Module): ) self.__current_thread.start() + def state(self, _): + if self.__output == 'no command configured': + return 'warning' + # vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4