From 05d70532edfb78732fc56fe4a84c0705761a84ed Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Thu, 14 May 2009 17:23:56 +0100 Subject: [PATCH] When running in command mode, config checker now checks to see if the button has a valid command, if not, remove the button. --- oblogout/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/oblogout/__init__.py b/oblogout/__init__.py index b3b5662..6540755 100644 --- a/oblogout/__init__.py +++ b/oblogout/__init__.py @@ -223,7 +223,9 @@ class OpenboxLogout(): for key in self.parser.items("commands"): self.logger.debug("Setting cmd_%s as %s" % (key[0], key[1])) if key[1] in ['logout', 'restart', 'shutdown', 'suspend', 'hibernate', 'safesuspend', 'lock', 'switch']: - if key[1]: setattr(self, "cmd_" + key[0], key[1]) + if key[1]: + self.logger.debug("Setting cmd_%s as %s" % (key[0], key[1])) + setattr(self, "cmd_" + key[0], key[1]) # Load theme information from local directory if local mode is set if self.local_mode: @@ -264,6 +266,13 @@ class OpenboxLogout(): if not self.dbus.check_ability(button): self.logger.warning(_("Can't %s, disabling button" % button)) list.remove(button) + else: + try: + if button != "cancel" and getattr(self, "cmd_" + button) == "None": + list.remove(button) + except: + self.logger.warning(_("Command for button %s is undefined, removing." % button)) + list.remove(button) if len(list) == 0: self.logger.warning(_("No valid buttons found, resetting to defaults"))