Run command at startup

In terminal I use the following command to change my laptop screen settings:

xrandr --output LVDS --brightness 0.9 --gamma 0.55

I put this command in “Session and startup preferences” in Manjaro on login, but it is not working when I login.

It is possible run this command automatically when I log in? How can I do this?

I’m not using XFCE but can recommend something of a mixture. You can make that command into a script file. Create an empty file on your home folder and name it screen.sh or whatever you want. Put your command in it like this and save.

#!/bin/sh
xrandr --output LVDS --brightness 0.9 --gamma 0.55

Later, put this command into your autostart:
sh ~/.screen.sh

Or you can wait for an XFCE user to reply. :slight_smile:

Edit:
It would be better as a hidden file so better make the name start with a dot, like this:
.screen.sh

Hi!
Don’t forget giving executable permissions to the file
chmod +x ~/.screen.sh

1 Like
  • https://wiki.archlinux.org/index.php/xfce#Autostart
  • https://docs.xfce.org/xfce/xfce4-session/advanced - Scroll down to ${XDG_CONFIG_DIRS}/autostart/

work when i run this command in terminal.

but nothing happens when i put the same code on startup preference command field

sh -c "sleep 3 && ~/.screen.sh"

@visone Forgot to mention that, thank you.

As @stargazer shared from Arch Wiki, you should be able to directly add the script file it seems. Add a new autostart program and choose .screen.sh from file manager. Should be fine I guess.

1 Like

Thank you for your help.

I chose to use a package called autorandr.

I was having a problem where any configuration I set it would run for a few seconds at startup and then go back to the previous state.

So I had to disable some items (Xfsettingsd and xiccd) in Session and startup in Manjaro xfce and it finally worked.

No problem, glad you solved your issue.
I guess xiccd is not needed unless you’re a photographer. Though xfsettingsd seems apply different XFCE config files at once, by disabling it you may need some things to start manually.

1 Like

Use the full path to the script instead of ~/

sh /home/$(USER)/.screen.sh

and add the sleep 3 command to the script before the xrandr command

#!/bin/sh
sleep 3
xrandr --output LVDS --brightness 0.9 --gamma 0.55
4 Likes