commit 9a0a91fd6e6f7ac15351b78c98faf643fc60adae
parent 20e494f8bdd668825fbe6deed7d2db769c53a341
Author: oscarbenedito <oscar@oscarbenedito.com>
Date:   Sat, 25 Apr 2020 14:30:30 +0200

Added brightness to i3 status bar

Diffstat:
Mdot_config/i3/config | 17++++++++++-------
Adot_config/i3blocks/bin/executable_backlight | 41+++++++++++++++++++++++++++++++++++++++++
Mdot_config/i3blocks/config | 9+++++++--
3 files changed, 58 insertions(+), 9 deletions(-)

diff --git a/dot_config/i3/config b/dot_config/i3/config @@ -213,18 +213,21 @@ exec --no-startup-id "xwallpaper --zoom $wp" # /theme }}} -# XF86 shortcuts {{{ +# volume and brightness {{{ # volume -bindsym XF86AudioRaiseVolume exec amixer -q -D pulse sset Master unmute && amixer -q -D pulse sset Master 5%+ && pkill -RTMIN+10 i3blocks -bindsym XF86AudioLowerVolume exec amixer -q -D pulse sset Master unmute && amixer -q -D pulse sset Master 5%- && pkill -RTMIN+10 i3blocks -bindsym XF86AudioMute exec amixer -q -D pulse sset Master toggle && pkill -RTMIN+10 i3blocks +bindsym XF86AudioRaiseVolume exec amixer -q -D pulse sset Master unmute && amixer -q -D pulse sset Master 5%+ && pkill -RTMIN+1 i3blocks +bindsym XF86AudioLowerVolume exec amixer -q -D pulse sset Master unmute && amixer -q -D pulse sset Master 5%- && pkill -RTMIN+1 i3blocks +bindsym XF86AudioMute exec amixer -q -D pulse sset Master toggle && pkill -RTMIN+1 i3blocks + +bindsym $mod+plus exec amixer -q -D pulse sset Master unmute && amixer -q -D pulse sset Master 5%+ && pkill -RTMIN+1 i3blocks +bindsym $mod+minus exec amixer -q -D pulse sset Master unmute && amixer -q -D pulse sset Master 5%- && pkill -RTMIN+1 i3blocks # brightness -bindsym XF86MonBrightnessDown exec --no-startup-id xbacklight -dec 15 -bindsym XF86MonBrightnessUp exec --no-startup-id xbacklight -inc 15 +bindsym XF86MonBrightnessDown exec --no-startup-id xbacklight -dec 10 && pkill -RTMIN+2 i3blocks +bindsym XF86MonBrightnessUp exec --no-startup-id xbacklight -inc 10 && pkill -RTMIN+2 i3blocks -# /XF86 shortcuts }}} +# /volume and brightness }}} # keyboards and monitors {{{ diff --git a/dot_config/i3blocks/bin/executable_backlight b/dot_config/i3blocks/bin/executable_backlight @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# Show the screen brightness value given by `xbacklight`. +# Clicking uses `xset` to turn off the backlight, scrolling increases or decreases +# the brightness. + +# Copyright 2019 Johannes Lange +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + +STEP_SIZE=${STEP_SIZE:-10} +USE_SUDO=${USE_SUDO:-0} + +# whether to use `sudo` for changing the brightness (requires a NOPASSWD rule) +if [[ "$USE_SUDO" == "0" ]] ; then + XBACKLIGHT_SET="xbacklight" +else + XBACKLIGHT_SET="sudo xbacklight" +fi + +case $BLOCK_BUTTON in + 3) xset dpms force off ;; # right click + 4) $XBACKLIGHT_SET -inc "$STEP_SIZE" ;; # scroll up + 5) $XBACKLIGHT_SET -dec "$STEP_SIZE" ;; # scroll down, decrease +esac + + +BRIGHTNESS=$(xbacklight -get) +echo "<span font='FontAwesome'>☀</span> ${BRIGHTNESS}%" | sed "s/\.[0-9]*//g" diff --git a/dot_config/i3blocks/config b/dot_config/i3blocks/config @@ -5,10 +5,15 @@ markup=pango command=$HOME/.config/i3blocks/bin/disk interval=30 +[backlight] +command=$HOME/.config/i3blocks/bin/backlight +interval=once +signal=2 + [volume] command=$HOME/.config/i3blocks/bin/volume-pulseaudio interval=once -signal=10 +signal=1 [battery] command=$HOME/.config/i3blocks/bin/battery2 @@ -16,5 +21,5 @@ markup=pango interval=30 [datetime] -command=date +"%a %d %b %H:%M" +command=date +"%a %d %b, %H:%M" interval=5