[~] Refactor

This commit is contained in:
Siarhei Siniak 2024-09-20 18:58:17 +03:00
parent 16a075b19c
commit 6b7bef9c07
4 changed files with 42 additions and 18 deletions

@ -7,6 +7,7 @@ cp dotfiles/.sway/config ~/.sway/config
cp dotfiles/.zshenv ~/.zshenv cp dotfiles/.zshenv ~/.zshenv
cp dotfiles/.zshrc ~/.zshrc cp dotfiles/.zshrc ~/.zshrc
cp dotfiles/.vimrc ~/.vimrc cp dotfiles/.vimrc ~/.vimrc
cp dotfiles/.tmux.conf ~/.tmux.conf
cp dotfiles/.py3.vimrc ~/.py3.vimrc cp dotfiles/.py3.vimrc ~/.py3.vimrc
cp dotfiles/.py3.vimrc ~/.py3.vimrc cp dotfiles/.py3.vimrc ~/.py3.vimrc
cp dotfiles/.gitconfig ~/.gitconfig cp dotfiles/.gitconfig ~/.gitconfig

@ -161,8 +161,12 @@ def intercept_output(
def player_metadata(): def player_metadata():
for k in range(20): for k in range(20):
try: try:
metadata = {
k : subprocess.check_output(['playerctl', 'metadata', k]).decode('utf-8').strip()
for k in ['artist', 'title']
}
return '%s - %s' % (metadata['artist'], metadata['title'])
time.sleep(1.0) time.sleep(1.0)
return subprocess.check_output(['playerctl', 'metadata']).decode('utf-8').strip()
except: except:
continue continue
@ -2508,6 +2512,7 @@ def desktop_services(argv):
self.bg is None or \ self.bg is None or \
not self.bg.poll() is None not self.bg.poll() is None
) and not self.bg_terminate: ) and not self.bg_terminate:
if not options.background_image is None:
self.bg = subprocess.Popen([ self.bg = subprocess.Popen([
'swaybg', 'swaybg',
'--output', '--output',
@ -3267,6 +3272,8 @@ def media_keys(argv):
'media-next', 'media-next',
'media-prev', 'media-prev',
'media-lower-volume', 'media-lower-volume',
'media-raise-volume',
'media-toggle-volume',
] ]
msg = None msg = None
@ -3288,7 +3295,7 @@ def media_keys(argv):
]) ])
return t2['Title'].strip()[:128] return t2['Title'].strip()[:128]
if is_mocp: if is_mocp():
mode = 'mocp' mode = 'mocp'
else: else:
mode = 'playerctl' mode = 'playerctl'
@ -3332,6 +3339,18 @@ def media_keys(argv):
'get-sink-volume', 'get-sink-volume',
'@DEFAULT_SINK@' '@DEFAULT_SINK@'
]).decode('utf-8').strip() ]).decode('utf-8').strip()
elif options.command == 'media-toggle-volume':
subprocess.check_call([
'pactl',
'set-sink-mute',
'@DEFAULT_SINK@',
'toggle',
])
msg = subprocess.check_output([
'pactl',
'get-sink-volume',
'@DEFAULT_SINK@'
]).decode('utf-8').strip()
elif options.command == 'media-raise-volume': elif options.command == 'media-raise-volume':
subprocess.check_call([ subprocess.check_call([
'pactl', 'pactl',

@ -84,33 +84,36 @@ bindgesture swipe:4:up exec $lock_cmd
# #
bindsym $mod+Shift+l exec $lock_cmd bindsym $mod+Shift+l exec $lock_cmd
bindsym XF86KbdBrightnessDown \ bindsym --locked XF86KbdBrightnessDown \
exec commands \ exec commands \
desktop-services \ desktop-services \
--backlight-decrease \ --backlight-decrease \
--backlight-type keyboard --backlight-type keyboard
bindsym XF86KbdBrightnessUp \ bindsym --locked XF86KbdBrightnessUp \
exec commands \ exec commands \
desktop-services \ desktop-services \
--backlight-increase \ --backlight-increase \
--backlight-type keyboard --backlight-type keyboard
bindsym XF86MonBrightnessDown \ bindsym --locked XF86MonBrightnessDown \
exec commands \ exec commands \
desktop-services \ desktop-services \
--backlight-decrease \ --backlight-decrease \
--backlight-type output --backlight-type output
bindsym XF86MonBrightnessUp \ bindsym --locked XF86MonBrightnessUp \
exec commands \ exec commands \
desktop-services \ desktop-services \
--backlight-increase \ --backlight-increase \
--backlight-type output --backlight-type output
bindsym XF86AudioPlay exec bash -c "commands media-play-pause" bindsym --locked XF86AudioPlay exec bash -c "commands media-play-pause"
bindsym XF86AudioNext exec bash -c "commands media-next" bindsym --locked XF86AudioRaiseVolume exec bash -c "commands media-raise-volume"
bindsym XF86AudioPrev exec bash -c "commands media-prev" bindsym --locked XF86AudioLowerVolume exec bash -c "commands media-lower-volume"
bindsym --locked XF86AudioMute exec bash -c "commands media-toggle-volume"
bindsym --locked XF86AudioNext exec bash -c "commands media-next"
bindsym --locked XF86AudioPrev exec bash -c "commands media-prev"
# Start a terminal # Start a terminal

@ -1,2 +1,3 @@
ACTION=="add|change", SUBSYSTEM=="leds", DEVPATH=="/devices/pci0000:00/0000:00:1b.0/hdaudioC0D0/leds/hda::mute", RUN{program}+="/usr/bin/chmod 666 /sys$devpath/brightness" ACTION=="add|change", SUBSYSTEM=="leds", DEVPATH=="/devices/pci0000:00/0000:00:1b.0/hdaudioC0D0/leds/hda::mute", RUN{program}+="/usr/bin/chmod 666 /sys$devpath/brightness"
ACTION=="add|change", SUBSYSTEM=="leds", DEVPATH=="/devices/platform/applesmc.768/leds/smc::kbd_backlight", RUN{program}+="/usr/bin/chmod 666 /sys$devpath/brightness" ACTION=="add|change", SUBSYSTEM=="leds", DEVPATH=="/devices/platform/applesmc.768/leds/smc::kbd_backlight", RUN{program}+="/usr/bin/chmod 666 /sys$devpath/brightness"
ACTION=="add|change", DEVPATH=="/class/backlight/intel_backlight", RUN{program}+="/usr/bin/chmod 666 /sys$devpath/brightness"