snapshot of https://github.com/ActivityWatch/aw-core.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Build / Test on ubuntu-latest, py-3.8 (push) Successful in 4m21s
Lint / lint (push) Successful in 25s
Build / Test on macOS-latest, py-3.8 (push) Has been cancelled
Build / Test on windows-latest, py-3.8 (push) Has been cancelled
CodeQL / Analyze (python) (push) Failing after 1s

This commit is contained in:
upstream-mirror
2026-09-16 00:17:07 +05:00
commit 8757f2fd5e
73 changed files with 8869 additions and 0 deletions

30
aw_transform/simplify.py Normal file
View File

@@ -0,0 +1,30 @@
import re
from copy import deepcopy
from typing import List
from aw_core import Event
def simplify_string(events: List[Event], key: str = "title") -> List[Event]:
events = deepcopy(events)
re_leadingdot = re.compile(r"^(●|\*)\s*")
re_parensprefix = re.compile(r"^\([0-9]+\)\s*")
re_fps = re.compile(r"FPS:\s+[0-9\.]+")
for e in events:
# Remove prefixes that are numbers within parenthesis
# Example: "(2) Facebook" -> "Facebook"
# Example: "(1) YouTube" -> "YouTube"
e.data[key] = re_parensprefix.sub("", e.data[key])
# Things generally specific to window events with the "app" key
if key == "title" and "app" in e["data"]:
# Remove FPS display in window title
# Example: "Cemu - FPS: 59.2 - ..." -> "Cemu - FPS: ... - ..."
e.data[key] = re_fps.sub("FPS: ...", e.data[key])
# For VSCode (uses ●), gedit (uses *), et al
# See: https://github.com/ActivityWatch/aw-watcher-window/issues/32
e.data[key] = re_leadingdot.sub("", e.data[key])
return events