Laptop brightness keys(f3&f4) doesnt work

I recently switched to endeavour os i3wm on my acer laptop, volume buttons work and show notification on screen, but brightness button (f3 & f4) when pressed shows a blank brightness bar.

I have tried changing brightness step to 5 & 10 at.config/i3/scripts/volume_brightness.sh, still not working,

tried adding these to my i3 config file, still no luck

bindsym XF86MonBrightnessUp exec brightnessctl -c backlight set +5%
bindsym XF86MonBrightnessDown exec brightnessctl -c backlight set 5%-

Any help would be appreciated.

Thanks

Did you install brightnessctl? I don’t think it is installed by default.

sudo pacman -S brightnessctl

Yes I did install that, it works in terminal. Im using amd gpu.

Post the current keybindings for the brightness keys in your i3wm config.

this is the current config,

bindsym XF86MonBrightnessUp exec --no-startup-id ~/.config/i3/scripts/volume_brightness.sh brightness_up
bindsym XF86MonBrightnessDown exec --no-startup-id ~/.config/i3/scripts/volume_brightness.sh brightness_down

thanks

Please put code snippets between ``` marks.

Post the contents of volume_brightness.sh

my volume_brightness.sh

#!/bin/bash
# original source: https://gitlab.com/Nmoleo/i3-volume-brightness-indicator

# taken from here: https://gitlab.com/Nmoleo/i3-volume-brightness-indicator

# See README.md for usage instructions
bar_color="#7f7fff"
volume_step=1
brightness_step=10
max_volume=100

# Uses regex to get volume from pactl
function get_volume {
    pactl get-sink-volume @DEFAULT_SINK@ | grep -Po '[0-9]{1,3}(?=%)' | head -1
}

# Uses regex to get mute status from pactl
function get_mute {
    pactl get-sink-mute @DEFAULT_SINK@ | grep -Po '(?<=Mute: )(yes|no)'
}

# Uses regex to get brightness from xbacklight
function get_brightness {
    xbacklight | grep -Po '[0-9]{1,3}' | head -n 1
}

# Returns a mute icon, a volume-low icon, or a volume-high icon, depending on the volume
function get_volume_icon {
    volume=$(get_volume)
    mute=$(get_mute)
    if [ "$volume" -eq 0 ] || [ "$mute" == "yes" ] ; then
        volume_icon=""
    elif [ "$volume" -lt 50 ]; then
        volume_icon=""
    else
        volume_icon=""
    fi
}

# Always returns the same icon - I couldn't get the brightness-low icon to work with fontawesome
function get_brightness_icon {
    brightness_icon=""
}

# Displays a volume notification using dunstify
function show_volume_notif {
    volume=$(get_mute)
    get_volume_icon
    dunstify -i audio-volume-muted-blocking -t 1000 -r 2593 -u normal "$volume_icon $volume%" -h int:value:$volume -h string:hlcolor:$bar_color
}

# Displays a brightness notification using dunstify
function show_brightness_notif {
    brightness=$(get_brightness)
    get_brightness_icon
    dunstify -t 1000 -r 2593 -u normal "$brightness_icon $brightness%" -h int:value:$brightness -h string:hlcolor:$bar_color
}

# Main function - Takes user input, "volume_up", "volume_down", "brightness_up", or "brightness_down"
case $1 in
    volume_up)
    # Unmutes and increases volume, then displays the notification
    pactl set-sink-mute @DEFAULT_SINK@ 0
    volume=$(get_volume)
    if [ $(( "$volume" + "$volume_step" )) -gt $max_volume ]; then
        pactl set-sink-volume @DEFAULT_SINK@ $max_volume%
    else
        pactl set-sink-volume @DEFAULT_SINK@ +$volume_step%
    fi
    show_volume_notif
    ;;

    volume_down)
    # Raises volume and displays the notification
    pactl set-sink-volume @DEFAULT_SINK@ -$volume_step%
    show_volume_notif
    ;;

    volume_mute)
    # Toggles mute and displays the notification
    pactl set-sink-mute @DEFAULT_SINK@ toggle
    show_volume_notif
    ;;

    brightness_up)
    # Increases brightness and displays the notification
    xbacklight -inc $brightness_step -time 5 
    show_brightness_notif
    ;;

    brightness_down)
    # Decreases brightness and displays the notification
    xbacklight -dec $brightness_step -time 5
    show_brightness_notif
    ;;
esac

Thanks

Change the xbacklight -inc $brightness_step -time 5 in the case statement to brightnessctl -c backlight set +5%.

Change the xbacklight -dec $brightness_step -time 5 in the case statement to brightnessctl -c backlight set 5%-.

You can try this other user’s solution, which uses xorg-xbacklight instead of brightnessctl.

Thank you. This is working as of now. though the brightness bar doesn’t show the percentage on screen like volume bar.

Anyway to get that to show?

Tried this before opening this ticket, didnt work. THanks

Inside the show_brightness_notif() function, replace this line

brightness=$(get_brightness)

with the following lines

current_value=$(brightnessctl get)
max_value=$(brightnessctl max)
brightness=$(( current_value * 100 / max_value ))
1 Like

That worked, amazing. Thank you.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.