cfg/.config/i3blocks/volume

29 lines
575 B
Text
Raw Normal View History

#!/usr/bin/env python
import subprocess
def main():
volume = subprocess.check_output([
'pulsemixer', '--get-volume',
]).decode('utf-8').strip().split(' ')
minvol = min([int(i) for i in volume])
mute = int(subprocess.check_output([
'pulsemixer', '--get-mute',
]).decode('utf-8').strip()) == 1
icon = '\uf6a9' if mute else '\uf6a8'
text = '{} {}%'.format(icon, minvol)
color = '#7f7f7f' if mute else '#ffffff'
print('\n'.join([
text,
text,
color,
]))
if __name__ == '__main__':
main()