From 935e9a8fafdfb52c429afb5d45d5deaa374754ce Mon Sep 17 00:00:00 2001 From: Siarhei Siniak Date: Wed, 25 Jan 2023 16:29:00 +0300 Subject: [PATCH] [~] Refactor --- d1/f1-root.sh | 6 ++++ dotfiles/.local/bin/commands | 47 +++++++++++++++++++++++++ dotfiles/.sway/config | 3 ++ dotfiles/etc/archlinux/packages.sh | 1 + dotfiles/etc/udev/rules.d/40-leds.rules | 1 + 5 files changed, 58 insertions(+) create mode 100644 d1/f1-root.sh create mode 100644 dotfiles/etc/archlinux/packages.sh diff --git a/d1/f1-root.sh b/d1/f1-root.sh new file mode 100644 index 0000000..7ff6572 --- /dev/null +++ b/d1/f1-root.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +echo user; +whoami +echo udev rules; +sudo cp dotfiles/etc/udev/rules.d/40-leds.rules /etc/udev/rules.d/40-leds.rules diff --git a/dotfiles/.local/bin/commands b/dotfiles/.local/bin/commands index 37ef787..710ab20 100755 --- a/dotfiles/.local/bin/commands +++ b/dotfiles/.local/bin/commands @@ -1200,9 +1200,56 @@ def desktop_services(argv): type=int, help='0 - mac book air (no turbo boost, max pct 30, every 4 seconds', ) + parser.add_option( + '--backlight-increase', + dest='backlight_increase', + default=False, + action='store_true', + help='increase keyboard backlight', + ) + parser.add_option( + '--backlight-decrease', + dest='backlight_decrease', + default=False, + action='store_true', + help='decrease keyboard backlight', + ) options, args = parser.parse_args(argv) + if options.backlight_increase or options.backlight_decrease: + if sys.platform == 'linux': + leds = \ + [ + o.strip() + for o in subprocess.check_output(['light', '-L'])\ + .decode('utf-8')\ + .splitlines()[1:] + ] + + if 'sysfs/leds/smc::kbd_backlight' in leds: + extra_args = [] + if options.backlight_increase: + extra_args.extend(['-A', '20']) + elif options.backlight_decrease: + extra_args.extend(['-U', '20']) + else: + raise NotImplementedError + + subprocess.check_call([ + 'light', '-v', '3', + '-s', 'sysfs/leds/smc::kbd_backlight', + *extra_args, + ]) + else: + raise NotImplementedError + + else: + raise NotImplementedError + return + else: + pass + os.environ['SWAYSOCK'] = sway_sock() assert all([ diff --git a/dotfiles/.sway/config b/dotfiles/.sway/config index 967693c..12e8686 100644 --- a/dotfiles/.sway/config +++ b/dotfiles/.sway/config @@ -73,6 +73,9 @@ input type:touchpad { # bindsym $mod+Shift+l exec loginctl list-sessions | tail '-n' +2 | head -n -2 | awk '{print $1}' | xargs loginctl lock-session +bindsym XF86KbdBrightnessDown exec bash -c "commands desktop-services --backlight-decrease" +bindsym XF86KbdBrightnessUp exec bash -c "commands desktop-services --backlight-increase" + # Start a terminal bindsym $mod+t exec $term diff --git a/dotfiles/etc/archlinux/packages.sh b/dotfiles/etc/archlinux/packages.sh new file mode 100644 index 0000000..b05ca4f --- /dev/null +++ b/dotfiles/etc/archlinux/packages.sh @@ -0,0 +1 @@ +yay -S light diff --git a/dotfiles/etc/udev/rules.d/40-leds.rules b/dotfiles/etc/udev/rules.d/40-leds.rules index 1842753..c1a55ed 100644 --- a/dotfiles/etc/udev/rules.d/40-leds.rules +++ b/dotfiles/etc/udev/rules.d/40-leds.rules @@ -1 +1,2 @@ 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"