moved all desktop utils into this repo
This commit is contained in:
parent
cd7e93374e
commit
2241d30a86
28 changed files with 151 additions and 45 deletions
|
@ -1,10 +1,36 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
FILE_TO_WATCH="/sys/class/backlight/intel_backlight/brightness" # Replace with the actual file path
|
||||
brightness_file="/sys/class/backlight/intel_backlight/brightness"
|
||||
min_brightness=1
|
||||
max_brightness=96000
|
||||
|
||||
cat "$FILE_TO_WATCH"
|
||||
# Check if an argument is provided
|
||||
if [[ -z $1 ]]; then
|
||||
# echo "Error: Number argument is missing."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while true; do
|
||||
inotifywait -e modify "$FILE_TO_WATCH"
|
||||
cat "$FILE_TO_WATCH"
|
||||
done
|
||||
# Retrieve the argument value
|
||||
number_to_add=$1
|
||||
|
||||
# Validate if the argument is a number
|
||||
if ! [[ $number_to_add =~ ^-?[0-9]+$ ]]; then
|
||||
# echo "Error: Invalid number argument."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Read the current brightness value from the file
|
||||
current_brightness=$(cat "$brightness_file")
|
||||
|
||||
# Add the desired number to the current brightness
|
||||
new_brightness=$((current_brightness + number_to_add))
|
||||
|
||||
# Enforce minimum and maximum brightness values
|
||||
if (( new_brightness < min_brightness )); then
|
||||
new_brightness=$min_brightness
|
||||
elif (( new_brightness > max_brightness )); then
|
||||
new_brightness=$max_brightness
|
||||
fi
|
||||
|
||||
# Write the new brightness value back to the file
|
||||
echo "$new_brightness" >> "$brightness_file"
|
Loading…
Add table
Add a link
Reference in a new issue