Update remap rules for windowname script

This commit is contained in:
ItsDrike 2024-06-21 02:39:01 +02:00
parent 2acdfac532
commit 47d070ce5e
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0

View file

@ -7,6 +7,7 @@ the window names. Window name and class are obtained from piped stdin, to preven
needlessly keep restarting this program, which takes a while due to the interpreter starting needlessly keep restarting this program, which takes a while due to the interpreter starting
overhead. overhead.
""" """
import json import json
import re import re
import sys import sys
@ -64,7 +65,7 @@ REMAP_RULES: list[RemapRule] = [
RemapRule(r"(?:\(\d+\) )?Discord \| (.+)", "{}", "vesktop"), RemapRule(r"(?:\(\d+\) )?Discord \| (.+)", "{}", "vesktop"),
RemapRule(r"(.+) - mpv", "{}", "mpv"), RemapRule(r"(.+) - mpv", "{}", "mpv"),
RemapRule(r"Stremio - (.+)", " Stremio - {}", r"(Stremio)|(com.stremio.stremio)"), RemapRule(r"Stremio - (.+)", " Stremio - {}", r"(Stremio)|(com.stremio.stremio)"),
RemapRule(r"Spotify", " Spotify", "Spotify"), RemapRule(r"Spotify((?: Premium)?)", " Spotify{}", "[Ss]potify"),
RemapRule(r"pulsemixer", " Pulsemixer"), RemapRule(r"pulsemixer", " Pulsemixer"),
RemapRule(r"(.*)", "{}", "Pcmanfm"), RemapRule(r"(.*)", "{}", "Pcmanfm"),
RemapRule(r"(.*)", "{}", "pcmanfm-qt"), RemapRule(r"(.*)", "{}", "pcmanfm-qt"),
@ -81,7 +82,9 @@ def iter_window() -> Iterator[tuple[str, str]]:
line = line.removesuffix("\n") line = line.removesuffix("\n")
els = line.split(",", maxsplit=1) els = line.split(",", maxsplit=1)
if len(els) != 2: if len(els) != 2:
raise ValueError(f"Expected 2 arguments from stdin line (name, class), but got {len(els)}") raise ValueError(
f"Expected 2 arguments from stdin line (name, class), but got {len(els)}"
)
yield els[1], els[0] yield els[1], els[0]