Hi
everyone,
This is a tutorial addendumFor those of you who have performed the steps in the
original post (i.e. the
first message in this thread) and now would like to change the brightness of your display using a
keyboard shortcut rather than needing to always open a terminal to dim or undim the display then this
"tutorial addendum" is for you.
The steps are
easy to follow and you get to write an executable script (which might be something new for beginners --
Wow! Programming!!).
To get started you should have
successfully followed the steps in the original post, should know the
designation of your
display (
DP-0 in the original post) and should have decided on a
"dimming factor" (or
"brightness factor") that you wish to use (e.g. like the
0.7 factor in the original post).
Given this knowledge we can begin writing our script file.
Where you save this file on your system is your choice. Many people create a new folder in their
home folder and cleverly name this new folder
Scripts, where they store all of their scripts. So that is what I will do in this post as well.
Any changes on your part are up to you.
To begin, open the
Nemo file manager -- e.g. by using the default keyboard shortcut
<Control><Alt>f -- and create a new folder in your
home folder named
Scripts. Then, still in
Nemo, open the
Scripts folder and then press the
F4 function key.
In the terminal window that opens type the following:
and then press the
Enter key. The text editor (
gedit) will open with a new empty file that is named
display-dim.sh.
Copy the following code and paste it into the empty
display-dim.sh file:
#!/bin/sh
# display-dim.sh is a script to dim your display. The brightness
# factor is set to 0.7 (compared to full brightness which uses the
# factor 1.0).
xrandr --output DP-0 --brightness 0.7
If you prefer a
different brightness factor (e.g.
0.55 for even
more dimming or
0.85 for
less dimming) then enter that factor in the file in place of
0.7. Also, be sure to use the
actual designation of your display (unless, of course, your display is actually
DP-0 -- on my notebook it is called
eDP1).
Finally, save the file and close the text editor and the terminal window.
In
Nemo you will see that your new script file
display-dim.sh has been created in the
Scripts folder. But it is
not yet executable as a script program. To make it executable, position your mouse pointer on the file
display-dim.sh and click the
right-button of your mouse (or the left-button if your mouse is set up for left-handed use) to open the file's context menu. Select and click the bottom line (labelled:
Properties) in this pop-up menu.
In the window that opens, click on the tab at the top named
Permissions. Then go to the line labelled
Execute and click in the empty
checkbox Allow executing file as program. Finally, click on the button labelled
Close.
Your script is now finished and is executable! Now you need to create a
keyboard shortcut that will run the script when you wish to dim your display.
To do this, start the
Peppermint Control Center by clicking on the main
menu button on the desktop panel, then click on the top entry
Peppermint Settings Panel. When it has started, open the
Peppermint Control Center.
Now click on the tab at the top labelled
Keyboard Shortcuts. Then click on the button in the upper right corner labelled
Add New.
The window titled
Add New Shortcut appears. Here you now enter the command to run your script in the empty text box. For the example we are using you enter this:
and then click the
OK button. The little window changes (the new title is
Assign New Shortcut).
So decide on the
keyboard shortcut that you wish to use to run your script -- let's say you wish to use
<Alt>d as the shortcut. So click on the button at the top of this window labelled
Alt and then click in the text box labelled
Enter a valid character: and press the
d key. Finally press the button labelled
Apply. Your shortcut is
finished and can be
immediately used!
But wait!! Wouldn't it be nice to also have a
keyboard shortcut to return the display to
full brightness again? Of course it would, so repeat all of the script writing steps above (just remember to use a
different file name: e.g. you might use
display-undim.sh). And in the new script file copy and paste this:
#!/bin/sh
# display-undim.sh is a script to set your display to full brightness.
xrandr --output DP-0 --brightness 1.0
After saving the new script and making it executable, create an appropriate
keyboard shortcut to start it (e.g.
<Alt>u).
That is the end of this
tutorial addendum. I hope that you can follow it and that it works for you. If you have any problems, just ask back here and someone will gladly help you.
Regards,
-- Slim