Example #1
0
def postdock(state, config):
    '''
    Executes postdock hook if it exists.

    :param bool state: Whether new state is on
    :param configparser.ConfigParser config: Global config
    :returns: None
    '''
    hook = os.path.expanduser(config['hooks']['postdock'])
    if tps.has_program(hook):
        tps.call([hook, 'on' if state else 'off'], logger)
Example #2
0
def postrotate(direction, config):
    '''
    Executes postrotate hook if it exists.

    :param tps.Direction direction: Desired direction
    :param configparser.ConfigParser config: Global config
    :returns: None
    '''
    hook = os.path.expanduser(config['hooks']['postrotate'])
    if tps.has_program(hook):
        tps.call([hook, direction.xrandr], logger)
Example #3
0
def postdock(state, config):
    '''
    Executes postdock hook if it exists.

    :param bool state: Whether new state is on
    :param configparser.ConfigParser config: Global config
    :returns: None
    '''
    hook = os.path.expanduser(config['hooks']['postdock'])
    if tps.has_program(hook):
        tps.call([hook, 'on' if state else 'off'], logger)
Example #4
0
def postrotate(direction, config):
    '''
    Executes postrotate hook if it exists.

    :param tps.Direction direction: Desired direction
    :param configparser.ConfigParser config: Global config
    :returns: None
    '''
    hook = os.path.expanduser(config['hooks']['postrotate'])
    if tps.has_program(hook):
        tps.call([hook, direction.xrandr], logger)
Example #5
0
def set_brightness(brightness):
    '''
    Sets the brightness with ``xbacklight``.

    :param str brightness: Percent value of brightness, e. g. ``60%``
    :returns: None
    '''
    if not tps.has_program('xbacklight'):
        logger.warning('xbacklight is not installed')
        return

    status = tps.call(['xbacklight', '-set', brightness], logger)
    if status != 0:
        logger.warning('`xbacklight` cannot set the brightness, this is ignored.')
Example #6
0
def set_brightness(brightness):
    '''
    Sets the brightness with ``xbacklight``.

    :param str brightness: Percent value of brightness, e. g. ``60%``
    :returns: None
    '''
    if not tps.has_program('xbacklight'):
        logger.warning('xbacklight is not installed')
        return

    status = tps.call(['xbacklight', '-set', brightness], logger)
    if status != 0:
        logger.warning(
            '`xbacklight` cannot set the brightness, this is ignored.')