示例#1
0
        // Creates a .desktop entry in autostart folder to
        // start SparkleShare automatically at login
        public override void EnableSystemAutostart()
        {
            string autostart_path   = SparkleHelpers.CombineMore(SparklePaths.HomePath, ".config", "autostart");
            string desktopfile_path = SparkleHelpers.CombineMore(autostart_path, "sparkleshare.desktop");

            if (!File.Exists(desktopfile_path))
            {
                if (!Directory.Exists(autostart_path))
                {
                    Directory.CreateDirectory(autostart_path);
                }

                TextWriter writer = new StreamWriter(desktopfile_path);
                writer.WriteLine("[Desktop Entry]\n" +
                                 "Type=Application\n" +
                                 "Name=SparkleShare\n" +
                                 "Exec=sparkleshare start\n" +
                                 "Icon=folder-sparkleshare\n" +
                                 "Terminal=false\n" +
                                 "X-GNOME-Autostart-enabled=true\n" +
                                 "Categories=Network");
                writer.Close();

                // Give the launcher the right permissions so it can be launched by the user
                UnixFileInfo file_info = new UnixFileInfo(desktopfile_path);
                file_info.Create(FileAccessPermissions.UserReadWriteExecute);

                SparkleHelpers.DebugInfo("Controller", "Created: " + desktopfile_path);
            }
        }