[~] 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/.zshrc ~/.zshrc
cp dotfiles/.vimrc ~/.vimrc
cp dotfiles/.tmux.conf ~/.tmux.conf
cp dotfiles/.py3.vimrc ~/.py3.vimrc
cp dotfiles/.py3.vimrc ~/.py3.vimrc
cp dotfiles/.gitconfig ~/.gitconfig

@ -161,8 +161,12 @@ def intercept_output(
def player_metadata():
for k in range(20):
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)
return subprocess.check_output(['playerctl', 'metadata']).decode('utf-8').strip()
except:
continue
@ -2508,15 +2512,16 @@ def desktop_services(argv):
self.bg is None or \
not self.bg.poll() is None
) and not self.bg_terminate:
self.bg = subprocess.Popen([
'swaybg',
'--output',
'*',
'--image',
options.background_image,
'--mode',
'fill',
])
if not options.background_image is None:
self.bg = subprocess.Popen([
'swaybg',
'--output',
'*',
'--image',
options.background_image,
'--mode',
'fill',
])
def background_terminate(self, *args, **kwargs):
if not self.bg is None:
@ -3267,6 +3272,8 @@ def media_keys(argv):
'media-next',
'media-prev',
'media-lower-volume',
'media-raise-volume',
'media-toggle-volume',
]
msg = None
@ -3288,7 +3295,7 @@ def media_keys(argv):
])
return t2['Title'].strip()[:128]
if is_mocp:
if is_mocp():
mode = 'mocp'
else:
mode = 'playerctl'
@ -3332,6 +3339,18 @@ def media_keys(argv):
'get-sink-volume',
'@DEFAULT_SINK@'
]).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':
subprocess.check_call([
'pactl',

@ -84,33 +84,36 @@ bindgesture swipe:4:up exec $lock_cmd
#
bindsym $mod+Shift+l exec $lock_cmd
bindsym XF86KbdBrightnessDown \
bindsym --locked XF86KbdBrightnessDown \
exec commands \
desktop-services \
--backlight-decrease \
--backlight-type keyboard
bindsym XF86KbdBrightnessUp \
bindsym --locked XF86KbdBrightnessUp \
exec commands \
desktop-services \
--backlight-increase \
--backlight-type keyboard
bindsym XF86MonBrightnessDown \
bindsym --locked XF86MonBrightnessDown \
exec commands \
desktop-services \
--backlight-decrease \
--backlight-type output
bindsym XF86MonBrightnessUp \
bindsym --locked XF86MonBrightnessUp \
exec commands \
desktop-services \
--backlight-increase \
--backlight-type output
bindsym XF86AudioPlay exec bash -c "commands media-play-pause"
bindsym XF86AudioNext exec bash -c "commands media-next"
bindsym XF86AudioPrev exec bash -c "commands media-prev"
bindsym --locked XF86AudioPlay exec bash -c "commands media-play-pause"
bindsym --locked XF86AudioRaiseVolume exec bash -c "commands media-raise-volume"
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

@ -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/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"