Script "on login"- not working

In my Zorin OS redshift is installed by default - an application that makes the screen warmer.
To enable it I had the following command added on startup:
redshift -O VALUE = value affects color

My thinking:
"Session and startup" -> Application Autostart -> Add

  • name "redshift"
  • description "redshift"
  • command redshift -O VALUE
  • trigger "on login"

Problem:
Does not work as I log in. However - if I changed trigger from "on login" to "on switch user/on suspend"- it works!

Anybody can help?

Hi,

Did you placed the script file in ~/.config/autostart and made it executable? Also try put a timer in the script so Gnome have time to startup before the command is executed.

.. forgive me, but I am not a scripting expert.
The script looks as the following:
script-name.sh
Inside:
redshift -O VALUE

What do you mean by timer, what should I do?

Like

#!/bin/bash
sleep 1000
redshift -O VALUE

and remeber to make it executable;
chmod +x filename.sh

Changed sleep 1000 into sleep 1.
It worked, but the interesting thing is that it worked even when I removed the "#!/bin/bash"

sleep 1 && redshift -O VALUE

I do not understand one thing thou: in "Session and startup" -> Application Autostart -> Add" I can as well enter a command itself. Instead of linking command to that .sh script I tried to simply insert "sleep 1 && redshift -O VALUE", but it did not work. Why?

1 Like

Try instead

sh -c "sleep 1 && redshift -O VALUE"

It works! Storm - you are my hero!
If I may ask: What does this part do?

sh -c

sh stands for "shell" and shell is the old, Unix like command line interpreter. An interpreter is an program that executes specific instructions written in a programming or scripting language. So basically you say "Execute that file for me".

-c tells it's a command string instead.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.