From ebd98663c6467d01ec5385e915b2afd73cf8c412 Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Thu, 28 May 2020 20:58:56 +0200 Subject: [PATCH] [modules/vault] fix copy of wrong password - fix bad errors (missing "show" in pass command) - pass in whole environment (otherwise clipboard doesn't work) - generate lambda to avoid late binding fixes #593 --- bumblebee_status/modules/core/vault.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bumblebee_status/modules/core/vault.py b/bumblebee_status/modules/core/vault.py index 92e5ba6..d4b6a8d 100644 --- a/bumblebee_status/modules/core/vault.py +++ b/bumblebee_status/modules/core/vault.py @@ -32,6 +32,9 @@ import util.cli import util.popup +def generate_callback(callback, path, name): + return lambda: callback(os.path.join(path, name)) + def build_menu(parent, current_directory, callback): with os.scandir(current_directory) as it: for entry in it: @@ -41,7 +44,7 @@ def build_menu(parent, current_directory, callback): name = entry.name[: entry.name.rfind(".")] parent.add_menuitem( name, - callback=lambda: callback(os.path.join(current_directory, name)), + callback=generate_callback(callback, current_directory, name), ) else: @@ -79,10 +82,12 @@ class Module(core.module.Module): secret_name = secret_name.replace(self.__path, "") # remove common path if self.__timer: self.__timer.cancel() + env = os.environ + env["PASSWORD_STORE_CLIP_TIME"] = str(self.__duration) res = util.cli.execute( - "pass -c {}".format(secret_name), + "pass show -c {}".format(secret_name), wait=False, - env={"PASSWORD_STORE_CLIP_TIME": self.__duration}, + env=env, ) self.__timer = threading.Timer(self.__duration, self.__reset) self.__timer.start()