evo8-linux 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- evo8/__init__.py +3 -0
- evo8/about.py +131 -0
- evo8/alsa.py +77 -0
- evo8/apps.py +76 -0
- evo8/calibrate.py +159 -0
- evo8/cli.py +214 -0
- evo8/data/__init__.py +0 -0
- evo8/data/applications/evo8-mixer.desktop +8 -0
- evo8/data/evo8-mixer.svg +38 -0
- evo8/data/pipewire/pipewire-pulse.conf.d/20-bloquear-volumen-micro.conf +16 -0
- evo8/data/pipewire/pipewire.conf.d/20-mezcla.conf +158 -0
- evo8/data/systemd/evo8-restore.service +8 -0
- evo8/data/udev/70-audient-evo8.rules +7 -0
- evo8/gui/__init__.py +1 -0
- evo8/gui/app.py +92 -0
- evo8/gui/backend.py +485 -0
- evo8/gui/meters.py +86 -0
- evo8/gui/qml/AboutPage.qml +257 -0
- evo8/gui/qml/CardProfiles.qml +118 -0
- evo8/gui/qml/ConsolePage.qml +255 -0
- evo8/gui/qml/Divider.qml +8 -0
- evo8/gui/qml/GlyphButton.qml +30 -0
- evo8/gui/qml/HardwarePage.qml +603 -0
- evo8/gui/qml/HwMixStrip.qml +178 -0
- evo8/gui/qml/Main.qml +139 -0
- evo8/gui/qml/PixelSlider.qml +80 -0
- evo8/gui/qml/Strip.qml +396 -0
- evo8/gui/qml/StripGroup.qml +23 -0
- evo8/gui/qml/Theme.qml +22 -0
- evo8/gui/qml/Tip.qml +20 -0
- evo8/gui/qml/Toggle.qml +41 -0
- evo8/gui/qml/VMeter.qml +28 -0
- evo8/gui/qml/format.js +88 -0
- evo8/gui/qml/qmldir +14 -0
- evo8/gui/snapshot.py +98 -0
- evo8/hw.py +147 -0
- evo8/mix.py +109 -0
- evo8/monitor.py +229 -0
- evo8/profiles.py +112 -0
- evo8/pw.py +164 -0
- evo8/state.py +45 -0
- evo8/usb.py +122 -0
- evo8/user_setup.py +224 -0
- evo8_linux-0.1.0.dist-info/METADATA +198 -0
- evo8_linux-0.1.0.dist-info/RECORD +49 -0
- evo8_linux-0.1.0.dist-info/WHEEL +5 -0
- evo8_linux-0.1.0.dist-info/entry_points.txt +5 -0
- evo8_linux-0.1.0.dist-info/licenses/LICENSE +21 -0
- evo8_linux-0.1.0.dist-info/top_level.txt +1 -0
evo8/pw.py
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"""Thin wrappers over the PipeWire / PulseAudio command-line tools.
|
|
2
|
+
|
|
3
|
+
Everything here shells out (pw-dump, pw-cli, pw-link, pw-metadata, pactl) so
|
|
4
|
+
the package needs no PipeWire bindings and behaves exactly like those tools.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
import os
|
|
11
|
+
import subprocess
|
|
12
|
+
from dataclasses import dataclass, field
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class PwError(RuntimeError):
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def run(*args: str, timeout: float = 5, check: bool = False) -> str:
|
|
20
|
+
env = dict(os.environ, LC_ALL="C")
|
|
21
|
+
try:
|
|
22
|
+
p = subprocess.run(args, capture_output=True, text=True, timeout=timeout, env=env)
|
|
23
|
+
except (OSError, subprocess.TimeoutExpired) as e:
|
|
24
|
+
if check:
|
|
25
|
+
raise PwError(f"{args[0]}: {e}") from e
|
|
26
|
+
return ""
|
|
27
|
+
if check and p.returncode != 0:
|
|
28
|
+
raise PwError(p.stderr.strip() or f"{args[0]} failed ({p.returncode})")
|
|
29
|
+
return p.stdout
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# ---- nodes and params ----
|
|
33
|
+
|
|
34
|
+
def dump(object_id: int | None = None) -> list[dict]:
|
|
35
|
+
out = run("pw-dump", *([str(object_id)] if object_id is not None else []))
|
|
36
|
+
try:
|
|
37
|
+
data = json.loads(out or "[]")
|
|
38
|
+
except json.JSONDecodeError:
|
|
39
|
+
return []
|
|
40
|
+
return data if isinstance(data, list) else []
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def node_id(name: str) -> int | None:
|
|
44
|
+
for obj in dump():
|
|
45
|
+
if obj.get("type") == "PipeWire:Interface:Node" and \
|
|
46
|
+
obj.get("info", {}).get("props", {}).get("node.name") == name:
|
|
47
|
+
return obj["id"]
|
|
48
|
+
return None
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def props_params(object_id: int) -> list[dict]:
|
|
52
|
+
objs = dump(object_id)
|
|
53
|
+
if not objs:
|
|
54
|
+
return []
|
|
55
|
+
return objs[0].get("info", {}).get("params", {}).get("Props", []) or []
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def set_props(object_id: int, spa_pod: str) -> bool:
|
|
59
|
+
"""pw-cli set-param <id> Props <pod>; the pod is SPA-JSON text."""
|
|
60
|
+
out = subprocess.run(["pw-cli", "set-param", str(object_id), "Props", spa_pod],
|
|
61
|
+
capture_output=True, text=True)
|
|
62
|
+
return out.returncode == 0
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def set_graph_param(object_id: int, param: str, value: float) -> bool:
|
|
66
|
+
return set_props(object_id, f'{{ params = [ "{param}" {value:.6g} ] }}')
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
# ---- clock ----
|
|
70
|
+
|
|
71
|
+
def force_quantum() -> int:
|
|
72
|
+
out = run("pw-metadata", "-n", "settings", "0", "clock.force-quantum")
|
|
73
|
+
for line in out.splitlines():
|
|
74
|
+
if "key:'clock.force-quantum'" in line and "value:'" in line:
|
|
75
|
+
v = line.split("value:'", 1)[1].split("'", 1)[0]
|
|
76
|
+
return int(v) if v.isdigit() else 0
|
|
77
|
+
return 0
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def set_force_quantum(value: int) -> None:
|
|
81
|
+
run("pw-metadata", "-n", "settings", "0", "clock.force-quantum", str(value))
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
# ---- links ----
|
|
85
|
+
|
|
86
|
+
def output_ports() -> list[str]:
|
|
87
|
+
return [l.strip() for l in run("pw-link", "-o").splitlines() if l.strip()]
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def input_ports() -> list[str]:
|
|
91
|
+
return [l.strip() for l in run("pw-link", "-i").splitlines() if l.strip()]
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def links_from(port: str) -> list[str]:
|
|
95
|
+
"""Ports `port` (an output port) is linked to."""
|
|
96
|
+
targets: list[str] = []
|
|
97
|
+
current = None
|
|
98
|
+
for line in run("pw-link", "-l").splitlines():
|
|
99
|
+
if line and not line[0].isspace() and not line.startswith("|"):
|
|
100
|
+
current = line.strip()
|
|
101
|
+
continue
|
|
102
|
+
s = line.strip()
|
|
103
|
+
if current == port and s.startswith("|->"):
|
|
104
|
+
targets.append(s[3:].strip())
|
|
105
|
+
return targets
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def link(src: str, dst: str) -> None:
|
|
109
|
+
# --wait: return once the link exists, so a listing right after sees it.
|
|
110
|
+
run("pw-link", "--wait", src, dst)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def unlink(src: str, dst: str) -> None:
|
|
114
|
+
run("pw-link", "-d", src, dst)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
# ---- pactl ----
|
|
118
|
+
|
|
119
|
+
def default_sink() -> str:
|
|
120
|
+
return run("pactl", "get-default-sink").strip()
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def sink_ports(sink: str | None = None, count: int = 2) -> list[str]:
|
|
124
|
+
"""First `count` playback ports of a sink (the selected output by default)."""
|
|
125
|
+
sink = sink or default_sink()
|
|
126
|
+
if not sink:
|
|
127
|
+
return []
|
|
128
|
+
prefix = f"{sink}:playback_"
|
|
129
|
+
return [p for p in input_ports() if p.startswith(prefix)][:count]
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
@dataclass
|
|
133
|
+
class SinkInput:
|
|
134
|
+
index: int
|
|
135
|
+
sink: int
|
|
136
|
+
props: dict = field(default_factory=dict)
|
|
137
|
+
mute: bool = False
|
|
138
|
+
|
|
139
|
+
@property
|
|
140
|
+
def node_id(self) -> str:
|
|
141
|
+
return str(self.props.get("object.id", ""))
|
|
142
|
+
|
|
143
|
+
@property
|
|
144
|
+
def node_name(self) -> str:
|
|
145
|
+
return str(self.props.get("node.name", ""))
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def sink_inputs() -> list[SinkInput]:
|
|
149
|
+
out = run("pactl", "-f", "json", "list", "sink-inputs")
|
|
150
|
+
try:
|
|
151
|
+
data = json.loads(out or "[]")
|
|
152
|
+
except json.JSONDecodeError:
|
|
153
|
+
return []
|
|
154
|
+
return [SinkInput(index=d.get("index", -1), sink=d.get("sink", -1),
|
|
155
|
+
props=d.get("properties", {}) or {}, mute=bool(d.get("mute")))
|
|
156
|
+
for d in data]
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def sink_index(name: str) -> int | None:
|
|
160
|
+
for line in run("pactl", "list", "short", "sinks").splitlines():
|
|
161
|
+
cols = line.split("\t")
|
|
162
|
+
if len(cols) > 1 and cols[1] == name:
|
|
163
|
+
return int(cols[0])
|
|
164
|
+
return None
|
evo8/state.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""Saved settings, restored by `evoctl apply` after PipeWire restarts.
|
|
2
|
+
|
|
3
|
+
One JSON object in $XDG_STATE_HOME/evo8/state.json. On first use it takes over
|
|
4
|
+
the file the wh01s17 shell scripts kept (wh01s17/mezcla-gains.json), so the
|
|
5
|
+
gains and sync delay already tuned carry over.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import json
|
|
11
|
+
import os
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def state_dir() -> Path:
|
|
16
|
+
base = os.environ.get("XDG_STATE_HOME") or os.path.expanduser("~/.local/state")
|
|
17
|
+
return Path(base) / "evo8"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def runtime_dir() -> Path:
|
|
21
|
+
return Path(os.environ.get("XDG_RUNTIME_DIR") or "/tmp")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
STATE = state_dir() / "state.json"
|
|
25
|
+
LEGACY = state_dir().parent / "wh01s17" / "mezcla-gains.json"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def load() -> dict:
|
|
29
|
+
for path in (STATE, LEGACY):
|
|
30
|
+
try:
|
|
31
|
+
data = json.loads(path.read_text())
|
|
32
|
+
except (OSError, json.JSONDecodeError):
|
|
33
|
+
continue
|
|
34
|
+
if isinstance(data, dict):
|
|
35
|
+
return data
|
|
36
|
+
return {}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def save(key: str, value) -> None:
|
|
40
|
+
data = load()
|
|
41
|
+
data[key] = value
|
|
42
|
+
STATE.parent.mkdir(parents=True, exist_ok=True)
|
|
43
|
+
tmp = STATE.with_suffix(".tmp")
|
|
44
|
+
tmp.write_text(json.dumps(data, separators=(",", ":")))
|
|
45
|
+
tmp.replace(STATE)
|
evo8/usb.py
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"""USB Audio Class requests to the EVO 8's control units.
|
|
2
|
+
|
|
3
|
+
What EVO Control (Windows/macOS) does, recovered from EVO.exe (UacLib): every
|
|
4
|
+
setting is a standard UAC2 class request on the audio control interface (0):
|
|
5
|
+
|
|
6
|
+
SET: bmRequestType 0x21, GET: 0xA1
|
|
7
|
+
bRequest CUR (0x01) or RANGE (0x02)
|
|
8
|
+
wValue (control selector << 8) | channel / mixer control number
|
|
9
|
+
wIndex (unit id << 8) | 0
|
|
10
|
+
|
|
11
|
+
Linux only lets a process send class requests to an interface it has claimed,
|
|
12
|
+
and snd-usb-audio holds interface 0 while the card exists. So a batch of
|
|
13
|
+
requests runs inside `session()`: the audio interfaces are detached from
|
|
14
|
+
snd-usb-audio, the requests go out, and the driver is reattached, which brings
|
|
15
|
+
the card back. Audio stops for that moment (about a second), so writes are
|
|
16
|
+
batched and meant for setup, not for live faders.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
import contextlib
|
|
22
|
+
import struct
|
|
23
|
+
import time
|
|
24
|
+
|
|
25
|
+
VENDOR_ID = 0x2708
|
|
26
|
+
PRODUCT_ID = 0x0007 # EVO 8
|
|
27
|
+
CONTROL_IFACE = 0
|
|
28
|
+
AUDIO_IFACES = (0, 1, 2) # control + playback + capture streaming
|
|
29
|
+
|
|
30
|
+
REQ_CUR = 0x01
|
|
31
|
+
REQ_RANGE = 0x02
|
|
32
|
+
TYPE_SET = 0x21 # class | interface, host to device
|
|
33
|
+
TYPE_GET = 0xA1 # class | interface, device to host
|
|
34
|
+
TIMEOUT_MS = 1000
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class UsbError(RuntimeError):
|
|
38
|
+
pass
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _usb():
|
|
42
|
+
try:
|
|
43
|
+
import usb.core
|
|
44
|
+
import usb.util
|
|
45
|
+
except ImportError as e: # pragma: no cover - depends on the host
|
|
46
|
+
raise UsbError("falta pyusb (pacman -S python-pyusb)") from e
|
|
47
|
+
return usb
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def find_device():
|
|
51
|
+
usb = _usb()
|
|
52
|
+
dev = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID)
|
|
53
|
+
if dev is None:
|
|
54
|
+
raise UsbError("no se encontró la EVO 8 (2708:0007)")
|
|
55
|
+
return dev
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class Session:
|
|
59
|
+
"""Requests on a device whose audio interfaces we hold."""
|
|
60
|
+
|
|
61
|
+
def __init__(self, dev):
|
|
62
|
+
self.dev = dev
|
|
63
|
+
|
|
64
|
+
def get(self, unit: int, selector: int, channel: int, length: int, request: int = REQ_CUR) -> bytes:
|
|
65
|
+
data = self.dev.ctrl_transfer(TYPE_GET, request, (selector << 8) | (channel & 0xFF),
|
|
66
|
+
(unit << 8) | CONTROL_IFACE, length, TIMEOUT_MS)
|
|
67
|
+
return bytes(data)
|
|
68
|
+
|
|
69
|
+
def set(self, unit: int, selector: int, channel: int, data: bytes, request: int = REQ_CUR) -> None:
|
|
70
|
+
n = self.dev.ctrl_transfer(TYPE_SET, request, (selector << 8) | (channel & 0xFF),
|
|
71
|
+
(unit << 8) | CONTROL_IFACE, data, TIMEOUT_MS)
|
|
72
|
+
if n != len(data):
|
|
73
|
+
raise UsbError(f"short write to unit {unit} selector {selector}: {n}/{len(data)}")
|
|
74
|
+
|
|
75
|
+
# Common payloads: UAC2 volumes are signed 16-bit in 1/256 dB.
|
|
76
|
+
def get_s16(self, unit: int, selector: int, channel: int) -> int:
|
|
77
|
+
return struct.unpack("<h", self.get(unit, selector, channel, 2))[0]
|
|
78
|
+
|
|
79
|
+
def set_s16(self, unit: int, selector: int, channel: int, value: int) -> None:
|
|
80
|
+
self.set(unit, selector, channel, struct.pack("<h", value))
|
|
81
|
+
|
|
82
|
+
def range_s16(self, unit: int, selector: int, channel: int) -> list[tuple[int, int, int]]:
|
|
83
|
+
"""RANGE answer: wNumSubRanges then (min, max, res) triples."""
|
|
84
|
+
head = self.get(unit, selector, channel, 2, REQ_RANGE)
|
|
85
|
+
count = struct.unpack("<H", head)[0]
|
|
86
|
+
raw = self.get(unit, selector, channel, 2 + 6 * count, REQ_RANGE)
|
|
87
|
+
return [struct.unpack_from("<hhh", raw, 2 + 6 * i) for i in range(count)]
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
@contextlib.contextmanager
|
|
91
|
+
def session(settle: float = 0.0):
|
|
92
|
+
"""Detach snd-usb-audio, yield a Session, then give the card back.
|
|
93
|
+
|
|
94
|
+
All audio interfaces are detached: if only the control interface went, the
|
|
95
|
+
driver would keep the old card half-alive on the streaming ones and refuse
|
|
96
|
+
to create a new one on reattach. Reattaching interface 0 is enough for it
|
|
97
|
+
to claim the streaming interfaces again."""
|
|
98
|
+
usb = _usb()
|
|
99
|
+
dev = find_device()
|
|
100
|
+
detached = []
|
|
101
|
+
try:
|
|
102
|
+
for i in AUDIO_IFACES:
|
|
103
|
+
if dev.is_kernel_driver_active(i):
|
|
104
|
+
dev.detach_kernel_driver(i)
|
|
105
|
+
detached.append(i)
|
|
106
|
+
usb.util.claim_interface(dev, CONTROL_IFACE)
|
|
107
|
+
yield Session(dev)
|
|
108
|
+
finally:
|
|
109
|
+
with contextlib.suppress(Exception):
|
|
110
|
+
usb.util.release_interface(dev, CONTROL_IFACE)
|
|
111
|
+
with contextlib.suppress(Exception):
|
|
112
|
+
usb.util.dispose_resources(dev)
|
|
113
|
+
if settle:
|
|
114
|
+
time.sleep(settle)
|
|
115
|
+
if detached:
|
|
116
|
+
# The driver claims the streaming interfaces itself when it binds
|
|
117
|
+
# the control interface, so only that one is handed back.
|
|
118
|
+
try:
|
|
119
|
+
dev.attach_kernel_driver(CONTROL_IFACE)
|
|
120
|
+
except Exception as e:
|
|
121
|
+
raise UsbError(f"no se pudo devolver la EVO al driver de audio: {e}; "
|
|
122
|
+
"desconecta y conecta el USB") from e
|
evo8/user_setup.py
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"""`evoctl setup`: put the files a pip/pipx install cannot place.
|
|
2
|
+
|
|
3
|
+
pip only installs Python code. The Mezcla needs a PipeWire drop-in, the
|
|
4
|
+
"Restaurar al conectar" service needs a user unit, and the menu entry needs a
|
|
5
|
+
.desktop file and an icon. All of those go under the user's home, so no root
|
|
6
|
+
is needed. The udev rule (USB access without root) is the one thing that does
|
|
7
|
+
need root: setup prints the exact command instead of running sudo itself.
|
|
8
|
+
|
|
9
|
+
It never restarts PipeWire: the user may be in a call.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import os
|
|
15
|
+
import shutil
|
|
16
|
+
import subprocess
|
|
17
|
+
import sys
|
|
18
|
+
from dataclasses import dataclass
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
|
|
21
|
+
DATA = Path(__file__).with_name("data")
|
|
22
|
+
UDEV_RULE = DATA / "udev" / "70-audient-evo8.rules"
|
|
23
|
+
UDEV_DEST = Path("/etc/udev/rules.d/70-audient-evo8.rules")
|
|
24
|
+
SYSTEM_PIPEWIRE = (Path("/usr/share/pipewire"), Path("/etc/pipewire"))
|
|
25
|
+
TOOLS = {
|
|
26
|
+
"pactl": "pactl (libpulse / pulseaudio-utils)",
|
|
27
|
+
"pw-cli": "PipeWire (pipewire)",
|
|
28
|
+
"pw-dump": "PipeWire (pipewire)",
|
|
29
|
+
"pw-link": "PipeWire (pipewire)",
|
|
30
|
+
"pw-record": "PipeWire (pipewire)",
|
|
31
|
+
"pw-play": "PipeWire (pipewire)",
|
|
32
|
+
"pw-metadata": "PipeWire (pipewire)",
|
|
33
|
+
"wpctl": "WirePlumber (wireplumber)",
|
|
34
|
+
"amixer": "amixer (alsa-utils)",
|
|
35
|
+
}
|
|
36
|
+
FONT = "JetBrainsMono Nerd Font"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _config_home() -> Path:
|
|
40
|
+
return Path(os.environ.get("XDG_CONFIG_HOME") or os.path.expanduser("~/.config"))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _data_home() -> Path:
|
|
44
|
+
return Path(os.environ.get("XDG_DATA_HOME") or os.path.expanduser("~/.local/share"))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def bin_path(name: str) -> str:
|
|
48
|
+
"""Absolute path of one of our commands: next to the running Python first
|
|
49
|
+
(a pipx or venv install), then PATH."""
|
|
50
|
+
here = Path(sys.executable).parent / name
|
|
51
|
+
if here.exists():
|
|
52
|
+
return str(here)
|
|
53
|
+
return shutil.which(name) or name
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@dataclass
|
|
57
|
+
class Item:
|
|
58
|
+
label: str
|
|
59
|
+
dest: Path
|
|
60
|
+
content: str
|
|
61
|
+
note: str = "" # why it is skipped, when it is
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _text(rel: str) -> str:
|
|
65
|
+
return (DATA / rel).read_text()
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def plan() -> list[Item]:
|
|
69
|
+
cfg, share = _config_home(), _data_home()
|
|
70
|
+
items: list[Item] = []
|
|
71
|
+
for rel, label in (("pipewire/pipewire.conf.d/20-mezcla.conf", "PipeWire: la Mezcla"),
|
|
72
|
+
("pipewire/pipewire-pulse.conf.d/20-bloquear-volumen-micro.conf",
|
|
73
|
+
"PipeWire: volumen fijo del micrófono en el navegador")):
|
|
74
|
+
dest = cfg / rel
|
|
75
|
+
item = Item(label, dest, _text(rel))
|
|
76
|
+
# A drop-in in ~/.config shadows the system one with the same name:
|
|
77
|
+
# never leave a stale copy over a packaged install.
|
|
78
|
+
sub = Path(rel).relative_to("pipewire")
|
|
79
|
+
system = next((d / sub for d in SYSTEM_PIPEWIRE if (d / sub).exists()), None)
|
|
80
|
+
if system:
|
|
81
|
+
item.note = f"ya lo instala el sistema ({system})"
|
|
82
|
+
elif dest.is_symlink():
|
|
83
|
+
item.note = f"enlace de una instalación de desarrollo ({os.readlink(dest)})"
|
|
84
|
+
items.append(item)
|
|
85
|
+
|
|
86
|
+
service = _text("systemd/evo8-restore.service").replace(
|
|
87
|
+
"%h/.local/bin/evoctl", bin_path("evoctl"))
|
|
88
|
+
items.append(Item("Servicio: restaurar ajustes al conectar la EVO",
|
|
89
|
+
cfg / "systemd" / "user" / "evo8-restore.service", service))
|
|
90
|
+
|
|
91
|
+
desktop = _text("applications/evo8-mixer.desktop").replace(
|
|
92
|
+
"Exec=evo8-mixer", "Exec=" + bin_path("evo8-mixer"))
|
|
93
|
+
items.append(Item("Menú de aplicaciones", share / "applications" / "evo8-mixer.desktop", desktop))
|
|
94
|
+
items.append(Item("Ícono", share / "icons" / "hicolor" / "scalable" / "apps" / "evo8-mixer.svg",
|
|
95
|
+
_text("evo8-mixer.svg")))
|
|
96
|
+
return items
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def checks() -> list[str]:
|
|
100
|
+
"""Problems setup cannot fix, in words the user can act on."""
|
|
101
|
+
problems = []
|
|
102
|
+
missing = sorted({pkg for tool, pkg in TOOLS.items() if not shutil.which(tool)})
|
|
103
|
+
if missing:
|
|
104
|
+
problems.append("Faltan programas del sistema: " + ", ".join(missing) + ".")
|
|
105
|
+
for module, what in (("usb", "pyusb (control por USB)"), ("PySide6", "PySide6 (la ventana)")):
|
|
106
|
+
try:
|
|
107
|
+
__import__(module)
|
|
108
|
+
except ImportError:
|
|
109
|
+
problems.append(f"Falta {what}: pipx install --force 'evo8-linux[gui,usb]'.")
|
|
110
|
+
if shutil.which("fc-list"):
|
|
111
|
+
out = subprocess.run(["fc-list", FONT], capture_output=True, text=True).stdout
|
|
112
|
+
if not out.strip():
|
|
113
|
+
problems.append(f"Falta la fuente «{FONT}»: los íconos de la ventana se verán como cuadros.")
|
|
114
|
+
return problems
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def udev_command() -> str:
|
|
118
|
+
return (f"sudo install -Dm644 {UDEV_RULE} {UDEV_DEST} && "
|
|
119
|
+
"sudo udevadm control --reload && sudo udevadm trigger --subsystem-match=usb")
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def udev_installed() -> bool:
|
|
123
|
+
return UDEV_DEST.exists() or Path("/usr/lib/udev/rules.d/70-audient-evo8.rules").exists()
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def install(dry_run: bool = False) -> list[str]:
|
|
127
|
+
lines = []
|
|
128
|
+
for it in plan():
|
|
129
|
+
if it.note:
|
|
130
|
+
lines.append(f" {'omitido':<11}{it.label}: {it.note}")
|
|
131
|
+
continue
|
|
132
|
+
current = it.dest.read_text() if it.dest.is_file() else None
|
|
133
|
+
if current == it.content:
|
|
134
|
+
lines.append(f" {'al día':<11}{it.label}")
|
|
135
|
+
continue
|
|
136
|
+
verb = "instalar" if current is None else "actualizar"
|
|
137
|
+
if not dry_run:
|
|
138
|
+
it.dest.parent.mkdir(parents=True, exist_ok=True)
|
|
139
|
+
it.dest.write_text(it.content)
|
|
140
|
+
verb = "instalado" if current is None else "actualizado"
|
|
141
|
+
lines.append(f" {verb:<11}{it.label} → {it.dest}")
|
|
142
|
+
if not dry_run:
|
|
143
|
+
_refresh()
|
|
144
|
+
return lines
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def remove(dry_run: bool = False) -> list[str]:
|
|
148
|
+
lines = []
|
|
149
|
+
for it in plan():
|
|
150
|
+
if it.note or not it.dest.is_file() or it.dest.is_symlink():
|
|
151
|
+
continue
|
|
152
|
+
if not dry_run:
|
|
153
|
+
it.dest.unlink()
|
|
154
|
+
lines.append(f" {'quitar' if dry_run else 'quitado':<11}{it.label} ({it.dest})")
|
|
155
|
+
if not dry_run:
|
|
156
|
+
_refresh()
|
|
157
|
+
return lines
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def _refresh() -> None:
|
|
161
|
+
"""Let systemd and the menus see the new files; all optional."""
|
|
162
|
+
for cmd in (["systemctl", "--user", "daemon-reload"],
|
|
163
|
+
["update-desktop-database", "-q", str(_data_home() / "applications")],
|
|
164
|
+
["gtk-update-icon-cache", "-q", "-t", str(_data_home() / "icons" / "hicolor")]):
|
|
165
|
+
if shutil.which(cmd[0]):
|
|
166
|
+
subprocess.run(cmd, capture_output=True)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def mezcla_loaded() -> bool | None:
|
|
170
|
+
"""Whether PipeWire already runs the Mezcla; None when it cannot tell."""
|
|
171
|
+
if not shutil.which("pw-cli"):
|
|
172
|
+
return None
|
|
173
|
+
out = subprocess.run(["pw-cli", "ls", "Node"], capture_output=True, text=True).stdout
|
|
174
|
+
return "mezcla.suma" in out
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def evo_profile_ok() -> bool | None:
|
|
178
|
+
"""Whether the EVO 8 is on Pro Audio; None when it is not plugged in."""
|
|
179
|
+
from . import apps, profiles
|
|
180
|
+
try:
|
|
181
|
+
cards = apps.card_profiles()
|
|
182
|
+
except Exception:
|
|
183
|
+
return None
|
|
184
|
+
for card, wanted in profiles.REQUIRED.items():
|
|
185
|
+
for c in cards:
|
|
186
|
+
if c["name"] == card:
|
|
187
|
+
return c["active"] == wanted
|
|
188
|
+
return None
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def run(remove_files: bool = False, dry_run: bool = False) -> int:
|
|
192
|
+
if remove_files:
|
|
193
|
+
lines = remove(dry_run)
|
|
194
|
+
print("\n".join(lines) if lines else "Nada que quitar.")
|
|
195
|
+
if udev_installed():
|
|
196
|
+
print(f"\nLa regla udev queda; para quitarla: sudo rm {UDEV_DEST}")
|
|
197
|
+
return 0
|
|
198
|
+
|
|
199
|
+
print("Archivos de usuario:" + (" (simulación)" if dry_run else ""))
|
|
200
|
+
lines = install(dry_run)
|
|
201
|
+
print("\n".join(lines))
|
|
202
|
+
pipewire_changed = any(line.split()[0] in ("instalado", "actualizado", "instalar", "actualizar")
|
|
203
|
+
and "PipeWire" in line for line in lines)
|
|
204
|
+
steps = []
|
|
205
|
+
if not udev_installed():
|
|
206
|
+
steps.append("Permitir el control por USB sin root (pide tu contraseña):\n " + udev_command())
|
|
207
|
+
if pipewire_changed or mezcla_loaded() is False:
|
|
208
|
+
steps.append("Reiniciar PipeWire para cargar la Mezcla (corta el audio un momento; no lo hagas en una llamada):\n"
|
|
209
|
+
" systemctl --user restart pipewire pipewire-pulse wireplumber")
|
|
210
|
+
if evo_profile_ok() is False:
|
|
211
|
+
steps.append("Poner la EVO 8 en el perfil Pro Audio:\n"
|
|
212
|
+
" evoctl profiles set alsa_card.usb-Audient_EVO8-00 pro-audio")
|
|
213
|
+
if steps:
|
|
214
|
+
print("\nFalta:")
|
|
215
|
+
for i, s in enumerate(steps, 1):
|
|
216
|
+
print(f" {i}. {s}")
|
|
217
|
+
else:
|
|
218
|
+
print("\nTodo listo. Abre el mezclador con evo8-mixer o desde el menú de aplicaciones.")
|
|
219
|
+
problems = checks()
|
|
220
|
+
if problems:
|
|
221
|
+
print("\nRevisa:")
|
|
222
|
+
for p in problems:
|
|
223
|
+
print(" - " + p)
|
|
224
|
+
return 1 if problems else 0
|