Laptop control, udev rules, xorg configs, README

This commit is contained in:
2021-11-09 15:00:53 +00:00
parent d3e2e9bab2
commit 61a54ec64c
8 changed files with 142 additions and 1 deletions

34
bin/brightness_down Normal file
View File

@@ -0,0 +1,34 @@
#!/bin/bash
# Check if AMD or NVIDIA GPU is connected
BrPath=
for Dir in /sys/class/backlight/amdgpu_*
do
if [ -d "$Dir" ]
then
BrPath="$Dir"
break
fi
done
if [ -d "$BrPath" ]
then
:
# echo "Found AMD GPU folder $BrPath"
else
BrPath=/sys/class/backlight/nvidia_0
# echo "Didn't find AMD GPU, defaulting to $BrPath"
fi
# Step brightness by 10%
BrCur=$(cat $BrPath/brightness)
BrMax=$(cat $BrPath/max_brightness)
BrStep=$(($BrMax/10))
if [ "$(($BrCur - $BrStep))" -lt "$BrStep" ]
then
echo "$BrStep" > "${BrPath}/brightness"
else
BrCur=$(($BrCur-$BrStep))
echo "$BrCur" > "${BrPath}/brightness"
fi

34
bin/brightness_up Normal file
View File

@@ -0,0 +1,34 @@
#!/bin/bash
# Check if AMD or NVIDIA GPU is connected
BrPath=
for Dir in /sys/class/backlight/amdgpu_*
do
if [ -d "$Dir" ]
then
BrPath="$Dir"
break
fi
done
if [ -d "$BrPath" ]
then
:
#echo "Found AMD GPU folder $BrPath"
else
BrPath=/sys/class/backlight/nvidia_0
#echo "Didn't find AMD GPU, defaulting to $BrPath"
fi
# Step brightness by 10%
BrCur=$(cat $BrPath/brightness)
BrMax=$(cat $BrPath/max_brightness)
BrStep=$(($BrMax/10))
if [ "$(($BrCur + $BrStep))" -gt "$BrMax" ]
then
echo "$BrMax" > "${BrPath}/brightness"
else
BrCur=$(($BrCur+$BrStep))
echo "$BrCur" > "${BrPath}/brightness"
fi

15
bin/conservation_mode Normal file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
# Run as sudo
[ "$UID" -eq 0 ] || exec sudo "$0" "$@"
Mode=$(cat /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode)
if [ "$Mode" -eq "1" ]
then
echo 0 > /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode
echo "Battery Conservation Mode is now inactive"
else
echo 1 > /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode
echo "Battery Conservation Mode is now active"
fi

28
bin/power_saving_mode Normal file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
# Run as sudo
[ "$UID" -eq 0 ] || exec sudo "$0" "$@"
if [ "$1" == "on" ]
then
for file in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
do
echo "powersave" > $file;
done
xrandr --output DP-4 --mode 2560x1600 --rate 60 > /dev/null 2>&1
xrandr --output eDP-1 --mode 2560x1600 --rate 60 > /dev/null 2>&1
for i in {1..3}; do brightness_down; done
echo "Power Saving Mode is now active"
elif [ "$1" == "off" ]
then
for file in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
do
echo "schedutil" > $file;
done
xrandr --output DP-4 --mode 2560x1600 --rate 165 > /dev/null 2>&1
xrandr --output eDP-1 --mode 2560x1600 --rate 165 > /dev/null 2>&1
for i in {1..3}; do brightness_up; done
echo "Power Saving Mode is now inactive"
else
echo "Usage: power_saving_mode [on/off]"
fi