I have been trying to get desktop shortcuts to be created on Linux-64 system with only marginal success. The installer is set to required administrator privilege. I have also define the default user and group for file ownership (I am logging into the system as that user, anyway). When running the installer from this user's account, I am installing using SUDO to satisfy the 'administrators' privilege requirement.

I tried creating a plain "shortcut" (under the "desktopShortcutList"), but that never created the shortcut UNLESS I removed the requirement for the installer to be run with "administrator" privilege. I then found the question that another user had posted regarding using SUDO and creating a desktop short (using a "fileShortcut"), but that also did not work (with admin privilege required--I did not try without this requirement). Any help would be appreciated.

My original code looked like this (it contains a rule that is evaluating to true):

<desktopShortcutList>
    <shortcut>
        <comment>${msg(DesktopShortcut.comment)}</comment>
        <exec>${installdir}/bin/myProg.sh</exec>
        <icon>${installdir}/bin/myProg48.png</icon>
        <name>My Prog</name>
        <path>${installdir}/bin</path>
        <platforms>all</platforms>
        <runAsAdmin>0</runAsAdmin>
        <runInTerminal>0</runInTerminal>
        <windowsExec>${installdir}/bin/myProg.exe</windowsExec>
        <windowsExecArgs></windowsExecArgs>
        <windowsIcon>${installdir}/bin/myProg.exe</windowsIcon>
        <windowsPath>${installdir}/bin</windowsPath>
        <ruleList>
            <isTrue>
                <value>${createShortcut}</value>
            </isTrue>
        </ruleList>
    </shortcut>
</desktopShortcutList>

I modified it to include the "fileShortcut". Note: I changed the "shortcut" to be only be for the "windows" platform and the new fileShortcut to be for the "linux-x64 & linux" platforms". Here is the new code:

<desktopShortcutList>
    <shortcut>
        <comment>${msg(DesktopShortcut.comment)}</comment>
        <exec>${installdir}/bin/myProg.sh</exec>
        <icon>${installdir}/bin/myProg48.png</icon>
        <name>My Prog</name>
        <path>${installdir}/bin</path>
        <platforms>windows</platforms>
        <runAsAdmin>0</runAsAdmin>
        <runInTerminal>0</runInTerminal>
        <windowsExec>${installdir}/bin/myProg.exe</windowsExec>
        <windowsExecArgs></windowsExecArgs>
        <windowsIcon>${installdir}/bin/myProg.exe</windowsIcon>
        <windowsPath>${installdir}/bin</windowsPath>
        <ruleList>
            <isTrue>
                <value>${createShortcut}</value>
            </isTrue>
        </ruleList>
    </shortcut>
    <fileShortcut>
        <comment>${msg(DesktopShortcut.comment)}</comment>
        <filePath>${installdir}/bin/myProg.sh</filePath>
        <icon>${installdir}/bin/myProg48.png</icon>
        <name>My Prog</name>
        <platforms>linux-x64 linux</platforms>
        <runAsAdmin>0</runAsAdmin>
        <runInTerminal>0</runInTerminal>
        <windowsIcon></windowsIcon>
        <ruleList>
            <isTrue>
               <value>${createShortcut}</value>
            </isTrue>
        </ruleList>
    </fileShortcut>
</desktopShortcutList>

asked 17 Oct '12, 17:28

DennisU's gravatar image

DennisU
16779
accept rate: 0%


I got this to work with both sudo and kdesu as follows:

<setInstallerVariable>
    <name>realUser</name>
    <value>${env(SUDO_USER)}</value>
    <ruleList>
        <stringTest text="${env(SUDO_USER)}" type="not_empty"/>
    </ruleList>
</setInstallerVariable>
<setInstallerVariable>
    <name>realUser</name>
    <value>${env(KDESU_USER)}</value>
    <ruleList>
        <stringTest text="${env(KDESU_USER)}" type="not_empty"/>
    </ruleList>
</setInstallerVariable>
<setInstallerVariable name="desktopDir" value="/home/${realUser}/Desktop"/>

Then when you go to create the shortcuts, make sure the desktopDir exists:

<createShortcuts>
  <destination>${desktopDir}</destination>
  <shortcutList>
   ...
  </shortcutList>
  <ruleList>
    <fileTest path="${desktopDir}" condition="is_directory"/>
  </ruleList>
</createShortcuts>

I think it also works with the GNOME gksudo, which also sets SUDO_USER, if I recall correctly.

link

answered 24 Jul '13, 16:52

Chard%20Nelson's gravatar image

Chard Nelson
161
accept rate: 0%

Running with sudo causes the shortcuts to be put in root user's desktop, not current user. Unfortunately Unix systems do not provide equivalent of Windows' common desktop items that are put on all users' desktops.

It is possible to determine directory for creation of icons by checking SUDO_USER environment variable and creating the shortcuts as actions:

<setInstallerVariable> <name>desktop_directory</name> <value>~/Desktop</value> </setInstallerVariable> <setInstallerVariable> <name>desktop_directory</name> <value>~${env(SUDO_USER)}/Desktop</value> <ruleList> <compareTextLength> <length>0</length> <logic>greater</logic> <text>${env(SUDO_USER)}</text> </compareTextLength> </ruleList> </setInstallerVariable> <createShortcuts> <destination>${desktop_directory}</destination> <shortcutList> <!-- shortcuts to create --> </shortcutList> </createShortcuts>

However, this may not work for gksu or kdesu commands.

link

answered 18 Oct '12, 08:12

wojciechka's gravatar image

wojciechka ♦♦
7.8k61122
accept rate: 26%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×72
×41
×22
×5
×2
×1

Asked: 17 Oct '12, 17:28

Seen: 2,081 times

Last updated: 24 Jul '13, 16:52