Merge pull request #34 from scollado/feature-brightnessctl

Add support for `brightnessctl` for blacklight control
This commit is contained in:
Aditya Shakya 2021-09-01 01:16:52 +05:30 committed by GitHub
commit ec0a1678aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 127 additions and 61 deletions

View File

@ -14,7 +14,12 @@ msg() {
} }
## Get Brightness ## Get Brightness
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
BNESS="$(brightnessctl get)"
MAX="$(brightnessctl max)"
PERC="$((BNESS*100/MAX))"
BLIGHT=${PERC%.*}
elif [[ -f /usr/bin/blight ]]; then
DEVICE=$(ls /sys/class/backlight | head -n 1) DEVICE=$(ls /sys/class/backlight | head -n 1)
BNESS="$(blight -d $DEVICE get brightness)" BNESS="$(blight -d $DEVICE get brightness)"
PERC="$(($BNESS*100/255))" PERC="$(($BNESS*100/255))"
@ -48,23 +53,29 @@ options="$ICON_UP\n$ICON_OPT\n$ICON_DOWN"
## Main ## Main
chosen="$(echo -e "$options" | $rofi_command -p "$BLIGHT%" -dmenu -selected-row 1)" chosen="$(echo -e "$options" | $rofi_command -p "$BLIGHT%" -dmenu -selected-row 1)"
case $chosen in case $chosen in
$ICON_UP) "$ICON_UP")
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
blight -d $DEVICE set +10% && $notify "Brightness Up $ICON_UP" brightnessctl -q set +10% && $notify "Brightness Up $ICON_UP"
elif [[ -f /usr/bin/blight ]]; then
blight -d "$DEVICE" set +10% && $notify "Brightness Up $ICON_UP"
elif [[ -f /usr/bin/xbacklight ]]; then elif [[ -f /usr/bin/xbacklight ]]; then
xbacklight -inc 10 && $notify "Brightness Up $ICON_UP" xbacklight -inc 10 && $notify "Brightness Up $ICON_UP"
fi fi
;; ;;
$ICON_DOWN) "$ICON_DOWN")
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
blight -d $DEVICE set -10% && $notify "Brightness Down $ICON_DOWN" brightnessctl -q set 10%- && $notify "Brightness Down $ICON_DOWN"
elif [[ -f /usr/bin/blight ]]; then
blight -d "$DEVICE" set -10% && $notify "Brightness Down $ICON_DOWN"
elif [[ -f /usr/bin/xbacklight ]]; then elif [[ -f /usr/bin/xbacklight ]]; then
xbacklight -dec 10 && $notify "Brightness Down $ICON_DOWN" xbacklight -dec 10 && $notify "Brightness Down $ICON_DOWN"
fi fi
;; ;;
$ICON_OPT) "$ICON_OPT")
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
blight -d $DEVICE set 25% && $notify "Optimal Brightness $ICON_OPT" brightnessctl -q set 25% && $notify "Optimal Brightness $ICON_OPT"
elif [[ -f /usr/bin/blight ]]; then
blight -d "$DEVICE" set 25% && $notify "Optimal Brightness $ICON_OPT"
elif [[ -f /usr/bin/xbacklight ]]; then elif [[ -f /usr/bin/xbacklight ]]; then
xbacklight -set 30 && $notify "Optimal Brightness $ICON_OPT" xbacklight -set 30 && $notify "Optimal Brightness $ICON_OPT"
fi fi

View File

@ -16,7 +16,12 @@ msg() {
} }
## Get Brightness ## Get Brightness
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
BNESS="$(brightnessctl get)"
MAX="$(brightnessctl max)"
PERC="$((BNESS*100/MAX))"
BLIGHT=${PERC%.*}
elif [[ -f /usr/bin/blight ]]; then
DEVICE=$(ls /sys/class/backlight | head -n 1) DEVICE=$(ls /sys/class/backlight | head -n 1)
BNESS="$(blight -d $DEVICE get brightness)" BNESS="$(blight -d $DEVICE get brightness)"
PERC="$(($BNESS*100/255))" PERC="$(($BNESS*100/255))"
@ -50,23 +55,29 @@ options="$ICON_UP\n$ICON_OPT\n$ICON_DOWN"
## Main ## Main
chosen="$(echo -e "$options" | $rofi_command -p "$BLIGHT%" -dmenu -selected-row 1)" chosen="$(echo -e "$options" | $rofi_command -p "$BLIGHT%" -dmenu -selected-row 1)"
case $chosen in case $chosen in
$ICON_UP) "$ICON_UP")
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
blight -d $DEVICE set +10% && $notify "Brightness Up $ICON_UP" brightnessctl -q set +10% && $notify "Brightness Up $ICON_UP"
elif [[ -f /usr/bin/blight ]]; then
blight -d "$DEVICE" set +10% && $notify "Brightness Up $ICON_UP"
elif [[ -f /usr/bin/xbacklight ]]; then elif [[ -f /usr/bin/xbacklight ]]; then
xbacklight -inc 10 && $notify "Brightness Up $ICON_UP" xbacklight -inc 10 && $notify "Brightness Up $ICON_UP"
fi fi
;; ;;
$ICON_DOWN) "$ICON_DOWN")
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
blight -d $DEVICE set -10% && $notify "Brightness Down $ICON_DOWN" brightnessctl -q set 10%- && $notify "Brightness Down $ICON_DOWN"
elif [[ -f /usr/bin/blight ]]; then
blight -d "$DEVICE" set -10% && $notify "Brightness Down $ICON_DOWN"
elif [[ -f /usr/bin/xbacklight ]]; then elif [[ -f /usr/bin/xbacklight ]]; then
xbacklight -dec 10 && $notify "Brightness Down $ICON_DOWN" xbacklight -dec 10 && $notify "Brightness Down $ICON_DOWN"
fi fi
;; ;;
$ICON_OPT) "$ICON_OPT")
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
blight -d $DEVICE set 25% && $notify "Optimal Brightness $ICON_OPT" brightnessctl -q set 25% && $notify "Optimal Brightness $ICON_OPT"
elif [[ -f /usr/bin/blight ]]; then
blight -d "$DEVICE" set 25% && $notify "Optimal Brightness $ICON_OPT"
elif [[ -f /usr/bin/xbacklight ]]; then elif [[ -f /usr/bin/xbacklight ]]; then
xbacklight -set 30 && $notify "Optimal Brightness $ICON_OPT" xbacklight -set 30 && $notify "Optimal Brightness $ICON_OPT"
fi fi

View File

@ -16,7 +16,12 @@ msg() {
} }
## Get Brightness ## Get Brightness
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
BNESS="$(brightnessctl get)"
MAX="$(brightnessctl max)"
PERC="$((BNESS*100/MAX))"
BLIGHT=${PERC%.*}
elif [[ -f /usr/bin/blight ]]; then
DEVICE=$(ls /sys/class/backlight | head -n 1) DEVICE=$(ls /sys/class/backlight | head -n 1)
BNESS="$(blight -d $DEVICE get brightness)" BNESS="$(blight -d $DEVICE get brightness)"
PERC="$(($BNESS*100/255))" PERC="$(($BNESS*100/255))"
@ -50,23 +55,29 @@ options="$ICON_UP\n$ICON_OPT\n$ICON_DOWN"
## Main ## Main
chosen="$(echo -e "$options" | $rofi_command -p "$BLIGHT% : $MSG" -dmenu -selected-row 1)" chosen="$(echo -e "$options" | $rofi_command -p "$BLIGHT% : $MSG" -dmenu -selected-row 1)"
case $chosen in case $chosen in
$ICON_UP) "$ICON_UP")
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
blight -d $DEVICE set +10% && $notify "Brightness Up $ICON_UP" brightnessctl -q set +10% && $notify "Brightness Up $ICON_UP"
elif [[ -f /usr/bin/blight ]]; then
blight -d "$DEVICE" set +10% && $notify "Brightness Up $ICON_UP"
elif [[ -f /usr/bin/xbacklight ]]; then elif [[ -f /usr/bin/xbacklight ]]; then
xbacklight -inc 10 && $notify "Brightness Up $ICON_UP" xbacklight -inc 10 && $notify "Brightness Up $ICON_UP"
fi fi
;; ;;
$ICON_DOWN) "$ICON_DOWN")
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
blight -d $DEVICE set -10% && $notify "Brightness Down $ICON_DOWN" brightnessctl -q set 10%- && $notify "Brightness Down $ICON_DOWN"
elif [[ -f /usr/bin/blight ]]; then
blight -d "$DEVICE" set -10% && $notify "Brightness Down $ICON_DOWN"
elif [[ -f /usr/bin/xbacklight ]]; then elif [[ -f /usr/bin/xbacklight ]]; then
xbacklight -dec 10 && $notify "Brightness Down $ICON_DOWN" xbacklight -dec 10 && $notify "Brightness Down $ICON_DOWN"
fi fi
;; ;;
$ICON_OPT) "$ICON_OPT")
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
blight -d $DEVICE set 25% && $notify "Optimal Brightness $ICON_OPT" brightnessctl -q set 25% && $notify "Optimal Brightness $ICON_OPT"
elif [[ -f /usr/bin/blight ]]; then
blight -d "$DEVICE" set 25% && $notify "Optimal Brightness $ICON_OPT"
elif [[ -f /usr/bin/xbacklight ]]; then elif [[ -f /usr/bin/xbacklight ]]; then
xbacklight -set 30 && $notify "Optimal Brightness $ICON_OPT" xbacklight -set 30 && $notify "Optimal Brightness $ICON_OPT"
fi fi

View File

@ -14,7 +14,12 @@ msg() {
} }
## Get Brightness ## Get Brightness
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
BNESS="$(brightnessctl get)"
MAX="$(brightnessctl max)"
PERC="$((BNESS*100/MAX))"
BLIGHT=${PERC%.*}
elif [[ -f /usr/bin/blight ]]; then
DEVICE=$(ls /sys/class/backlight | head -n 1) DEVICE=$(ls /sys/class/backlight | head -n 1)
BNESS="$(blight -d $DEVICE get brightness)" BNESS="$(blight -d $DEVICE get brightness)"
PERC="$(($BNESS*100/255))" PERC="$(($BNESS*100/255))"
@ -48,23 +53,29 @@ options="$ICON_UP\n$ICON_OPT\n$ICON_DOWN"
## Main ## Main
chosen="$(echo -e "$options" | $rofi_command -p "$BLIGHT%" -dmenu -selected-row 1)" chosen="$(echo -e "$options" | $rofi_command -p "$BLIGHT%" -dmenu -selected-row 1)"
case $chosen in case $chosen in
$ICON_UP) "$ICON_UP")
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
blight -d $DEVICE set +10% && $notify "Brightness Up $ICON_UP" brightnessctl -q set +10% && $notify "Brightness Up $ICON_UP"
elif [[ -f /usr/bin/blight ]]; then
blight -d "$DEVICE" set +10% && $notify "Brightness Up $ICON_UP"
elif [[ -f /usr/bin/xbacklight ]]; then elif [[ -f /usr/bin/xbacklight ]]; then
xbacklight -inc 10 && $notify "Brightness Up $ICON_UP" xbacklight -inc 10 && $notify "Brightness Up $ICON_UP"
fi fi
;; ;;
$ICON_DOWN) "$ICON_DOWN")
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
blight -d $DEVICE set -10% && $notify "Brightness Down $ICON_DOWN" brightnessctl -q set 10%- && $notify "Brightness Down $ICON_DOWN"
elif [[ -f /usr/bin/blight ]]; then
blight -d "$DEVICE" set -10% && $notify "Brightness Down $ICON_DOWN"
elif [[ -f /usr/bin/xbacklight ]]; then elif [[ -f /usr/bin/xbacklight ]]; then
xbacklight -dec 10 && $notify "Brightness Down $ICON_DOWN" xbacklight -dec 10 && $notify "Brightness Down $ICON_DOWN"
fi fi
;; ;;
$ICON_OPT) "$ICON_OPT")
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
blight -d $DEVICE set 25% && $notify "Optimal Brightness $ICON_OPT" brightnessctl -q set 25% && $notify "Optimal Brightness $ICON_OPT"
elif [[ -f /usr/bin/blight ]]; then
blight -d "$DEVICE" set 25% && $notify "Optimal Brightness $ICON_OPT"
elif [[ -f /usr/bin/xbacklight ]]; then elif [[ -f /usr/bin/xbacklight ]]; then
xbacklight -set 30 && $notify "Optimal Brightness $ICON_OPT" xbacklight -set 30 && $notify "Optimal Brightness $ICON_OPT"
fi fi

View File

@ -16,7 +16,12 @@ msg() {
} }
## Get Brightness ## Get Brightness
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
BNESS="$(brightnessctl get)"
MAX="$(brightnessctl max)"
PERC="$((BNESS*100/MAX))"
BLIGHT=${PERC%.*}
elif [[ -f /usr/bin/blight ]]; then
DEVICE=$(ls /sys/class/backlight | head -n 1) DEVICE=$(ls /sys/class/backlight | head -n 1)
BNESS="$(blight -d $DEVICE get brightness)" BNESS="$(blight -d $DEVICE get brightness)"
PERC="$(($BNESS*100/255))" PERC="$(($BNESS*100/255))"
@ -50,23 +55,29 @@ options="$ICON_UP\n$ICON_OPT\n$ICON_DOWN"
## Main ## Main
chosen="$(echo -e "$options" | $rofi_command -p "$BLIGHT%" -dmenu -selected-row 1)" chosen="$(echo -e "$options" | $rofi_command -p "$BLIGHT%" -dmenu -selected-row 1)"
case $chosen in case $chosen in
$ICON_UP) "$ICON_UP")
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
blight -d $DEVICE set +10% && $notify "Brightness Up $ICON_UP" brightnessctl -q set +10% && $notify "Brightness Up $ICON_UP"
elif [[ -f /usr/bin/blight ]]; then
blight -d "$DEVICE" set +10% && $notify "Brightness Up $ICON_UP"
elif [[ -f /usr/bin/xbacklight ]]; then elif [[ -f /usr/bin/xbacklight ]]; then
xbacklight -inc 10 && $notify "Brightness Up $ICON_UP" xbacklight -inc 10 && $notify "Brightness Up $ICON_UP"
fi fi
;; ;;
$ICON_DOWN) "$ICON_DOWN")
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
blight -d $DEVICE set -10% && $notify "Brightness Down $ICON_DOWN" brightnessctl -q set 10%- && $notify "Brightness Down $ICON_DOWN"
elif [[ -f /usr/bin/blight ]]; then
blight -d "$DEVICE" set -10% && $notify "Brightness Down $ICON_DOWN"
elif [[ -f /usr/bin/xbacklight ]]; then elif [[ -f /usr/bin/xbacklight ]]; then
xbacklight -dec 10 && $notify "Brightness Down $ICON_DOWN" xbacklight -dec 10 && $notify "Brightness Down $ICON_DOWN"
fi fi
;; ;;
$ICON_OPT) "$ICON_OPT")
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
blight -d $DEVICE set 25% && $notify "Optimal Brightness $ICON_OPT" brightnessctl -q set 25% && $notify "Optimal Brightness $ICON_OPT"
elif [[ -f /usr/bin/blight ]]; then
blight -d "$DEVICE" set 25% && $notify "Optimal Brightness $ICON_OPT"
elif [[ -f /usr/bin/xbacklight ]]; then elif [[ -f /usr/bin/xbacklight ]]; then
xbacklight -set 30 && $notify "Optimal Brightness $ICON_OPT" xbacklight -set 30 && $notify "Optimal Brightness $ICON_OPT"
fi fi

View File

@ -16,7 +16,12 @@ msg() {
} }
## Get Brightness ## Get Brightness
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
BNESS="$(brightnessctl get)"
MAX="$(brightnessctl max)"
PERC="$((BNESS*100/MAX))"
BLIGHT=${PERC%.*}
elif [[ -f /usr/bin/blight ]]; then
DEVICE=$(ls /sys/class/backlight | head -n 1) DEVICE=$(ls /sys/class/backlight | head -n 1)
BNESS="$(blight -d $DEVICE get brightness)" BNESS="$(blight -d $DEVICE get brightness)"
PERC="$(($BNESS*100/255))" PERC="$(($BNESS*100/255))"
@ -50,23 +55,29 @@ options="$ICON_UP\n$ICON_OPT\n$ICON_DOWN"
## Main ## Main
chosen="$(echo -e "$options" | $rofi_command -p "$BLIGHT% : $MSG" -dmenu -selected-row 1)" chosen="$(echo -e "$options" | $rofi_command -p "$BLIGHT% : $MSG" -dmenu -selected-row 1)"
case $chosen in case $chosen in
$ICON_UP) "$ICON_UP")
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
blight -d $DEVICE set +10% && $notify "Brightness Up $ICON_UP" brightnessctl -q set +10% && $notify "Brightness Up $ICON_UP"
elif [[ -f /usr/bin/blight ]]; then
blight -d "$DEVICE" set +10% && $notify "Brightness Up $ICON_UP"
elif [[ -f /usr/bin/xbacklight ]]; then elif [[ -f /usr/bin/xbacklight ]]; then
xbacklight -inc 10 && $notify "Brightness Up $ICON_UP" xbacklight -inc 10 && $notify "Brightness Up $ICON_UP"
fi fi
;; ;;
$ICON_DOWN) "$ICON_DOWN")
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
blight -d $DEVICE set -10% && $notify "Brightness Down $ICON_DOWN" brightnessctl -q set 10%- && $notify "Brightness Down $ICON_DOWN"
elif [[ -f /usr/bin/blight ]]; then
blight -d "$DEVICE" set -10% && $notify "Brightness Down $ICON_DOWN"
elif [[ -f /usr/bin/xbacklight ]]; then elif [[ -f /usr/bin/xbacklight ]]; then
xbacklight -dec 10 && $notify "Brightness Down $ICON_DOWN" xbacklight -dec 10 && $notify "Brightness Down $ICON_DOWN"
fi fi
;; ;;
$ICON_OPT) "$ICON_OPT")
if [[ -f /usr/bin/blight ]]; then if [[ -f /bin/brightnessctl ]]; then
blight -d $DEVICE set 25% && $notify "Optimal Brightness $ICON_OPT" brightnessctl -q set 25% && $notify "Optimal Brightness $ICON_OPT"
elif [[ -f /usr/bin/blight ]]; then
blight -d "$DEVICE" set 25% && $notify "Optimal Brightness $ICON_OPT"
elif [[ -f /usr/bin/xbacklight ]]; then elif [[ -f /usr/bin/xbacklight ]]; then
xbacklight -set 30 && $notify "Optimal Brightness $ICON_OPT" xbacklight -set 30 && $notify "Optimal Brightness $ICON_OPT"
fi fi

View File

@ -84,7 +84,7 @@ $ ./setup.sh
|Applets|Description|Supported / Required Applications| |Applets|Description|Supported / Required Applications|
|:-|:-|:-| |:-|:-|:-|
|**`Apps`**|Shortcuts for most used applications.|`termite`/`urxvt`/`kitty`/`xterm`, `thunar`/`pcmanfm`, `geany`/`leafpad`/`mousepad`/`code`, `firefox`/`chromium`/`midori`, etc| |**`Apps`**|Shortcuts for most used applications.|`termite`/`urxvt`/`kitty`/`xterm`, `thunar`/`pcmanfm`, `geany`/`leafpad`/`mousepad`/`code`, `firefox`/`chromium`/`midori`, etc|
|**`Backlight`**|Display and adjust screen brightness.|`blight` and `xbacklight`| |**`Backlight`**|Display and adjust screen brightness.|`brightnessctl`, `blight` and `xbacklight`|
|**`Battery`**|Display battery percentage & charging-discharging status with dynamic icons.|`acpi` and `xfce4-power-manager-settings`| |**`Battery`**|Display battery percentage & charging-discharging status with dynamic icons.|`acpi` and `xfce4-power-manager-settings`|
|**`MPD`**|Control the song play through [mpd](https://github.com/MusicPlayerDaemon/).|`mpd`, `mpc` and `dunst`| |**`MPD`**|Control the song play through [mpd](https://github.com/MusicPlayerDaemon/).|`mpd`, `mpc` and `dunst`|
|**`Network`**|Display Online-Offline status with dynamic icons.|`dnsutils`, `nmcli`, `nmtui`, `bmon`, `nm-connection-editor` and `termite`| |**`Network`**|Display Online-Offline status with dynamic icons.|`dnsutils`, `nmcli`, `nmtui`, `bmon`, `nm-connection-editor` and `termite`|