• Now's your chance win big! Join our community and get entered to win a RTX 2060 GPU, plus more! Join here.

    Pi Cast Episode 3 streams live on Tuesday, August 4th at 2:30 pm ET (7:30 PM BST). Watch live right here!

    Catch Scharon on the Tom's Hardware Show live on Thursday, August 6th at 2:00 pm ET (7:00 PM BST). Click here!

Question Creating A Script For Adjusting Laptop Screen Brightness? Linux Mint 19.3

System32_76

Prominent
Jul 29, 2019
70
2
535
0
I'm running Linux Mint 19.3 Cinnamon on a 2009 Macbook Pro.

The only thing the Power Manager is recognizing concerning brightness is the laptop keyboard (Macbook feature), not the actual display.

Currently, I have this "xrandr" argument/command assigned to the F1 and F2 keys, the keys for turning up and down my brightness. When I press F2, it'll activate this argument with xrandr: "xrandr --output eDP1 --brightness 1.0," turning up my display's brightness up all the way. When I press F1, however, it'll activate this other xrandr argument "xrandr --output eDP1 --brightness 0.5," setting my display's brightness to halfway. Using the F brightness keys with the arguments assigned to them work, but it has a very limited selection for adjusting between brightness levels.

Is there a way where I can create a script that allows adjustment for all brightness levels instead?
 
Last edited:

Ralston18

Titan
Moderator
In general terms just write a script that prompts for a brightness level.

Use a numeric keypress to enter the applicable numeric value and then convert that value to a string variable.

e.g., a numeric 1 becomes a string '1.0' or a numeric 5 becomes a string '0.5'.

Concantenate that string variable into the "xrandr--ouput eDP1--brightness-- [string variable here]" argument.

The script would need to be running (looping) in the background and brought forward with some unique keypress that then prompts for a new brightness level, accepts the user input, and then changes the brightness.
 

System32_76

Prominent
Jul 29, 2019
70
2
535
0
In general terms just write a script that prompts for a brightness level.

Use a numeric keypress to enter the applicable numeric value and then convert that value to a string variable.

e.g., a numeric 1 becomes a string '1.0' or a numeric 5 becomes a string '0.5'.

Concantenate that string variable into the "xrandr--ouput eDP1--brightness-- [string variable here]" argument.

The script would need to be running (looping) in the background and brought forward with some unique keypress that then prompts for a new brightness level, accepts the user input, and then changes the brightness.
I'm not that experienced with programming. How would I convert a numeric number to a string number? Could you put the design you mentioned in code so I can easily copy and paste it into my text editor?
 

Ralston18

Titan
Moderator

System32_76

Prominent
Jul 29, 2019
70
2
535
0
Not [full disclosure] a Linux person per se.

Something similar to the following should work:

https://www.unix.com/shell-programming-and-scripting/68166-converting-integer-string.html

Start simple with just enough code to test the concept.

See if it works and modify/correct as necessary.

Then if it still does not work, then post your documented code accordingly along an explanation of what is or is not happening as you expect or desire.
Thank you for your assistance but I've found a workaround, I assigned the different brightness levels with the xrandr command to different keybindings. Ctrl + 0 for max brightness, Ctrl + 5 for half brightness, etc.
 

ASK THE COMMUNITY

TRENDING THREADS