[util/cli] fix CLI invokation for sway

in sway/wayland, make sure that the wayland socket is cleared, which
seems to cause issue for some unspecified reason.

also, while at it, improve code so that the environment dict that is
passed in is *not* modified.

fixes #628
This commit is contained in:
tobi-wan-kenobi 2020-06-28 10:44:30 +02:00
parent 350648b0cd
commit fc8783ee13

View file

@ -33,14 +33,19 @@ def execute(
if not env: if not env:
env = os.environ.copy() env = os.environ.copy()
env["LC_ALL"] = "C"
myenv = env.copy()
myenv["LC_ALL"] = "C"
if "WAYLAND_SOCKET" in myenv:
del myenv["WAYLAND_SOCKET"]
try: try:
proc = subprocess.Popen( proc = subprocess.Popen(
args, args,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT if include_stderr else subprocess.PIPE, stderr=subprocess.STDOUT if include_stderr else subprocess.PIPE,
env=env, env=myenv,
shell=shell, shell=shell,
) )
except FileNotFoundError as e: except FileNotFoundError as e: