[modules] Adjust update schedules
Make a few modules update more seldomly, to reduce CPU consumption.
This commit is contained in:
parent
0f6dfb3f1a
commit
18154dd74f
7 changed files with 24 additions and 12 deletions
|
@ -1,11 +1,11 @@
|
|||
import util.format
|
||||
|
||||
def every(minutes=0, seconds=0):
|
||||
def every(hours=0, minutes=0, seconds=0):
|
||||
def decorator_init(init):
|
||||
def call_init(obj, *args, **kwargs):
|
||||
init(obj, *args, **kwargs)
|
||||
if obj.parameter('interval') is None:
|
||||
obj.set('interval', minutes*60 + seconds)
|
||||
obj.set('interval', hours*3600 + minutes*60 + seconds)
|
||||
return call_init
|
||||
return decorator_init
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
# pylint: disable=C0111,R0903
|
||||
|
||||
'''Displays the brightness of a display
|
||||
"""Displays the brightness of a display
|
||||
|
||||
Parameters:
|
||||
* brightness.step: The amount of increase/decrease on scroll in % (defaults to 2)
|
||||
* brightness.device_path: The device path (defaults to /sys/class/backlight/intel_backlight), can contain wildcards (in this case, the first matching path will be used)
|
||||
|
||||
'''
|
||||
"""
|
||||
|
||||
import glob
|
||||
import shutil
|
||||
|
@ -14,8 +14,10 @@ import shutil
|
|||
import core.module
|
||||
import core.widget
|
||||
import core.input
|
||||
import core.decorators
|
||||
|
||||
class Module(core.module.Module):
|
||||
@core.decorators.every(seconds=30) # takes 30s to pick up on "external" changes
|
||||
def __init__(self, config):
|
||||
super().__init__(config, core.widget.Widget(self.brightness))
|
||||
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
# pylint: disable=C0111,R0903
|
||||
|
||||
'''Displays the current date and time.
|
||||
"""Displays the current date and time.
|
||||
|
||||
Parameters:
|
||||
* date.format: strftime()-compatible formatting string
|
||||
* date.locale: locale to use rather than the system default
|
||||
'''
|
||||
"""
|
||||
|
||||
import core.decorators
|
||||
from .datetime import Module
|
||||
|
||||
class Module(Module):
|
||||
@core.decorators.every(hours=1)
|
||||
def __init__(self, config):
|
||||
super().__init__(config)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pylint: disable=C0111,R0903
|
||||
|
||||
'''Displays the name, IP address(es) and status of each available network interface.
|
||||
"""Displays the name, IP address(es) and status of each available network interface.
|
||||
|
||||
Requires the following python module:
|
||||
* netifaces
|
||||
|
@ -10,7 +10,7 @@ Parameters:
|
|||
* nic.include: Comma-separated list of interfaces to include
|
||||
* nic.states: Comma-separated list of states to show (prefix with '^' to invert - i.e. ^down -> show all devices that are not in state down)
|
||||
* nic.format: Format string (defaults to '{intf} {state} {ip} {ssid}')
|
||||
'''
|
||||
"""
|
||||
|
||||
import shutil
|
||||
import netifaces
|
||||
|
@ -18,10 +18,12 @@ import subprocess
|
|||
|
||||
import core.widget
|
||||
import core.module
|
||||
import core.decorators
|
||||
import util.cli
|
||||
import util.format
|
||||
|
||||
class Module(core.module.Module):
|
||||
@core.decorators.every(seconds=10)
|
||||
def __init__(self, config):
|
||||
widgets = []
|
||||
super().__init__(config, widgets)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# pylint: disable=C0111,R0903
|
||||
|
||||
'''Displays the current color temperature of redshift
|
||||
"""Displays the current color temperature of redshift
|
||||
|
||||
Requires the following executable:
|
||||
* redshift
|
||||
|
@ -11,7 +11,7 @@ Parameters:
|
|||
'auto' uses whatever redshift is configured to do
|
||||
* redshift.lat : latitude if location is set to 'manual'
|
||||
* redshift.lon : longitude if location is set to 'manual'
|
||||
'''
|
||||
"""
|
||||
|
||||
import threading
|
||||
import logging
|
||||
|
@ -24,6 +24,7 @@ except ImportError:
|
|||
import core.module
|
||||
import core.widget
|
||||
import core.input
|
||||
import core.decorators
|
||||
|
||||
import util.cli
|
||||
|
||||
|
@ -75,6 +76,7 @@ def get_redshift_value(widget, location, lat, lon):
|
|||
widget.set('transition', ' '.join(line.split(' ')[2:]))
|
||||
|
||||
class Module(core.module.Module):
|
||||
@core.decorators.every(seconds=10)
|
||||
def __init__(self, config):
|
||||
widget = core.widget.Widget(self.text)
|
||||
super().__init__(config, widget)
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
# pylint: disable=C0111,R0903
|
||||
|
||||
'''Displays the current date and time.
|
||||
"""Displays the current date and time.
|
||||
|
||||
Parameters:
|
||||
* time.format: strftime()-compatible formatting string
|
||||
* time.locale: locale to use rather than the system default
|
||||
'''
|
||||
"""
|
||||
|
||||
import core.decorators
|
||||
from .datetime import Module
|
||||
|
||||
class Module(Module):
|
||||
@core.decorators.every(seconds=59) # ensures one update per minute
|
||||
def __init__(self, config):
|
||||
super().__init__(config)
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import sys
|
|||
import core.module
|
||||
import core.widget
|
||||
import core.input
|
||||
import core.decorators
|
||||
|
||||
import util.cli
|
||||
import util.format
|
||||
|
@ -33,6 +34,7 @@ except:
|
|||
pass
|
||||
|
||||
class Module(core.module.Module):
|
||||
@core.decorators.every(seconds=5) # takes up to 5s to detect a new screen
|
||||
def __init__(self, config):
|
||||
widgets = []
|
||||
super().__init__(config, widgets)
|
||||
|
|
Loading…
Reference in a new issue