PDA

View Full Version : Installer framework CreateDesktopEntry help



adutzu89
10th December 2016, 18:20
I'm trying to create a desktop entry using a script file with the installer framework but not working.

Here is the content of the script file:


function Component() {
installer.finishButtonClicked.connect(this, Component.prototype.installationFinished);
}

Component.prototype.createOperations = function() {
component.createOperations();
}

Component.prototype.installationFinished = function() {
try {
if (installer.isInstaller() && installer.status == QInstaller.Success) {
component.addOperation("CreateDesktopEntry",
"@HomeDir@/.local/share/applications/Cumulus.desktop",
"Type=Application\n
Terminal=false\n
Exec=@TargetDir@/Cumulus\n
Name=Cumulus\n
Icon=@TargetDir@/cumulus.svg");
component.addOperation("Copy", "@HomeDir@/.local/share/applications/Cumulus.desktop", "@HomeDir@/Desktop/Cumulus.desktop");
QDesktopServices.openUrl("file:///" + installer.value("TargetDir") + "/InstallationLog.txt");
}
} catch(e) {
console.log(e);
}
}

I also have tried the following version for installation Finished:


Component.prototype.installationFinished = function() {
var targetDir = installer.value("TargetDir");
var homeDir = installer.value("HomeDir");
var desktopFileTarget = installer.value("HomeDir") + "/.local/share/applications";
try {
if (installer.isInstaller() && installer.status == QInstaller.Success) {
component.addOperation("CreateDesktopEntry",
desktopFileTarget + "/Cumulus.desktop",
"Type=Application\nTerminal=false\nExec= " + targetDir + "/Cumulus\nName=Cumulus\nIcon= " + targetDir + "/cumulus.svg");
QDesktopServices.openUrl("file:///" + installer.value("TargetDir") + "/InstallationLog.txt");
}
} catch(e) {
console.log(e);
}
}

The script runs and no error is logged, when finishing the InstallationLog.txt opens and is there to confirm that the script is running.
I have also tried copying a file from within installation using Copy operation but not working at all either.

anda_skoa
11th December 2016, 11:57
I don't have any know-how on the installer framework, but have you tried a tmp path for the target to see if it could be a path problem?

Cheers,
_

P.S.: $HOME/.local/share is the fallback default value if $XDG_DATA_HOME is not set, so you could end up with a wrong path on systems where that is set to something else

adutzu89
11th December 2016, 13:14
Hi anda,
I don't understand what you mean by tmp path, you mean an absolute path for the desktop entry? I have tried that.
I also tried other operations, if it's not written correctly I get errors otherwise it doesn't fire.......I don't understand what's happening :|

Added after 15 minutes:

Appearently Qt Installer Framework doesn't do operations after finish button was clicked.........

I have modified my script this way:

function Component() {}
Component.prototype.createOperations = function() {
component.createOperations();
var targetDir = installer.value("TargetDir");
var homeDir = installer.value("HomeDir");
var desktopFileTarget = installer.value("HomeDir") + "/.local/share/applications";
component.addOperation("CreateDesktopEntry",
"Cumulus.desktop",
"Type=Application\nTerminal=false\nExec= " + targetDir + "/Cumulus\nName=Cumulus\nIcon= " + targetDir + "/cumulus.svg");
component.addOperation("CreateDesktopEntry",
homeDir + "/.config/autostart/Cumulus.desktop",
"Type=Application\nTerminal=false\nExec= " + targetDir + "/Cumulus\nName=Cumulus\nIcon= " + targetDir + "/cumulus.svg");
}

Makes both Dash entry and autostart on login.

anda_skoa
12th December 2016, 11:20
Hi anda,
I don't understand what you mean by tmp path, you mean an absolute path for the desktop entry?

Yes, a fixed path, probably in the system temp directory. Something you know exists and is user writable.

Cheers,
_