Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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.')
Esempio n. 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.')