Skip to content

Instantly share code, notes, and snippets.

@naranyala
Last active May 21, 2024 10:24
Show Gist options
  • Save naranyala/0419dcbc3d1e9bcf69924573310b5f64 to your computer and use it in GitHub Desktop.
Save naranyala/0419dcbc3d1e9bcf69924573310b5f64 to your computer and use it in GitHub Desktop.
easy select brightness in range
#!/bin/bash
# Define the brightness levels as percentages
levels="0\n5\n10\n15\n20\n25\n30\n35\n40\n45\n50\n55\n60\n65\n70\n75\n80\n85\n90\n95\n100"
# Use rofi to select a brightness level
chosen=$(echo -e "$levels" | rofi -dmenu -p "Set Brightness Level")
# If the user made a selection, set the brightness and print the chosen level
if [ -n "$chosen" ]; then
# Calculate the actual brightness value
max_brightness=$(brightnessctl m)
actual_brightness=$((chosen * max_brightness / 100))
brightnessctl set "$actual_brightness"
echo "$chosen%"
else
echo "No brightness level selected."
fi
# [module/rofi-light-range]
# type = custom/script
# exec = brightnessctl g | awk -v max=$(brightnessctl m) '{print int($1 * 100 / max) "%"}'
# interval = 0.5
# label = "[light:%output%]"
# click-left = ~/.config/polybar/scripts/rofi-brightness-range.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment