Sunday, November 1, 2015

Auto start wanted application on Lubuntu log in.




Putting launcher into ~/.config/autostart. Ref
CreatAutoStartShell.py '' ''
./CreatAutoStartShell.py vncserverstart /home/qyang/startvncserver.sh
./CreatAutoStartShell.py startxcompmgr /home/qyang/startxcompmgr.sh
startvncserver.sh
#!/bin/bash
vncserver &
startxcompmgr.sh
#!/bin/bash
xcompmgr -n &
CreatAutoStartShell.py
#!/usr/bin/env python3
import os
import sys
home = os.environ["HOME"]

name = sys.argv[1]; command = sys.argv[2]

launcher = ["[Desktop Entry]", "Name=", "Exec=", "Type=Application", "X-GNOME-Autostart-enabled=true"]
dr = home+"/.config/autostart/"
if not os.path.exists(dr):
    os.makedirs(dr)
file = dr+name.lower()+".desktop"

if not os.path.exists(file):
    with open(file, "wt") as out:
        for l in launcher:
            l = l+name if l == "Name=" else l
            l = l+command if l == "Exec=" else l
            out.write(l+"\n")
else:
    print("file exists, choose another name")

No comments: