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");
Related
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;
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
I have RedHat linux. Intention is to start the java based GUI app after linux system finishes boot up. I have edited /etc/rc.local and kept
/usr/java/jre1.7.0_60/bin/java -jar /home/rfgwtest/Desktop/CEM/CEM_v2.0_Beta08/CEM_v2.0_Beta08/PME_CEM.jar &
at the end of the file. I am able to run this file for testing by executing the file on prompt. no errors of path or so.
what is missing as part of this? i have found this tip from the RedHat website
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Installation_Guide/s1-boot-init-shutdown-run-boot.html
is there a common way to do this across the different kind of distribution ?
Maybe, creating a desktop entry will do it.
To do that,
$ cd
$ nano .config/autostart/javaApp.desktop
now, write this inside it,
[Desktop Entry]
Type=Application
Exec=usr/java/jre1.7.0_60/bin/java -jar /home/rfgwtest/Desktop/CEM/CEM_v2.0_Beta08/CEM_v2.0_Beta08/PME_CEM.jar
Hidden=false
NoDisplay=false
Name[en_IN]=StartJAR
Name=StartJAR
Comment[en_IN]=Jar comment
Comment=Jar comment
save the file and then, restart or re-login to the system.
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.
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?