LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Launch script at cinnamon login (https://www.linuxquestions.org/questions/linux-newbie-8/launch-script-at-cinnamon-login-4175644987/)

zetrotrack000 12-26-2018 09:16 AM

Launch script at cinnamon login
 
Hi
I have created following script in: /home/user/bin/lockscreen.sh:
Code:

#!/bin/bash
cinnamon-screensaver-command -a

I want to execute this script at cinnamon login and for this purpose I have created file: /home/user/.config/autostart/lockscreen.sh
Code:

[Desktop Entry]
Type=Application
Exec=bash -c 'sleep 5; /home/user/bin/lockscreen.sh'
X-GNOME-Autostart-enabled=true
NoDisplay=false
Hidden=false
Name[en_US]=lockscreen
Comment[en_US]=Locks session at login
X-GNOME-Autostart-Delay=0

But Cinnamon is not executing this script at login. Am I doing any mistake here? Kindly guide me.
Thanks

rtmistler 12-26-2018 09:48 AM

Quote:

Originally Posted by zetrotrack000 (Post 5941408)
I have created following script in: /home/user/bin/lockscreen.sh

Quote:

Originally Posted by zetrotrack000 (Post 5941408)
Code:

I want to execute this script at  cinnamon login and for this purpose I have created file:  /home/user/.config/autostart/lockscreen.sh

Recheck where you put your script file. The desktop entry says one thing matching your first statement, but meanwhile there is this contradictory statement as to where the script file is actually located.


Or, are you saying that you have a .config/autostart file named the same thing as your script. Try not using the same name.


Shouldn't be harmful unless both are in your path variable, and they probably are not. But just a possible guess here.

zetrotrack000 12-26-2018 10:03 AM

Kindly check the following results:
Code:

ls /home/user/bin/lockscreen.sh
/home/user/bin/lockscreen.sh

and:
Code:

cat /home/user/.config/autostart/lockscreen.desktop |grep Exec
Exec=bash -c "sleep 5; /home/user/bin/lockscreen.sh"

Which show that file name is correct. However, still I have changed the filename to "autologin" and amend the script accordingly, but it's not working.
PS: Cinnamon "Startup Application" has an option to test the script and when I click on that option it executes the script properly, confirming that the script and its paths are correct.

rtmistler 12-26-2018 12:01 PM

Agree.

At this point I'd try to add logs to various parts of the process and see if they reveal anything. I know you can add logs to the script, however I'd also see if I could add logs to the desktop autostart process, if possible.

Also assuming the obvious which are that the lockscreen.desktop owner and permissions are the same as any other .desktop files which do run.

Same for the shell script, that it's permissions are at least 755.

zetrotrack000 12-26-2018 12:23 PM

Quote:

Originally Posted by rtmistler (Post 5941451)
Agree.

At this point I'd try to add logs to various parts of the process and see if they reveal anything. I know you can add logs to the script, however I'd also see if I could add logs to the desktop autostart process, if possible.

Also assuming the obvious which are that the lockscreen.desktop owner and permissions are the same as any other .desktop files which do run.

Same for the shell script, that it's permissions are at least 755.

Script permission wasn't 755, so I changed it to 755 but still not working. Regarding .desktop files, there are several files in ~/.config/autostart with different permissions:
Code:

-rwxr--r-- 1 user  1000 11065 Dec 24 20:16 firefox.desktop
-rwxr--r-- 1 user users  228 Dec 26 20:05 lockscreen.desktop
-rw-r--r-- 1 user users 15045 Dec 26 20:18 nemo.desktop
-rw-r--r-- 1 user users 14833 Dec 26 16:45 org.gnome.Terminal.desktop
-rw-r--r-- 1 user users  8001 Dec 26 16:45 print-applet.desktop
-rw-r--r-- 1 user users  5005 Dec 26 16:45 pulseaudio.desktop
-rwxr--r-- 1 user  1000  6961 Dec 24 20:16 thunderbird.desktop
-rwxrw-r-- 1 user  1000  610 Dec 24 20:16 whatsie.desktop

All run at startup, except lockscreen.desktop.
Regarding log, I don't know that how can I add log to a script.

zetrotrack000 12-26-2018 12:28 PM

1 Attachment(s)
One very strange thing is that when I click on "Run Button" in "Startup Applications" (check attached image), the script runs fine and loads screensaver. Doesn't it prove that the script formation, permission and location, all are correct?

rtmistler 12-26-2018 12:52 PM

Not arguing the point, however it's not behaving as expected. Thus, debug as best as you can.

Me, I'd put in log outputs to a file within the script saying stuff like "Entered", "Successfully ran script", and so forth.

And I'd try to figure a way the desktop startup works where I could add debug to it. Perhaps there is a flag which can be used.

rtmistler 12-26-2018 12:54 PM

Quote:

Originally Posted by zetrotrack000 (Post 5941455)
Regarding log, I don't know that how can I add log to a script.

Code:

echo "this is a log line" >>  /home/xxx/yyy/logfile.txt;


All times are GMT -5. The time now is 01:09 PM.