From 9433c26d62de6805eabdc8d937176456356b587c Mon Sep 17 00:00:00 2001 From: Joe Groocock Date: Sun, 4 Dec 2016 13:58:25 +0000 Subject: [PATCH] Add backlight control to i3 --- .config/i3/blocks/backlight | 21 +++++++++++++++++++++ .config/i3/blocks/battery | 2 -- .config/i3/blocks/config | 5 +++++ .config/i3/config | 2 ++ 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100755 .config/i3/blocks/backlight diff --git a/.config/i3/blocks/backlight b/.config/i3/blocks/backlight new file mode 100755 index 0000000..59f29e8 --- /dev/null +++ b/.config/i3/blocks/backlight @@ -0,0 +1,21 @@ +#!/bin/sh + +# Set how much you want the brightness to change +DELTA=2 + +# Get the current light level, rounded to an integer +LIGHT=$(printf '%.*f' 0 $(xbacklight -get)) +NEW_LIGHT=$LIGHT + +# If called from i3blocks, and scrolling, then change light level +case $BLOCK_BUTTON in + 5) NEW_LIGHT=$(expr $LIGHT + $DELTA) ;; + 4) NEW_LIGHT=$(expr $LIGHT - $DELTA) ;; +esac + +xbacklight -set $NEW_LIGHT -time 0 -steps 1 + +# Output the new light level +OUTPUT=$(printf '%.*f%%' 0 $(xbacklight -get)) +echo $OUTPUT +echo $OUTPUT diff --git a/.config/i3/blocks/battery b/.config/i3/blocks/battery index b608375..4bfbf61 100755 --- a/.config/i3/blocks/battery +++ b/.config/i3/blocks/battery @@ -75,8 +75,6 @@ switch($ENV{BLOCK_BUTTON} || 0) { } } } - case "4" { system("light -U -l 1") } - case "5" { system("light -A -l 1") } } diff --git a/.config/i3/blocks/config b/.config/i3/blocks/config index 9018e49..0e20c56 100644 --- a/.config/i3/blocks/config +++ b/.config/i3/blocks/config @@ -77,6 +77,11 @@ interval=10 label= interval=10 +[backlight] +label= +interval=30 +signal=12 + [separator] [rotation] diff --git a/.config/i3/config b/.config/i3/config index ba09136..b65e628 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -160,6 +160,8 @@ bindsym XF86AudioPause exec --no-startup-id mpc pause bindsym XF86AudioStop exec --no-startup-id mpc stop bindsym XF86AudioNext exec --no-startup-id mpc next bindsym XF86AudioPrev exec --no-startup-id mpc previous +bindsym XF86MonBrightnessUp exec xbacklight -inc 5 && pkill -RTMIN+12 i3blocks +bindsym XF86MonBrightnessDown exec xbacklight -dec 5 && pkill -RTMIN+12 i3blocks bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +2% && pkill -RTMIN+10 i3blocks bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -2% && pkill -RTMIN+10 i3blocks bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && pkill -RTMIN+10 i3blocks