LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Autoload Python Script at Cinnamon Login (https://www.linuxquestions.org/questions/linux-newbie-8/autoload-python-script-at-cinnamon-login-4175533042/)

zetrotrack000 02-04-2015 09:14 AM

Autoload Python Script at Cinnamon Login
 
Hi
I am using Cinnamon desktop on the top of arch linux. I wanted to load a python script at desktop login which informs me about battery stats, so I created a batterymonitor.desktop entry under ~/.config/autostart. The contents of batterymonitor.desktop are:
Code:

[Desktop Entry]
Type=Application
Exec=python /home/<myusername>/scripts/battery_monitor.py
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=BatteryMonitor
Name=BatteryMonitor
Comment[en_US]=
Comment=
X-GNOME-Autostart-Delay=0

But the problem is that the script is not loading at cinnamon login. I have also confirmed that the script is executable.
Can you help to load this script at cinnamon login?
Regards

JeremyBoden 02-04-2015 03:15 PM

The only autostart user job in ~/.config I have is as follows:-
Code:

[Desktop Entry]
Version=1.0
Type=Application
Name=SpiderOak
GenericName=File Backup and Synchronizer
Comment=Privately sync, backup, and share your data across your computers.
Comment[en_US]=Privately sync, backup, and share your data across your computers.
Icon=SpiderOak
Exec=SpiderOak
Terminal=false
Categories=Network;Archiving;Utility;

This gives an iconised process.

zetrotrack000 02-04-2015 03:49 PM

I have 2 more, dropbox and pulse audio. I want to create this 3rd one but not able to succeed yet :(

JeremyBoden 02-04-2015 07:15 PM

Is it listed in Admin, System settings, Start-up Programs?

zetrotrack000 02-05-2015 04:35 AM

Quote:

Originally Posted by JeremyBoden (Post 5312214)
Is it listed in Admin, System settings, Start-up Programs?

Yes. Check this screenshot:
http://s12.postimg.org/b2uaennfh/Sta...rences_001.png
I suspect that the problem is with this line:
Code:

Exec=python /home/<myusername>/scripts/battery_monitor.py
I have also tried following variation:
Code:

Exec=python /home/<myusername>/scripts/battery_monitor.py
Exec=/usr/bin/python /home/<myusername>/scripts/battery_monitor.py
Exec=python '/home/<myusername>/scripts/battery_monitor.py'
Exec=python "/home/<myusername>/scripts/battery_monitor.py"
Exec=/home/<myusername>/scripts/battery_monitor.py

But none worked.

zetrotrack000 02-05-2015 04:37 AM

PS. PowerTop is showing that the process is running, but its not working like it used to do when I launch it from terminal.

SaintDanBert 02-08-2015 04:33 PM

Quote:

Originally Posted by zetrotrack000 (Post 5312403)
PS. PowerTop is showing that the process is running, but its not working like it used to do when I launch it from terminal.

This is just a guess...

It might be that your python script runs BEFORE there are enough desktop parts active to support it correctly. For example, the desktop is an X-Windows DISPLAY. If your script's shell cannot learn the active DISPLAY or if your script cannot get proper access, the the script will not be able to create and open an on-desktop window.

SUGGESTIONS:

There are ways for your script to wait until needed resources are available.

There are ways to impose a sequence on the various login-time applications.

If all else fails, you could insert a run-time delay (consider adding a WAIT=nn script parameter) to allow for some time passage and those resources to be active.

Good luck,
~~~ 0;-Dan


All times are GMT -5. The time now is 03:15 AM.