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:
|
if self.background_path is None:
|
||||||
return {}
|
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 == "*":
|
if self.match == "*":
|
||||||
key = "any"
|
key = "any"
|
||||||
|
|
||||||
|
@ -234,6 +236,35 @@ def main():
|
||||||
|
|
||||||
host_config = cattrs.structure(host_toml, HostConfig)
|
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:
|
for output in host_config.outputs:
|
||||||
# Attempt to resolve port names for swaylock template
|
# Attempt to resolve port names for swaylock template
|
||||||
# (Workaround https://github.com/swaywm/swaylock/issues/114)
|
# (Workaround https://github.com/swaywm/swaylock/issues/114)
|
||||||
|
@ -243,37 +274,10 @@ def main():
|
||||||
if output.match == "*":
|
if output.match == "*":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
for haystack, port in output_map:
|
||||||
if "SWAYSOCK" in os.environ:
|
if output.match in haystack:
|
||||||
get_outputs = subprocess.check_output(
|
output.port = port
|
||||||
["swaymsg", "-t", "get_outputs", "-p"],
|
break
|
||||||
).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.")
|
|
||||||
|
|
||||||
jenv = jinja2.Environment(
|
jenv = jinja2.Environment(
|
||||||
loader=jinja2.FileSystemLoader("templates"),
|
loader=jinja2.FileSystemLoader("templates"),
|
||||||
|
|
Loading…
Add table
Reference in a new issue