From 057348f9ec5700f5a5e0f07f54e0153e54e2abe5 Mon Sep 17 00:00:00 2001 From: Jaden Provost Maxwell-Comfort Date: Sat, 6 Jan 2024 10:55:30 -0800 Subject: [PATCH] Updated brightness to use a custom bash script instead of brightnessctl --- .config/i3/brightness.sh | 22 ++++++++++++++++++++++ .config/i3/config | 4 ++-- .config/polybar/config.ini | 6 +++--- 3 files changed, 27 insertions(+), 5 deletions(-) create mode 100755 .config/i3/brightness.sh diff --git a/.config/i3/brightness.sh b/.config/i3/brightness.sh new file mode 100755 index 0000000..4000c83 --- /dev/null +++ b/.config/i3/brightness.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +if [[ $# != 1 ]]; then + echo "Usage: $0 " + echo "Example: $0 5 # Increase brighness by 5%" + echo "Example: $0 -5 # Decrease brighness by 5%" + exit 1 +fi + +file_root="/sys/class/backlight/$(ls /sys/class/backlight | head -n 1)" +max=$(cat "$file_root/max_brightness") +current=$(cat "$file_root/actual_brightness") +new=$(($current + ($max / 100 * $1))) + + +if [ "$new" -ge "$max" ]; then + echo "$max" > $file_root/brightness +elif [ "$new" -le "0" ]; then + echo "0" > $file_root/brightness +else + echo "$new" > $file_root/brightness +fi diff --git a/.config/i3/config b/.config/i3/config index b72e420..e7a51cf 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -154,8 +154,8 @@ bindsym l resize shrink width 10 px or 10 ppt bindsym $mod+r mode "resize" # Brightness keys setup -bindsym XF86MonBrightnessDown exec --no-startup-id "brightnessctl set 5%-" -bindsym XF86MonBrightnessUp exec --no-startup-id "brightnessctl set +5%" +bindsym XF86MonBrightnessDown exec --no-startup-id "sudo $HOME/.config/i3/brightness.sh -5" +bindsym XF86MonBrightnessUp exec --no-startup-id "sudo $HOME/.config/i3/brightness.sh 5" # Window Cosmetic Changes gaps inner 10 diff --git a/.config/polybar/config.ini b/.config/polybar/config.ini index 1c7074d..9bac7ee 100644 --- a/.config/polybar/config.ini +++ b/.config/polybar/config.ini @@ -52,7 +52,7 @@ separator-foreground = ${colors.disabled} font-0 = monospace;2 modules-left = xworkspaces xwindow -modules-right = filesystem brightness pulseaudio memory cpu battery network date +modules-right = filesystem brightness alsa memory cpu battery network date cursor-click = pointer cursor-scroll = ns-resize @@ -100,8 +100,8 @@ label-mounted = %{F#0000FF}%mountpoint%%{F-} %percentage_used%% label-unmounted = %mountpoint% not mounted label-unmounted-foreground = ${colors.disabled} -[module/pulseaudio] -type = internal/pulseaudio +[module/alsa] +type = internal/alsa format-volume-prefix = "VOL " format-volume-prefix-foreground = ${colors.primary}