Desktop shortcut gives error "KDEInit could not launch" - linux

I am on Linux Mint KDE.
I created a c++ executable using Netbeans. Then I added the folder where the executable was to the path.
If I go to the terminal and run the executable it runs fine.
I next create a desktop file with the following
[Desktop Entry]
Categories=Application;
Comment[en_US]=
Comment=
Exec=myprog
GenericName[en_US]=
GenericName=
Icon=utilities-terminal
MimeType=
Name[en_US]=Test
Name=Test
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
Version=1.0
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=
I change the permission of this desktop file to executable. If I double click the desktop file, I get a message saying "KDEInit could not launch 'myprog':
Could not find 'myprog' executable."
I wish to create a desktop shortcut to my executable. What am I doing wrong? Do I need to specify the path again in the desktop file?

Related

How to add an icon of app that I have downloaded in Ubuntu?

I have downloaded Webstorm, but accidentally I did not see an icon. Then I just wrote a command "bash webstorm.sh" and then Webstorm run. But I really don't want to run WS with this method. Help me
just create a desktop file ( a file with desktop extension, for example my_app.desktop) and then move this file under "~/.local/share/applications" or under "/usr/share/applications" (if you are a member of sudoers and you can run a command with sudo).
your desktop file should be similar to this
[Desktop Entry]
Name=Webstorm
Comment=terminal app
Exec="bash webstorm.sh"
Terminal=false
Type=Application
Icon=path_to_icon
Categories=IDE;

VSCode icon is missing in app switcher on Ubuntu

After I installed VSCode using the the "Snap Store" on Ubuntu Mate 20.04 (Using compiz).
When I do the app switching with ALT+TAB the icon of the VSCode icon is missing.
The original path for the icon is at /snap/code/43/meta/gui/com.visualstudio.code.png.
I encountered this issue only in the app switcher for VSCode.
Other snap apps works as they should.
The content of /var/lib/snapd/desktop/applications/code_code.desktop:
[Desktop Entry]
X-SnapInstanceName=code
Name=Visual Studio Code
Comment=Code Editing. Redefined.
GenericName=Text Editor
Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/code_code.desktop /snap/bin/code --force-user-env --no-sandbox --unity-launch %F
Icon=/snap/code/43/meta/gui/com.visualstudio.code.png
Type=Application
StartupNotify=false
StartupWMClass=Code
Categories=Utility;TextEditor;Development;IDE;
MimeType=text/plain;inode/directory;
Actions=new-empty-window;
Keywords=vscode;
[Desktop Action new-empty-window]
Name=New Empty Window
Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/code_code.desktop /snap/bin/code --force-user-env --no-sandbox --new-window %F
Icon=/snap/code/43/meta/gui/com.visualstudio.code.png
If you install through snap, sometimes the *.desktop file does not update correctly.
You should change the Icon= path in the following file, which is the one the system uses:
/usr/share/applications/code_code.desktop
So for instance, I had to change /usr/share/applications/code_code.desktop attributes of [Desktop Entry] and [Desktop Action new-empty-window], with the correct path in Icon=, which I found in /var/lib/snapd/desktop/applications/code_code.desktop
Icon=/snap/code/85/meta/gui/com.visualstudio.code.png
instead of
Icon=/snap/code/64/meta/gui/com.visualstudio.code.png
I guess you can also do:
cat /var/lib/snapd/desktop/applications/code_code.desktop > /usr/share/applications/code_code.desktop
This is VSCode bug #71942 on github. Edit /var/lib/snapd/desktop/applications/code_code.desktop and change the Icon path to /snap/code/43/meta/gui/com.visualstudio.code.png

run external application in linux using qprocess

I am creating an GUI application using QT creater in Raspbian. When I click a button I want to open an external application like terminal, or browser, etc.
I have tried many attempts
attempt 1
std::system("/usr/share/raspi-ui-overrides/applications/scratch.desktop&");
it says me permission denied
attempt 2
QDesktopServices::openUrl(QUrl("/usr/share/raspi-ui-overrides/applications/scratch.desktop"));
this one is working but its not opening the application but its opening in terminal:
QDesktopServices::openUrl(QUrl("/usr/share/raspi-ui-overrides/applications/scratch.desktop"));
I'm assuming the question is about Raspberry Pi and Raspbian.
In Raspbian, the scratch.desktop and other *.desktop files are not executables, but just text files that describe which application to run.
Example:
pi#raspberrypi:~ $ cat /usr/share/raspi-ui-overrides/applications/scratch.desktop
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
TryExec=scratch
Exec=scratch
Icon=scratch
Terminal=false
Name=Scratch
Comment= Programming system and content development tool
Categories=Application;Development;
MimeType=application/x-scratch-project
You need to use an actual binary to start the process. For scratch, it would be /usr/bin/scratch. For a browser, it's likely to be /usr/bin/epiphany-browser. Look at Exec= line in the *.desktop file to see the name of the executable, then use which in the terminal to see its location:
pi#raspberrypi:~ $ which epiphany-browser
/usr/bin/epiphany-browser
The .desktop files are not executable, but serve as shortcuts for the desktop system. Assuming that the scratch.desktop has the following:
scratch.desktop
[Desktop Entry]
Name=Scratch
Comment= Programming system and content development tool
Exec=scratch
Terminal=false
Type=Application
Icon=scratch
Categories=Development;
MimeType=application/x-scratch-project
Then the executable is /usr/bin/scratch, And you can run it with Qt:
QProcess::startDetached("/usr/bin/scratch");
Or:
QProcess::execute("/usr/bin/scratch");

How to create a desktop-entry in Gnome?

I have installed ProM 6.8 (a process mining tool, written in Java) and after executing the command ./ProM68.sh & in a terminal, the application starts without problems.
I tried to create both a desktop-entry in Gnome 3 (on Fedora 28) or a menu-item.
This is my desktop-entry:
[Desktop Entry]
Name=Prom
Exec=/home/bengbers/Programs/Prom/ProM68.sh %u
Type=Application
StartupNotify=true
Terminal=false
Categories=Development;Java;
After double-clicking this iscon, nothing happens.
I also tried adding an entry in the main-menu but this entry fails also.
How can I create a working desktop entry?
Ben
Prom needed a .ini file to start. After adding a path to the directory, everything worked fine.
Ben

LXDE .desktop file permission issue

I’m trying to run a Python script via a desktop icon/shortcut/launcher on a Raspberry Pi using Raspbian and LXDE. I have to use a desktop launcher since the script has to be started via a tiny touchscreen only accepting left-clicks and without a keyboard.
I think that I have a permission issue since the script fails at a point where it should execute some system commands which require root.
The script works if I do the following:
Open a terminal
Enter sudo python3 program.py
I tried to replicate this behavior with a .desktop file using the following config:
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Exec=sudo python3 program.py
Terminal=true
Icon=path/to/icon.png
Name=Program Launcher
I suppose I missed something obvious, but since I don’t work with Linux usually I’m a bit lost here.
Edit: The problem was not a missing permission but an incorrectly assumed working directory and is now solved. Sorry for my confusion.
In detail: during development the script was started from its own folder while the desktop launcher used /home/pi as working directory. In general that's not a problem, but in the script a hardcoded path was used and a required file not found when using the launcher. The real problem was sloppy swallowed and the status code of a permission issue returned. So it was simply a bad code issue.
As docs for desktop entries says:
The Exec key must contain a command line. A command line consists of
an executable program optionally followed by one or more arguments.
The executable program can either be specified with its full path or
with the name of the executable only. If no full path is provided the
executable is looked up in the $PATH environment variable used by the
desktop environment. The name or path of the executable program may
not contain the equal sign ("="). Arguments are separated by a space.
It leads to conclusion, that maybe python3 is not within $PATH used by the desktop environment. Try to check full path of your python3 and sudo with:
whereis python3
whereis sudo
on my Archlinux it gives me /usr/bin/python3 and /usr/bin/sudo. Try to modify your Dekstop entry to something like:
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Exec=/usr/bin/sudo /usr/bin/python3 program.py
Terminal=true
Icon=path/to/icon.png
Name=Program Launcher
Let me know if this helps.

Resources