LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Laptop and Netbook (https://www.linuxquestions.org/questions/linux-laptop-and-netbook-25/)
-   -   Reducing screen's brightness: Dimmer than dimmest (https://www.linuxquestions.org/questions/linux-laptop-and-netbook-25/reducing-screens-brightness-dimmer-than-dimmest-4175547780/)

andrew.comly 07-11-2015 10:55 PM

Reducing screen's brightness: Dimmer than dimmest
 
I would like to make a shell script program I have made to convenience night viewing from my netbook. I have the samsung NP-NC110 10” netbook, and it's lowest screen brightness setting is far too bright to use when at night with the lights off (intended to maximize environmentalist daily living habits). Thus from Lubuntu 14.04 I have to
1) start a terminal and type sudo su,
2) enter the password
3) “echo 1200 >/sys/class/backlight/intel_backlight/brightness”
The screen is at the perfect level for my eyes.

Naturally, the file /sys/class/backlight/intel_backlight/brightness is restricted.

I first create the following files:
Code:

/home/a/bin/dimmest.sh
#!/bin/bash
sudo su -c "echo 1200 >/sys/class/backlight/intel_backlight/brightness"
$SHELL

(I also try echo 1200 >/sys/class/backlight/intel_backlight/brightness for the second line, but to no avail)

Code:

/home/a/.local/share/applications/dimmest.desktop:
[Desktop Entry]
Type=Application
Name=Dimmest
Exec="sudo su -c /home/a/bin/dimmest.sh"
Icon=/home/Icons/dimmest.png
Categories=System
Terminal=true

< I also try Exec=”lxterminal -e "sudo /home/a/bin/dimmest.sh"
in above desktop, but to no avail. >

I have used visudo to alter the file as:
Code:

# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL

%sudo ALL = NOPASSWD: /home/a/bin/dimmest.sh


Any ideas on how to do this in Lubuntu 14.04?

Andrew

andrew.comly 07-11-2015 11:16 PM

[Solved] am/pm screen brightness shellscript completed!
 
In ~/bin I make the two shell scripts. First is dimmest.sh:
Code:

#!/bin/bash
echo 1200 >/home/a/dim_value

and second is dim.sh (for regular day brightness level):
Code:

#!/bin/bash
#Program resumes screen brightness to normal.
echo 12421 >/home/a/dim_value

Start terminal,
Code:

cd ~/bin
sudo chmod +x dim.sh && sudo chmod +x dimmest.sh

Since security is very important, I then use what yo8rxp taught to me earlier to make a root daemon by writing the following code to the very end of /etc/rc.local:
Code:

while true
do
 echo $(cat /home/a/dim_value) >/sys/class/backlight/intel_backlight/brightness
sleep 5
done

Finally, I made a desktop file for both dim.sh and dimmest.sh shellscripts above. That way I now have an "am" and "pm" button on my lxpanel. Works beautifully!

With this solution you can now reduce your screen's brightness and then switch to a night colour so that you don't have to "burn the midnight oil" (turn on your lights at night time). This will facilitate conserving electricity, carrying out the acts of:
1) environmentalism and
2) reducing your electricity bills, as well as
3) health - will help you fall asleep earlier


All times are GMT -5. The time now is 02:51 PM.