Force update using USR1 signal
This commit is contained in:
parent
f8d035c079
commit
c77f3aa3bc
2 changed files with 10 additions and 1 deletions
|
@ -4,6 +4,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
import signal
|
||||||
import socket
|
import socket
|
||||||
import select
|
import select
|
||||||
import logging
|
import logging
|
||||||
|
@ -103,6 +104,12 @@ def main():
|
||||||
input_thread.daemon = True
|
input_thread.daemon = True
|
||||||
input_thread.start()
|
input_thread.start()
|
||||||
|
|
||||||
|
def sig_USR1_handler(signum,stack):
|
||||||
|
if update_lock.acquire(blocking=False) == True:
|
||||||
|
core.event.trigger("update", redraw_only=False)
|
||||||
|
core.event.trigger("draw")
|
||||||
|
update_lock.release()
|
||||||
|
|
||||||
if config.debug():
|
if config.debug():
|
||||||
modules.append(core.module.load("debug", config, theme))
|
modules.append(core.module.load("debug", config, theme))
|
||||||
|
|
||||||
|
@ -120,6 +127,7 @@ def main():
|
||||||
|
|
||||||
core.event.trigger("start")
|
core.event.trigger("start")
|
||||||
started = True
|
started = True
|
||||||
|
signal.signal(10, sig_USR1_handler)
|
||||||
while True:
|
while True:
|
||||||
if update_lock.acquire(blocking=False) == True:
|
if update_lock.acquire(blocking=False) == True:
|
||||||
core.event.trigger("update")
|
core.event.trigger("update")
|
||||||
|
|
|
@ -222,13 +222,14 @@ class i3(object):
|
||||||
return blocks
|
return blocks
|
||||||
|
|
||||||
# TODO: only updates full text, not the state!?
|
# TODO: only updates full text, not the state!?
|
||||||
|
# can this TODO be removed now? Will update the state if not redraw_only
|
||||||
def update(self, affected_modules=None, redraw_only=False):
|
def update(self, affected_modules=None, redraw_only=False):
|
||||||
now = time.time()
|
now = time.time()
|
||||||
for module in self.__modules:
|
for module in self.__modules:
|
||||||
if affected_modules and not module.id in affected_modules:
|
if affected_modules and not module.id in affected_modules:
|
||||||
continue
|
continue
|
||||||
if not affected_modules and module.next_update:
|
if not affected_modules and module.next_update:
|
||||||
if now < module.next_update:
|
if now < module.next_update and redraw_only:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not redraw_only:
|
if not redraw_only:
|
||||||
|
|
Loading…
Reference in a new issue