Do not log during minimize count down loop.
This commit is contained in:
@@ -58,7 +58,7 @@ class AntiDriftDaemon(dbus.service.Object):
|
||||
mainloop.run()
|
||||
|
||||
|
||||
def window_is_blocked(config: Config) -> bool:
|
||||
def window_is_blocked(config: Config, silent: bool = False) -> bool:
|
||||
# These should be selectable in the future (not all at the same time)
|
||||
blackblocks = config.blackblocks
|
||||
whiteblocks = config.whiteblocks
|
||||
@@ -69,18 +69,23 @@ def window_is_blocked(config: Config) -> bool:
|
||||
for b in blackblocks:
|
||||
for k in b.keywords:
|
||||
if k in window.keywords:
|
||||
if not silent:
|
||||
xwindow.notify(f"{window.name[:30]} blocked by {b.name}.")
|
||||
logging.warning(f"{window.name[:30]} blocked by {b.name}.")
|
||||
logging.warning(f"[red]{window.name[:50]}[/red] "
|
||||
f"blocked by [red]{b.name}[/red].")
|
||||
return True
|
||||
if config.blackblocks_only:
|
||||
if not silent:
|
||||
logging.debug("All non-blacklisted windows are allowed.")
|
||||
return False
|
||||
for w in whiteblocks:
|
||||
for k in w.keywords:
|
||||
if k in window.keywords:
|
||||
if not silent:
|
||||
logging.debug(f"[green]{window.name[:30]}[/green] "
|
||||
f"allowed by [blue]{w.name}[/blue].")
|
||||
return False
|
||||
if not silent:
|
||||
xwindow.notify(f"{window.name[:30]} not on any whitelist.")
|
||||
return True
|
||||
|
||||
@@ -90,7 +95,12 @@ def enforce(config: Config):
|
||||
return
|
||||
delay = config.minimize_delay
|
||||
xwindow.notify(f"AntiDrift will minimize in {delay} seconds.")
|
||||
time.sleep(config.minimize_delay)
|
||||
timer, timer_step = 0.0, 0.5
|
||||
while timer < config.minimize_delay:
|
||||
time.sleep(timer_step)
|
||||
timer += timer_step
|
||||
if not window_is_blocked(config, True):
|
||||
break
|
||||
window = xwindow.XWindow()
|
||||
if window_is_blocked(config):
|
||||
window = xwindow.XWindow()
|
||||
|
||||
Reference in New Issue
Block a user