GUI Display Brightness Control v0.2, updated 02.10.2019

Post your tutorials and howtos here.
xfce
Posts: 14
Joined: 22 Jan 2019 02:53

GUI Display Brightness Control v0.2, updated 02.10.2019

Postby xfce » 06 Feb 2019 20:52

!! TIP !! -- GUI Display Brightness Control -- 02.06.2019

I previously posted a CLI version of this same process here:
-- viewtopic.php?f=74&t=7465

The GUI is possible via Zenity (it's kind of like editing Excel formulas in days of yore -- all on one line).
vb-set.png
vb-set.png (47.46 KiB) Viewed 1736 times

Code: Select all

#!/bin/bash
# vb-set - v0.1 - Video/Display Brightness Control -- 02.06.2019
# ==============================================================
# SolydXee XFCE x64

# ** Acknowledgements ** ---------------------------------------
# Les Pounder: https://bigl.es/author/les/
# --------------------------------------------------------------
#
# the CLI command: xrandr -q |grep " connected"
# -- should return the ID of displays currently
#    active on your system.
# --------------------------------------------------------------
# !! NOTE: NOT advised TO EXCEED "1.0" setting !!

# *** Variables (start) ****************************************
# **************************************************************
# DISPLAYS=2                      # Connected Displays

DISPLAY1="HDMI-1"                 # ID: Display 1
DISPLAY2="HDMI-2"                 # ID: Display 2

# *** Variables (end) *****************************************
# *************************************************************

ans=$(zenity  --width=150 --height=320 --list --title "Display" --text "== Adjust Brightness" --checklist --column "[x]" --column "Level" FALSE "100%" FALSE "90%" FALSE "80%" FALSE "70%" FALSE "60%" FALSE "50%" FALSE "40%" FALSE "30%");
 
echo $ans
if [ $ans == "100%" ]; then
   xrandr --output $DISPLAY1 --brightness 1.0 &
   xrandr --output $DISPLAY2 --brightness 1.0 &

elif [ $ans == "90%" ]; then
   xrandr --output $DISPLAY1 --brightness 0.9 &
   xrandr --output $DISPLAY2 --brightness 0.9 &

elif [ $ans == "80%" ]; then
   xrandr --output $DISPLAY1 --brightness 0.8 &
   xrandr --output $DISPLAY2 --brightness 0.8 &

elif [ $ans == "70%" ]; then
   xrandr --output $DISPLAY1 --brightness 0.7 &
   xrandr --output $DISPLAY2 --brightness 0.7 &

elif [ $ans == "60%" ]; then
   xrandr --output $DISPLAY1 --brightness 0.6 &
   xrandr --output $DISPLAY2 --brightness 0.6 &

elif [ $ans == "50%" ]; then
   xrandr --output $DISPLAY1 --brightness 0.5 &
   xrandr --output $DISPLAY2 --brightness 0.5 &

elif [ $ans == "40%" ]; then
   xrandr --output $DISPLAY1 --brightness 0.4 &
   xrandr --output $DISPLAY2 --brightness 0.4 &

elif [ $ans == "30%" ]; then
   xrandr --output $DISPLAY1 --brightness 0.3 &
   xrandr --output $DISPLAY2 --brightness 0.3 &
else
  exit 0
fi
Create a launcher for the bash script on the panel and you are all "set" -- Good Luck!
Image

xfce
Posts: 14
Joined: 22 Jan 2019 02:53

Re: !! UPDATED !! -- v0.2 GUI Display Brightness Control -- 02.10.2019

Postby xfce » 10 Feb 2019 21:59

!! UPDATED !! -- v0.2 GUI Display Brightness Control -- 02.10.2019

vb-set - v0.2
=============
I picked up some coding pointers and this version will "loop" through the Brightness Levels and will NOT terminate until the Exit button is selected. This should be more helpful in comparing levels directly.

Level 20% and 10% are enabled, but be forwarned 10% is very dark on my system!

Additionally, I found the "\" will continue Zenity commands on a new line, which enhances legibility and debugging of the code!

Code: Select all

#!/bin/bash
# vb-set - v0.2 - Video/Display Brightness Control -- 02.10.2019
# ==============================================================
# SolydXee XFCE x64

# ** Acknowledgements ** ---------------------------------------
# Les Pounder: https://bigl.es/author/les/ (coding-examples)
#
# the CLI command: xrandr -q |grep " connected"
# -- should return the ID of displays currently
#    active on your system.
# --------------------------------------------------------------
# !! Caution: NOT advised TO EXCEED "1.0" setting !!
# !! ----- 10% "may" render a BLACK screen ------ !!

# *** Variables (start) ****************************************
# **************************************************************
# DISPLAYS=2                      # Connected Displays

DISPLAY1="HDMI-1"                 # ID: Display 1
DISPLAY2="HDMI-2"                 # ID: Display 2

# *** Variables (end) *****************************************
# *************************************************************

while
  vbset=$(zenity  --width=150 --height=350 \
    --ok-label "Adjust" --cancel-label "Exit" \
    --list --title "Display" --text "== Adjust Brightness" \
    --checklist --column "[x]" --column "Level" FALSE "100%" \
    FALSE "90%" FALSE "80%" FALSE "70%" FALSE "60%" FALSE "50%" \
    FALSE "40%" FALSE "30%" FALSE "20%" FALSE "10%");
do
 
echo $vbset
if [ $vbset == "100%" ]; then
   xrandr --output $DISPLAY1 --brightness 1.0 &
   xrandr --output $DISPLAY2 --brightness 1.0 &

elif [ $vbset == "90%" ]; then
   xrandr --output $DISPLAY1 --brightness 0.9 &
   xrandr --output $DISPLAY2 --brightness 0.9 &

elif [ $vbset == "80%" ]; then
   xrandr --output $DISPLAY1 --brightness 0.8 &
   xrandr --output $DISPLAY2 --brightness 0.8 &

elif [ $vbset == "70%" ]; then
   xrandr --output $DISPLAY1 --brightness 0.7 &
   xrandr --output $DISPLAY2 --brightness 0.7 &

elif [ $vbset == "60%" ]; then
   xrandr --output $DISPLAY1 --brightness 0.6 &
   xrandr --output $DISPLAY2 --brightness 0.6 &

elif [ $vbset == "50%" ]; then
   xrandr --output $DISPLAY1 --brightness 0.5 &
   xrandr --output $DISPLAY2 --brightness 0.5 &

elif [ $vbset == "40%" ]; then
   xrandr --output $DISPLAY1 --brightness 0.4 &
   xrandr --output $DISPLAY2 --brightness 0.4 &

elif [ $vbset == "30%" ]; then
   xrandr --output $DISPLAY1 --brightness 0.3 &
   xrandr --output $DISPLAY2 --brightness 0.3 &

elif [ $vbset == "20%" ]; then
   xrandr --output $DISPLAY1 --brightness 0.2 &
   xrandr --output $DISPLAY2 --brightness 0.2 &

elif [ $vbset == "10%" ]; then
   xrandr --output $DISPLAY1 --brightness 0.1 &
   xrandr --output $DISPLAY2 --brightness 0.1 &
else
  break
fi

done

exit 0
Create a launcher for the bash script on the panel and you are all "set" -- Good Luck!
Image


Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 1 guest