-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplayplacer-wrapper
More file actions
executable file
·60 lines (49 loc) · 1.13 KB
/
displayplacer-wrapper
File metadata and controls
executable file
·60 lines (49 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env -S uv --quiet run --no-project --script --
# https://peps.python.org/pep-0723/
# https://github.com/astral-sh/uv
# /// script
# # Docopt issues SyntaxWarning in Python 3.12
# requires-python = ">=3.11,<3.12"
# dependencies = [
# "docopt >=0.6.2",
# ]
# ///
"""
Usage:
{prog}
"""
import sys, locale, os, subprocess, shlex
import docopt
def main(*, args, prog):
locale.setlocale(locale.LC_ALL, "")
params = docopt.docopt(
__doc__.replace("\t", " " * 4).format(prog=os.path.basename(prog)),
argv=args,
help=True,
version=True,
options_first=False
)
assert not params, params
p = subprocess.run(
["displayplacer", "list"],
shell=False,
check=True,
capture_output=True,
encoding="ASCII",
)
lines = [l for l in p.stdout.splitlines() if l.startswith("displayplacer \"")]
assert len(lines) == 1, lines
displayplacer_args = shlex.split(lines[0])[1:]
print("\n".join(displayplacer_args))
def smain(argv=None):
if argv is None:
argv = sys.argv
try:
return main(
args=argv[1:],
prog=argv[0]
)
except KeyboardInterrupt:
print(file=sys.stderr)
if __name__ == "__main__":
sys.exit(smain())