Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh bar #9

Closed
AckslD opened this issue Apr 19, 2020 · 6 comments
Closed

Refresh bar #9

AckslD opened this issue Apr 19, 2020 · 6 comments

Comments

@AckslD
Copy link
Contributor

AckslD commented Apr 19, 2020

I just tried this bar with herbstluftwm and works really nice :) I've did some small tweaks and added something to display the volume status. However, it only updates quite rarely. How can I control the refresh-rate, or ideally can it be configured to refresh when for example a certain key is pressed or headphones are plugged in?

Thanks in advance!

PS, here's my battery status, I added the following to the start of conky_text:

conky_text = '%{F\\#9fbc00}%{T2}'
conky_text += '${if_match \"${exec getvolume}\" == \"off\"}\ue202$else\ue203$endif'
conky_text += '%{T-}%{F\\#989898}${exec getvolume} '

where getvolume is a script I have to retrieve the volume from amixer. Can I use the output of getvolume in a variable to not have to call it twice? For example, where does the $battery variable come from?

@t-wissmann
Copy link
Owner

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.

@AckslD
Copy link
Contributor Author

AckslD commented Apr 19, 2020

Awesome thanks, I'll try this out!

@AckslD
Copy link
Contributor Author

AckslD commented Apr 19, 2020

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).

@AckslD AckslD closed this as completed Apr 19, 2020
@AckslD
Copy link
Contributor Author

AckslD commented Apr 19, 2020

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.

@t-wissmann
Copy link
Owner

Great! Thanks for sharing!

@AckslD
Copy link
Contributor Author

AckslD commented Apr 20, 2020

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) + ' '

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants