Skip to content

Instantly share code, notes, and snippets.

@VicoErv
Created May 22, 2020 11:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VicoErv/f1567f33b0f4630339350efcd5496892 to your computer and use it in GitHub Desktop.
Save VicoErv/f1567f33b0f4630339350efcd5496892 to your computer and use it in GitHub Desktop.
How to make brightness work with i3

Install brightnessctl https://www.archlinux.org/packages/community/x86_64/brightnessctl/

Add this script to ~/.config/i3/config

bindsym XF86MonBrightnessUp exec brightnessctl s +10% > /dev/null && notify-send Brightness $(($(brightnessctl get) * 10 / 937 * 10))% -h string:x-canonical-private-synchronous:brightness_percentage --app-name System
bindsym XF86MonBrightnessDown exec brightnessctl s 10%- > /dev/null && notify-send Brightness $(($(brightnessctl get) * 10 / 937 * 10))% -h string:x-canonical-private-synchronous:brightness_percentage --app-name System

explanation:

  • bindsym: i3 script to bind key
  • XF86MonBrightnessUp brightness up button
  • XF86MonBrightnessDown brightness down button
  • exec i3 script to execute command
  • brightnessctl program that can change brightness by changing the backlight not the brightness of the image
  • s argument that stands for set, that can accept + and -
  • > forward the output to /dev/null
  • && execute another command in same event
  • notify-send send notify
  • Brightness title of the notification
  • $(($(brightnessctl get) * 10 / 937 * 10))% the brightness percentage, i can't make it work to cast the number to decimal using dots, so i multiply the number with 10 instead
  • -h string:x-canonical-private-synchronous:brightness_percentage bring tag to the notification so if user change brightness multiple times will not stack the notification but replace the old one instead.
  • --app-name System name of the notification
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment