Coder Social home page Coder Social logo

Refresh bar about barpyrus HOT 6 CLOSED

t-wissmann avatar t-wissmann commented on June 23, 2024
Refresh bar

from barpyrus.

Comments (6)

AckslD avatar AckslD commented on June 23, 2024 2

I updated it a bit to also show a bluetooth symbol if bluetooth speakers are used, works for me but port name might be different for others

  # Colors
  gray = '%{F\\#989898}'
  green = '%{F\\#9fbc00}'
  blue = '%{F\\#0000ff}'
  pink = '%{F\\#f268ae}'
  light_blue = '%{F\\#28b4c9}'
  purple = '%{F\\#b057fd}'
  bright_green = '%{F\\#d3f1e3}'

  # Volume status
  vol_off_symb = gray + '\ue202'
  speaker_symb = purple + '\ue203'
  headphone_symb = purple + '\ue0fd'
  bluetooth_symb = blue + '\ue1b5'
  vol_on_symb = '${if_match \"$pa_sink_active_port_name\" == \"analog-output-headphones\"}'
  vol_on_symb += headphone_symb
  vol_on_symb += '${else}'
  
  vol_on_symb += '${if_match \"$pa_sink_active_port_name\" == \"headset-output\"}'
  vol_on_symb += headphone_symb + bluetooth_symb
  vol_on_symb += '${else}'
  vol_on_symb += speaker_symb
  vol_on_symb += '${endif}'
  
  vol_on_symb += '${endif}'
  
  volume = '${if_pa_sink_muted}' + vol_off_symb + '${else}' + vol_on_symb + '${endif}'
  volume += gray + '${pa_sink_volume}%'

also added an indicator of wifi quality (similar to how battery was done)

  ########                                                 
  # wifi #                                          
  ########
  wifi_icons = ['\ue218', '\ue219', '\ue21a']
  wifi_delta = 100 / len(wifi_icons)
  wifi_qual = '${wireless_link_qual_perc wlp0s20f3}'
  wifi = ''
  for i, icon in enumerate(wifi_icons[:-1]):
      wifi += '${if_match ' + wifi_qual + ' < %d}' % ((i + 1) * wifi_delta)
      wifi += light_blue + icon
      wifi += '${else}'
  wifi += light_blue + wifi_icons[-1]  # 100 %
  for _ in range(len(wifi_icons) - 1):
      wifi += '${endif}'
  wifi += gray + ' ' + wifi_qual + '%'

which gets added to my list of things as

  conky_elements = [
      test,
      mail,
      wifi,
      volume,
      disk_usage,
      cpu,
      ram,
      # net_down_speed,
      # net_up_speed,
      battery,
      uptime,
  ]
  
  conky_text = ' '.join(conky_elements) + ' '

from barpyrus.

t-wissmann avatar t-wissmann commented on June 23, 2024 1

The $battery variable comes from conky (see man conky). Conky also comes with many options for displaying the volume (pa_sink_volume, if_mixer_mute, etc). Maybe this does directly what you are trying to accomplish.

Regarding the refresh rate, you can pass
config = {'update_interval': '2'} to ConkyWidget. For all available options here, see the section CONFIGURATION SETTINGS in the conky man page.

I don't think it's possible to make conky refresh automatically when the volume changes. The best solution is probably to implement a volume control directly as a barpyrus widget.

from barpyrus.

AckslD avatar AckslD commented on June 23, 2024

Awesome thanks, I'll try this out!

from barpyrus.

AckslD avatar AckslD commented on June 23, 2024

Works great, first neither $mixer nor $pa_sink_volume worked for me but after installing conky-all $pa_sink_volume started working (but not $mixer).

from barpyrus.

AckslD avatar AckslD commented on June 23, 2024

Here's how I added volume indicator:

gray = '%{F\\#989898}'
green = '%{F\\#9fbc00}'
vol_off_symb = gray + '\ue202'
speaker_symb = green + '\ue203'
headphone_symb = green + '\ue0fd'
vol_on_symb = '${if_match \"$pa_sink_active_port_name\" == \"analog-output-speaker\"}' + speaker_symb + '${else}' + headphone_symb + '${endif}'
conky_text = ''
conky_text += '${if_pa_sink_muted}' + vol_off_symb + '${else}' + vol_on_symb + '${endif}'
conky_text += gray + '${pa_sink_volume}% '

showing if volume is on/off and if headphone are plugged in.

from barpyrus.

t-wissmann avatar t-wissmann commented on June 23, 2024

Great! Thanks for sharing!

from barpyrus.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.