def process_operation(q):
    if len(q) == 0:
        return
    op = q[0]
    old = int(v.get_volume())
    new = old
    if op == 'mute':
        v.set_muted('true')
    elif op == 'unmute':
        v.set_muted('false')
    else:
        if op == 'up':
            delta = int(q[1]) if len(q) >= 2 else 10
            new = min(old + delta, 100)
        elif op == 'down':
            delta = int(q[1]) if len(q) >= 2 else 10
            new = max(old - delta, 0)
        else:
            try:
                new = int(op)
            except:
                new = old
            new = max(new, 0)
            new = min(new, 100)
        logging.debug(new)
        v.set_volume(new)
        return new
Beispiel #2
0
def blockify_volume():
  """ Print the current volume. """

  block = StatusUnit('volume')
  block.icon_block.set_name('toggle-volume')

  status = volume_control.status()
  if status == "on":
    volume = int(volume_control.get_volume())
    if volume > 80:
      block.set_icon('')
    elif volume > 40:
      block.set_icon('')
    else:
      block.set_icon('')

    block.set_text(str(volume) + '%')

    color = get_color_gradient(volume, [
      { 'threshold': 0,   'color': colors['urgent'] },
      { 'threshold': 100, 'color': colors['blue'] },
      { 'threshold': 101, 'color': colors['yellow'] },
      { 'threshold': 200, 'color': colors['yellow'] } ])
    block.set_border(color, 0, TOP_BORDER_WIDTH, 0, 0)
    block.status_block.set_min_width(40, 'right')
  else:
    block.set_icon('')
    block.set_text('muted')
    block.set_urgent()
    block.status_block.set_name('toggle-volume')

  return block.to_json()
Beispiel #3
0
def blockify_volume():
  """ Print the current volume. """

  block = StatusUnit('volume')
  block.icon_block.set_name('toggle-volume')

  status = volume_control.status()
  if status == "on":
    volume = int(volume_control.get_volume())
    if volume > 80:
      block.set_icon('')
    elif volume > 40:
      block.set_icon('')
    else:
      block.set_icon('')

    block.set_text(str(volume) + '%')

    color = get_color_gradient(volume, [
      { 'threshold': 0,   'color': colors['urgent'] },
      { 'threshold': 100, 'color': colors['blue'] },
      { 'threshold': 101, 'color': colors['yellow'] },
      { 'threshold': 200, 'color': colors['yellow'] } ])
    block.set_border(color, 0, TOP_BORDER_WIDTH, 0, 0)
    block.status_block.set_min_width(40, 'right')
  else:
    block.set_icon('')
    block.set_text('muted')
    block.set_urgent()
    block.status_block.set_name('toggle-volume')

  return block.to_json()
Beispiel #4
0
def blockify_volume():
  """ Print the current volume. """

  block = Powerblock('volume')

  status = volume_control.status()
  if status == "on":
    volume = int(volume_control.get_volume())
    block.set_text(str(volume) + '%')

  else:
    block.set_text('muted')
    #block.set_urgent()

  return block