fix wpaperd ports; only query compositor for outputs one time
This commit is contained in:
parent
7de71dd986
commit
a4c9f59091
1 changed files with 36 additions and 32 deletions
68
install.py
68
install.py
|
@ -131,7 +131,9 @@ class OutputConfig:
|
|||
if self.background_path is None:
|
||||
return {}
|
||||
|
||||
key = self.match
|
||||
# FIXME: output descriptions _should_ work?
|
||||
# https://github.com/danyspin97/wpaperd/pull/97
|
||||
key = self.port or self.match
|
||||
if self.match == "*":
|
||||
key = "any"
|
||||
|
||||
|
@ -234,6 +236,35 @@ def main():
|
|||
|
||||
host_config = cattrs.structure(host_toml, HostConfig)
|
||||
|
||||
output_map = []
|
||||
try:
|
||||
if "SWAYSOCK" in os.environ:
|
||||
get_outputs = subprocess.check_output(
|
||||
["swaymsg", "-t", "get_outputs", "-p"],
|
||||
).decode("utf-8")
|
||||
for line in get_outputs.splitlines():
|
||||
# Line format: Output <port> '<match identifier>'
|
||||
if line.startswith("Output"):
|
||||
output_map.append((line, line.split()[1]))
|
||||
|
||||
elif "NIRI_SOCKET" in os.environ:
|
||||
get_outputs = subprocess.check_output(
|
||||
["niri", "msg", "outputs"],
|
||||
).decode("utf-8")
|
||||
for line in get_outputs.splitlines():
|
||||
# Line format: Output "<match identifier>" (<port>)
|
||||
if line.startswith("Output"):
|
||||
output_map.append((line, line.split()[-1].removeprefix("(").removesuffix(")")))
|
||||
else:
|
||||
print(
|
||||
"Could not find SWAYSOCK or NIRI_SOCKET, cannot retrieve output names."
|
||||
)
|
||||
print("Please re-run in sway or niri to finish configuring swaylock.")
|
||||
|
||||
except subprocess.CalledProcessError:
|
||||
print("Could not contact sway or niri to retrieve output names.")
|
||||
print("Please re-run in sway or niri to finish configuring swaylock.")
|
||||
|
||||
for output in host_config.outputs:
|
||||
# Attempt to resolve port names for swaylock template
|
||||
# (Workaround https://github.com/swaywm/swaylock/issues/114)
|
||||
|
@ -243,37 +274,10 @@ def main():
|
|||
if output.match == "*":
|
||||
continue
|
||||
|
||||
try:
|
||||
if "SWAYSOCK" in os.environ:
|
||||
get_outputs = subprocess.check_output(
|
||||
["swaymsg", "-t", "get_outputs", "-p"],
|
||||
).decode("utf-8")
|
||||
for line in get_outputs.splitlines():
|
||||
# Line format: Output <port> '<match identifier>'
|
||||
if line.startswith("Output") and output.match in line:
|
||||
output.port = line.split()[1]
|
||||
break
|
||||
|
||||
elif "NIRI_SOCKET" in os.environ:
|
||||
get_outputs = subprocess.check_output(
|
||||
["niri", "msg", "outputs"],
|
||||
).decode("utf-8")
|
||||
for line in get_outputs.splitlines():
|
||||
# Line format: Output "<match identifier>" (<port>)
|
||||
if line.startswith("Output") and output.match in line:
|
||||
output.port = (
|
||||
line.split()[-1].removeprefix("(").removesuffix(")")
|
||||
)
|
||||
break
|
||||
else:
|
||||
print(
|
||||
"Could not find SWAYSOCK or NIRI_SOCKET, cannot retrieve output names."
|
||||
)
|
||||
print("Please re-run in sway or niri to finish configuring swaylock.")
|
||||
|
||||
except subprocess.CalledProcessError:
|
||||
print("Could not contact sway or niri to retrieve output names.")
|
||||
print("Please re-run in sway or niri to finish configuring swaylock.")
|
||||
for haystack, port in output_map:
|
||||
if output.match in haystack:
|
||||
output.port = port
|
||||
break
|
||||
|
||||
jenv = jinja2.Environment(
|
||||
loader=jinja2.FileSystemLoader("templates"),
|
||||
|
|
Loading…
Add table
Reference in a new issue