[~] Refactor
This commit is contained in:
		
							parent
							
								
									27277f3fe6
								
							
						
					
					
						commit
						0a523fe353
					
				
							
								
								
									
										45
									
								
								dotfiles/.local/bin/commands
									
									
									
									
									
										Executable file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										45
									
								
								dotfiles/.local/bin/commands
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,45 @@
 | 
			
		||||
#!/usr/bin/python3
 | 
			
		||||
import traceback
 | 
			
		||||
import sys
 | 
			
		||||
import subprocess
 | 
			
		||||
 | 
			
		||||
msg = ''
 | 
			
		||||
 | 
			
		||||
try:
 | 
			
		||||
    if sys.argv[1] == 'media-play-pause':
 | 
			
		||||
        subprocess.check_call(['playerctl', 'play-pause'])
 | 
			
		||||
        msg = subprocess.check_output(['playerctl', 'status']).decode('utf-8').strip()
 | 
			
		||||
    elif sys.argv[1] == 'media-lower-volume':
 | 
			
		||||
        subprocess.check_call([
 | 
			
		||||
            'pactl',
 | 
			
		||||
            'set-sink-volume',
 | 
			
		||||
            '@DEFAULT_SINK@',
 | 
			
		||||
            '-5%'
 | 
			
		||||
        ])
 | 
			
		||||
        msg = subprocess.check_output([
 | 
			
		||||
            'pactl',
 | 
			
		||||
            'get-sink-volume',
 | 
			
		||||
            '@DEFAULT_SINK@'
 | 
			
		||||
        ]).decode('utf-8').strip()
 | 
			
		||||
    elif sys.argv[1] == 'media-raise-volume':
 | 
			
		||||
        subprocess.check_call([
 | 
			
		||||
            'pactl',
 | 
			
		||||
            'set-sink-volume',
 | 
			
		||||
            '@DEFAULT_SINK@',
 | 
			
		||||
            '+5%'
 | 
			
		||||
        ])
 | 
			
		||||
        msg = subprocess.check_output([
 | 
			
		||||
            'pactl',
 | 
			
		||||
            'get-sink-volume',
 | 
			
		||||
            '@DEFAULT_SINK@'
 | 
			
		||||
        ]).decode('utf-8').strip()
 | 
			
		||||
    else:
 | 
			
		||||
        raise NotImplementedError
 | 
			
		||||
except:
 | 
			
		||||
    msg = 'not implemented\n%s' % traceback.format_exc()
 | 
			
		||||
 | 
			
		||||
subprocess.check_call([
 | 
			
		||||
    'notify-send',
 | 
			
		||||
    'commands',
 | 
			
		||||
    msg
 | 
			
		||||
])
 | 
			
		||||
@ -42,7 +42,13 @@
 | 
			
		||||
"pactl set-sink-mute @DEFAULT_SINK@ toggle; (pactl get-sink-mute @DEFAULT_SINK@ | grep -Po no > /dev/null); echo $? > /sys/class/leds/hda::mute/brightness"
 | 
			
		||||
  XF86AudioMute
 | 
			
		||||
 | 
			
		||||
"playerctl play-pause"
 | 
			
		||||
"commands media-raise-volume"
 | 
			
		||||
  XF86AudioRaiseVolume
 | 
			
		||||
 | 
			
		||||
"commands media-lower-volume"
 | 
			
		||||
  XF86AudioLowerVolume
 | 
			
		||||
 | 
			
		||||
"commands media-play-pause"
 | 
			
		||||
  XF86AudioPlay
 | 
			
		||||
 | 
			
		||||
#"xbindkeys_show" 
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user