Running a script before or once login screen appears
There are two ways to approach this:
Place command or call to script in
/etc/rc.local. For instance
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# By default this script does nothing.
# path to my script. Note the & at the end, it's important
The login screen is actually known as desktop manager, and Ubuntu in particular uses
lightdm desktop manager. Its configuration file
/etc/lightdm/lightdm.conf can take
greeter-setup-script= parameter to execute something before login screen actually shows up. For instance, you could do:
NOTE: Older versions of the header
[SeatDefaults] is deprecated now, use
[Seat:*]. Also, if you have never edited
/etc/lightdm/lightdm.conf it will be blank - that's the normal behavior since 14.04 Ubuntu version.
Controlling the brightness:
Setting brightness will have to be done by writing to
brightness file in
/sys/class/backlight/<NAME> directory. There are couple different
<NAME> versions than can appear, for example mine is
/sys/class/backlight/intel_backlight , so you will need to figure out the name your own computer uses or alternatively use
/sys/class/backlight/*/brightness. There is also
max_brightness file in the same location, which you can use as 100% value to calculate brightness to set. Both files accept integer value.
Common way to write into that file is via
echo 123 | sudo tee /sys/class/backlight/*/brightness from command line. If you are running a script via
/etc/rc.local or via
greeter-setup-script= parameter mentioned above,
sudo is not necessary, as both method run scripts with root privillege ( which is also important to remember for security reasons, so ensure your script is accessible only to your user or root only )
There are also alternatives to writing into
/sys , but not all of them are good. In my experience
xbacklight doesn't work for Ubuntu users and
xrandr --output SCREEN_NAME --brightness INT is only a software solution (i.e., it doesn't actually decrease power of the screen, only makes screen turn darker color).