Closed AckslD closed 4 years ago
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.
Awesome thanks, I'll try this out!
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
).
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.
Great! Thanks for sharing!
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) + ' '
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
:where
getvolume
is a script I have to retrieve the volume fromamixer
. Can I use the output ofgetvolume
in a variable to not have to call it twice? For example, where does the$battery
variable come from?