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