On my OS, there is no way to manually set the brightness, so I wrote a small shell script to do so:

echo -n "Set Brightness To (from 0 to 100):"
read answer
echo $((answer * 8 + 50))>/sys/class/backlight/intel_backlight/brightness

But the problem is that running the script directly from the GUI runs it without prompting for user input on the terminal (answer = 0), and right clicking to run in terminal is necessary for the script to prompt for user input.

How can one display the terminal directly when executing said script?


Prompting for input

Method #1

Using xterm you can simply run your application as an argument to whatever terminal emulator you're using. Here I'm using xterm:

$ xterm "./bright.bash"

Which will result in your application running inside of a xterm terminal:


The same method with gnome-terminal.

$ gnome-terminal -e ./bright.bash


Method #2 - zenity

You could use the GUI toolkit zenity to open a dialog box asking for a response to be typed in, then take what was typed in and use the rest of your script to set it.


$ cat brightness.bash
answer="$(zenity --entry --title='Brightness setting' \
    --text='Set Brightness To (from 0 to 100):')"
echo $((answer * 8 + 50))>/sys/class/backlight/intel_backlight/brightness

If we run it, but merely echo the last line out instead of running it we can see what it'll do:

$ ./brightness.bash
echo 450 > /sys/class/backlight/intel_backlight/brightness

The UI looks like this:


  • @Jesse_b - yeah if you search the site I've recommended it before for similar types of work.
    – slm
    Aug 5 '18 at 0:05

Another way to do this is to invoke the terminal program and tell it to run the command. Most terminals have an option to do this; for xterm (which is pretty old-school), you can do

xterm -e PROGRAMNAME (replacing programname with the command)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.