diff options
author | venomade <venomade@venomade.com> | 2025-02-27 17:06:42 +0000 |
---|---|---|
committer | venomade <venomade@venomade.com> | 2025-02-27 17:06:42 +0000 |
commit | 1cace80e4832a5d250ef4b7ccd687996563fb01b (patch) | |
tree | db1ced91d1382ca3cabe37dbae00da51231d6a99 /nixos/scripts/get-brightness |
Add old dotfiles
Diffstat (limited to 'nixos/scripts/get-brightness')
-rwxr-xr-x | nixos/scripts/get-brightness | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/nixos/scripts/get-brightness b/nixos/scripts/get-brightness new file mode 100755 index 0000000..4531c16 --- /dev/null +++ b/nixos/scripts/get-brightness @@ -0,0 +1,22 @@ +#!/bin/sh + +# Get the current brightness level as a percentage +brightness=$(brightnessctl g) +max_brightness=$(brightnessctl m) + +# Perform float division and store the result with 2 decimal points +result=$(awk "BEGIN { printf \"%.2f\", $brightness / $max_brightness }") + +# Convert the result to a percentage (multiply by 100) and round to the nearest whole number +percentage=$(awk "BEGIN { printf \"%.0f\", $result * 100 }") + +# Set the icon based on the brightness level +if [ $percentage -le 33 ]; then + icon="" +elif [ $percentage -le 66 ]; then + icon="" +else + icon="" +fi + +echo "$icon $percentage%" |