From 999954766efbe6f6cd7e3deec82d8f99fe7e3847 Mon Sep 17 00:00:00 2001 From: Salyrus Date: Sun, 5 Dec 2021 09:28:54 +0100 Subject: [PATCH] Added adaptive icon, changing based on the brightness value. Increased default interval. Updated README. --- README.md | 13 +++++++------ src/brightnessctl.sh | 15 ++++++++++++++- src/config | 5 ++--- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d3cef93..6a84ba2 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ The brightnessctl package is the only one that managed to change the brightness ### Installation 1. Download the files as a ZIP or clone into a temporary directory. -2. Move `brightnessctl.sh` to `~/.config/polybar/` file. -3. Make `brightnessctl.sh` executable by executing `chmod u+x ~/.config/polybar/brightnessctl.sh`. +2. Move `brightnessctl.sh` to `~/.config/polybar/` folder. +3. Make `brightnessctl.sh` executable by executing `chmod +x ~/.config/polybar/brightnessctl.sh`. 4. Decide where you will put the module. Depending on your choice, add `brightnessctl` to the `modules-left`,`modules-center` or `modules-right` variable in your polybar config file. 5. Add the following lines to the `~/.config/polybar/config` file: @@ -17,12 +17,13 @@ exec = ~/.config/polybar/brightnessctl.sh scroll-up = exec brightnessctl set +5% scroll-down = exec brightnessctl set 5%- -interval = 0.2 +interval = 0.5 -format-prefix = " " label = %output% -label-foreground = #FFFFFF +label-foreground = ${colors.foreground} ``` +6. Adjust the `interval` and `label-foreground` values to your liking. + ### Note -- This module uses a custom icon from the `MaterialIcons` font package. If you do not have this you may install it, or choose your own gliph, simply replace the character that is assigned to `format-prefix`. +- This module uses custom icons from the `MaterialIcons` font package by Google. If you do not have this you may install it (it's most likely in your repository), or choose your own gliph, simply replace the character that is assigned to `format-prefix`. diff --git a/src/brightnessctl.sh b/src/brightnessctl.sh index 79301a9..261c4d9 100755 --- a/src/brightnessctl.sh +++ b/src/brightnessctl.sh @@ -1,3 +1,16 @@ #!/bin/bash -echo "$(brightnessctl | grep -o "(.*" | tr -d "()")" +BRIGHTNESS_VALUE=`brightnessctl | grep -o "(.*" | tr -d "()"` +BRIGHTNESS_NR=${BRIGHTNESS_VALUE//%} + +if [ $BRIGHTNESS_NR -lt 20 ]; then + BRIGHTNESS_ICON='' +elif [ $BRIGHTNESS_NR -lt 50 ]; then + BRIGHTNESS_ICON='' +elif [ $BRIGHTNESS_NR -lt 80 ]; then + BRIGHTNESS_ICON='' +else + BRIGHTNESS_ICON='' +fi + +echo "$BRIGHTNESS_ICON $BRIGHTNESS_VALUE" diff --git a/src/config b/src/config index 3e2dbf1..7178d67 100644 --- a/src/config +++ b/src/config @@ -15,8 +15,7 @@ exec = ~/.config/polybar/brightnessctl.sh scroll-up = exec brightnessctl set +5% scroll-down = exec brightnessctl set 5%- -interval = 0.2 +interval = 0.5 -format-prefix = " " label = %output% -label-foreground = #FFFFFF +label-foreground = ${colors.foreground}