I have lots of programs installed, for each one I append its directory to the $PATH variable.
this is easy, I open a terminal type the name and it runs, until I decided to make a desktop file for each program. It seems desktop files do not recognize the $PATH variable
[Desktop Entry]
Version=1.0
Terminal=false
Icon=/usr/share/applications/ISE.png
Type=Application
Categories=Digital
Exec=ise
Name=Xilinx ISE
It does not even appear in unity menu, the command ise usually works fine in a terminal, I also tried to use the complete /path/to/ise, still does not appear in search.
but if I remove ise and put for example gedit instead. it appears in search, opens gedit and works fine. how do I make Desktop files recognize the $PATH variable and execute these commands ??
Related
New to Cygwin and trying to launch the batch file from the current working directory. I've done similar things before for .exe files in Windows 10 using the Registry Editor (see link):
https://www.windowscentral.com/how-launch-bash-shell-right-click-context-menu-windows-10
My Cygwin.bat file looks like this:
#echo off
SETLOCAL
set HOME=C:\path\to\home
C:
chdir C:\cygwin64\bin
bash --login -i
ENDLOCAL
However, when I right click on a directory in order to "Open Cygwin.bat here", the terminal opens at C:\path\to\home. How can I make sure the terminal opens in the current working directory?
To obtain the expected result you need to use the chere package.
chere -i
is usually enough to create a proper Bash Prompt Here entry in Explorer left mouse button menu.
Please note that the usage of the cygwin.bat is not recommended anyway as does not use mintty as terminal
I have this .desktop file in /home/user/.local/share/applications
[Desktop Entry]
Categories=AudioVideo;Video;
Comment=This Bash script compresses the specified video files (wildcards supported) to lossy h.264 format in an MP4 container
Exec="\\$HOME/Scripts/Git/compress2mp4.sh" %F
GenericName=Batch compress to mp4
Icon=folder-video
MimeType=video/x-msvideo;video/quicktime;video/mpeg;video/mp4;
Name=Compress to mp4
NoDisplay=false
Path=
StartupNotify=true
Terminal=true
TerminalOptions=\s--noclose
Type=Application
Version=1.0
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=
which shows up in the "Open with" menu and works flawlessly.
Then I created another .desktop file and copied it in /home/user/.local/share/kservices5/ServiceMenus
[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=video/x-msvideo;video/quicktime;video/mpeg;video/mp4;
Icon=folder-video
Actions=compress2mp4
X-KDE-Priority=TopLevel
X-KDE-StartupNotify=false
X-KDE-Submenu=Video
[Desktop Action compress2mp4]
Name=Compress to mp4
Icon=video-mp4
Exec="$HOME/Scripts/Git/compress2mp4.sh" %F
The service menu shows up but gives this error:
Could not find the program '$HOME/Scripts/Git/compress2mp4.sh'
I tried to replace $HOME with \\$HOME and ~/ but it did not help.
If I type /home/my-user-name/... instead of the $HOME there is a window opens up in the background and closes up right away so I can't catch what is going on there.
Does anyone have an idea on why a .desktop file Type=service does not work while a very similar file Type=application works?
It seems that environment variables are not evaluated by .desktop file processors, as evidenced by similar problems posted online. If anything, it looks that KDE understanding environment variable in /home/user/.local/share/applications is a bug.
For one possible workaround, see this StackOverflow post. Personally, I created service menu with following entry and it did work as expected (pay attention to placement of quotation marks):
Exec=sh -c "$HOME/bin/test.sh %F"
If I use absolute path to script in Exec, it does show something that could be mistaken for "window in background". Name of process appears on taskbar (which usually shows only windows) and quickly disappears. In my case, that was because my test script had only one command inside and finished execution almost instantaneous. How long do you expect your program to run? Have you verified that it does not finish successfully?
If you don't want to use sh workaround and don't want to use absolute path inside .desktop file, consider placing your script in one of directories in $PATH, where .desktop file processor will look for it. You can see value of that variable from plasma point of view by using following command:
tr '\0' '\n' < /proc/$(pidof plasmashell)/environ
I am currently working on a Raspberry Pi. I want to implement a script to run a Python program at startup. I followed the steps given in this guide. The contents of my script are:
#! /bin/sh
# /etc/init.d/launchScript
cd path/to/file
python main.py
Although the script successfully runs at startup (file and I/O operations are working), but the terminal window doesn't appear. I am not able to debug any errors at all.
Can anyone help me on how to make the terminal appear so that debugging is possible?
From a forum post;
create a .desktop file, Ex. myApp.desktop
myApp.desktop file content:
[Desktop Entry]
Exec=lxterminal -e "/home/pi/main.py"
Type=Application
Than, copy myApp.destop to ~/.config/autostart directory.
I'm using arch linux with gnome and I try to open text files with vim by using nautilus. I already created a vim.desktop file in my .local/share/applications folder .
If I choose Vim in Nautilus, nothing happens. My default terminal doesn't work and I already tried to change my default terminal to terminator, but it didn't work. Maybe there is an other option to change the .desktop file to forcing nautilus to open a new terminator window with vim. I guess I need to change the exec parameter.
This should work
[Desktop Entry]
Name=VIM
GenericName=Text Editor
Comment=Edit text
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
Exec=vim %f
Type=Application
Terminal=true
Categories=Development;TextEditor;
Keywords=Text;Editor;
whenever I run eclipse from the shortcut I am unable to correctly build some of my projects because the PATH variable that I configured in .bashrc doesn't get used.
When I run eclipse from my terminal, I can build all my projects perfectly fine because it's running through the correct shell.
The problem is that I want to use the PATH variable from my .bashrc without permanently having a terminal open. I tried this before, but every day I accidentally close the terminal that's running eclipse by accident and lose all my unsaved code.
Can anyone help me?
Your tooling probably utilizes the embedded eclipse terminal. This terminal does not start providing your login/user shell. So you need to set the eclipse terminal in your Eclipse preferences to start as --login shell:
Go to:
Preferences -> Terminal -> Local Terminal
and set
"Arguments" to "--login"
restart Eclipse and your users $PATH should be used from now on.
Edit /usr/share/applications/eclipse.desktop with write privileges, i.e. sudo gedit /usr/share/applications/eclipse.desktop
Change the setting Exec=/usr/bin/eclipse to Exec=bash -ic "/usr/bin/eclipse" and save
The underlying issue is that .bashrc is not loaded in a non-interactive shell. When you start Eclipse normally clicking on its symbol, .bashrc quits early. This solution applies to all programs that are defined by a .desktop file.
In contrast, bash -i opens an interactive shell, -c "" runs a command in that shell.
I can think of two options for this problem:
write a small script, export those vars or source your .bashrc before you start your eclipse.
define those variables in /etc/environment. then they are not user-scope any more.
I prefer the 1st option.
Create simple script
#!/bin/bash
source /home/user/.environment_variables
/home/user/eclipse_cpp/eclipse -Duser.name="My Name"
2.
Next put your all system variables in file /home/user/.environment_variables (any file you want)
My looks like:
export COCOS_ROOT=/home/user/Projects/edukoala
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
3.
Now you can delete your variables in .bashrc and put line
source /home/user/.environment_variables
Everything works fine :)
Well, this is already answered and the answer has been accepted. But this will also work for running your code using Eclipse. You can edit the Run Configurations and set the environment variable there. Then, Eclipse will pick up the variable from this setting while building.