Example #1
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()
Example #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()
Example #3
0
def blockify_battery():
  """ Print the current battery level. """

  block = StatusUnit('battery')
  block.set_icon('')

  acpi = executor.run('acpi -b')[0]
  battery = re.search('\d*%', acpi).group(0)
  battery_int = int(battery[:-1])
  is_charging = bool(re.search('Charging|Unknown', acpi))

  if is_charging:
    block.set_icon('')
  elif battery_int > 90:
    block.set_icon('')
  elif battery_int > 50:
    block.set_icon('')
  elif battery_int > 20:
    block.set_icon('')
  else:
    block.set_icon('')

  block.set_text(battery)

  if battery_int > 10 or is_charging:
    color = get_color_gradient(battery_int, [ 
      { 'threshold': 0,   'color': colors['urgent'] },
      { 'threshold': 20,  'color': colors['urgent'] },
      { 'threshold': 80,  'color': colors['lime'] },
      { 'threshold': 100, 'color': colors['lime'] } ])
    #block.set_border(colors["blue"], 0, 1, 0, 1)
  else:
    #block.set_urgent()
    pass

  block.status_block.set_min_width(40, 'right')
  return block.to_json()
Example #4
0
def blockify_battery():
  """ Print the current battery level. """

  block = StatusUnit('battery')
  block.set_icon('')

  acpi = executor.run('acpi -b')[0]
  battery = re.search('\d*%', acpi).group(0)
  battery_int = int(battery[:-1])
  is_charging = bool(re.search('Charging|Unknown', acpi))

  if is_charging:
    block.set_icon('')
  elif battery_int > 90:
    block.set_icon('')
  elif battery_int > 50:
    block.set_icon('')
  elif battery_int > 20:
    block.set_icon('')
  else:
    block.set_icon('')

  block.set_text(battery)

  if battery_int > 10 or is_charging:
    color = get_color_gradient(battery_int, [ 
      { 'threshold': 0,   'color': colors['urgent'] },
      { 'threshold': 20,  'color': colors['urgent'] },
      { 'threshold': 80,  'color': colors['blue'] },
      { 'threshold': 100, 'color': colors['blue'] } ])
    block.set_border(color, 0, TOP_BORDER_WIDTH, 0, 0)
  else:
    block.set_urgent()

  block.status_block.set_min_width(40, 'right')
  return block.to_json()