How can I get a command to run before login (ie while booting or just after)?

Solution 1:

You can edit /etc/lightdm/lightdm.conf and append the line

display-setup-script=/usr/local/sbin/lightdm-setup.sh

to the [SeatDefaults] section. Then create the file /usr/local/sbin/lightdm-setup.sh with this content:

#! /bin/sh
xbacklight =100

And make the file executable (chmod +x /usr/local/sbin/lightdm-setup.sh). After a reboot or when you restart lightdm (sudo restart lightdm) your script should run.