Why doesn't my .desktop file show in the menu under "Science"? - x11

The following .desktop file shows up under "Other" but not "Science" as indicated by the category. How do I define the menu item under which it should show?
I'm using Mate Desktop 1.16.2, but I think this is a standard XDG thing so the window manager shouldn't matter too much.
]$ cat /usr/share/applications/xnec2c.desktop
[Desktop Entry]
Name=Xnec2c
GenericName=NEC2 Simulator
Comment=Numerical Electromagnetics Code software
Exec=xnec2c
Icon=xnec2c
Terminal=false
Type=Application
Categories=Science;
Keywords=nec2;em;simulator;
X-Desktop-File-Install-Version=0.23
MimeType=application/x-nec2;
See also this related question: Make xdg-utils associate a file extension with my application from a distribution package?

Related

How can I make Atom my default editor when I open a file from terminal?

Every time I open a file from the terminal it opens the file in Xcode.
open hashing.md then Xcode opens. I don't want it to open in Xcode.
How can I make my terminal open files in Atom instead?
I'm on a Mac, Monterey, 12.1.
(I'm at the point where I just want to uninstall Xcode, but, who knows, I may need it in the future.)
I see this suggestion from someone, but I don't know how to do it. How do I "add the following to my ~/.bashrc file?" What does that mean? Where is my ~/.bashrc file and how do I add to it?
Add the following to your ~/.bashrc file:
export EDITOR="/Applications/TextEdit.app/Contents/MacOS/TextEdit"
Open finder and look for a file with the extension you want to open using atom, ".md" for example.
Right click on it and go to "Get info". You should see an "Open With" tab. Click on it, choose atom and click on the "Change all" button. That will make it the default option to open any ".md" file.
In case you just want to open a certain file with atom, use the -a flag with the open command.
~% open -a atom file.md

Change directory in terminal using hyperlinks

Opening a gnome-terminal in the specified directory is straightforward:
gnome-terminal --working-directory ~/dotfiles
Creating hyperlinks is not a problem:
echo -e '\e]8;;file:///home/pmn/dotfiles\aThis is a link\e]8;;\a'
this produces a link that opens the file explorer in the correct folder when Ctrl+Clicked.
What I want to do is combine the two things, so that when I Ctrl+Click the link, a terminal pops up, already in the requested folder. It would not be a problem if the current terminal I'm in changed directory, but in that case I'd like to still see the previous terminal output and just do the equivalent of a regular cd (Edit: Note that the ~/dotfiles folder is just an example, I have several links that are generated by a script, and I'd like to be able to click on them to quickly open a terminal where needed).
I tried fiddling with registering custom applications:
In ~/.local/share/applications/mimeapps.list add:
(Note that the use of this file is deprecated, ~/.config/mimeapps.list should be used, if you have tips on doing that properly I'm open to them)
[Default Applications]
x-scheme-handler/mygnometerm=mygnometerm.desktop
In ~/.local/share/applications/mygnometerm.desktop add:
[Desktop Entry]
Type=Application
Terminal=false
Name=My Gnome Terminal
Exec=/bin/gnome-terminal --working-directory=%f
MimeType=x-scheme-handler/mygnometerm
Create the folder for the mime database:
mkdir -p ~/.local/share/mime/packages
Update the mime database:
update-mime-database ~/.local/share/mime
This does work: if I right-click on a folder in the file explorer and select My Gnome Terminal as the app to use, a terminal is opened already in the right folder.
If I print
echo -e '\e]8;;mygnometerm:///home/pmn/dotfiles\aThis is a link\e]8;;\a'
and click on the link, a terminal does pop up, but in the root folder, and the same happens when running
gio open mygnometerm:///home/pmn/dotfiles
I just need to combine everything, but I tried a lot of combination of what to echo in the link and could not find the right one.
I'm also open to other ways to achieve this behaviour, but at this point I'm quite curious in how to to it this way.
The use case, for the curious, is that I made a simple script to check the status of my repos, and I want to click on the ones with things to do without having to copy and paste the path. I reckon I'll save at least 5 seconds!
Cheers!

How to set windows title in python qt?

I develop in pyqt and i made deb package on Ubuntu. It contain .desktop file, so it automatically add icon to main menu. When I start application windows title is correct but in gnome bar shows s_main.pyw which is name of main script in application. It is possible to set correct name in that bar?
Here's a link to image!
I found answer. Simply you can enter name of application in constructor of QApplication object. Like this.
app = QtGui.QApplication(['Here application name'])
This name shows in gnome shell.
Gnome required .desktop file located in /usr/share/applications or ~/.local/share/applications.
Example of myapp.desktop file:
[Desktop Entry]
Name=Application Name
Comment= My application description
Terminal=false
Type=Application
Categories=Development;Education
Exec=path/to/main-script
Icon=path/to/icon
Name from example will be displayed in Gnome top bar. Exec is path to your main script (in your case s_main.pyw).
Also you should restart Gnome to show changes (Alt + F2, type r and Enter).

Why does the TextMate title bar not show the file path when opened with the "mate" command?

When I open a file in TextMate using the mate command the title bar does not allow me to right click to see the path of the file while files opened within the TextMate app do show the full path. Is there something about the behavior of the mate command that prevents this functionality or is this a bug?
If you wish to have the path visible in the title bar the mate command must include the full path of the file. Using mate with an assumed current working directory (CWD) does not inherently provide mate the full file path.
If you have a local project .tm_properties file it's trivial to have TM2 display the path - add something like:
windowTitle = "$TM_DISPLAYNAME – $TM_DIRECTORY"
Works with $ mate [filename] in terminal and in normal finder use.
But I agree it's pretty lame that it doesn't seem to work for the global .tm_properties - though I'd love to be proved wrong!
Go to folder "/Applications/TextMate.app/Contents/Resources" or where your TextMate.app installation folder. Close textmate app before modifying the file.
Modify the file Default.tmProperties as below. I have provided the diff here:
diff Default.tmProperties
../textmateBin/TextMate.app/Contents/Resources/Default.tmProperties
10c10
< windowTitleProject = '${projectDirectory:+ — ${projectDirectory}}'
windowTitleProject = '${projectDirectory:+ — ${projectDirectory/^.*///}}'
Restart your textmate app and it should display your folder path :)
I think TextMate has updated the documentation on their website.
It even contains a similar snippet to solve the issue above.
For example, if we want to show the path as relative to the project
folder, we can use:
windowTitle = '${TM_DIRECTORY:+${TM_DIRECTORY/^${projectDirectory}(?:\/(.+))?/${1:+$1/}/}}$TM_DISPLAYNAME$windowTitleProject$windowTitleSCM'
Source: https://macromates.com/textmate/manual/projects

How to startup a Mac OS X application from command line?

"open -a" is not the answer wanted, because I want to debug the Mac OS X application automatically. This means it's better if someone can give the command line like [program] [args] format. So ltrace mechanism can make [program] as target for debugging and take [args] as input.
I have tried command line like "/Applications/Microsoft Office 2011/Microsoft PowerPoint.app/Contents/MacOS/Microsoft PowerPoint" /Users/poc.pptx, only Microsoft Point process started but the poc.pptx not opened.
After grepping the Microsoft Point with pptx file opened, it's something like: /Applications/Microsoft Office 2011/Microsoft PowerPoint.app/Contents/MacOS/Microsoft PowerPoint -psn_0_307275, there is no argument "poc.pptx".
I even manually use "gdb /Applications/Microsoft Office 2011/Microsoft PowerPoint.app/Contents/MacOS/Microsoft PowerPoint" and "set args /Users/poc.pptx", and then "r", the target application can not run with the certain file opened.
I am confused about this, so, is there someone can help me to solve this problem?
Thank you!
open -b com.microsoft.PowerPoint <filename> seems to work for me to open presentations from the command line.
Go to file directory and then type
open -a "Microsoft PowerPoint" <filename.ppt>
Here "Microsoft PowerPoint" is the name of power point application, please check name of power point if it is different in your application directory.
This is working perfectly fine on my MAC (OSX 10.8).
We can also give complete path instead of just file name.
open -a "Microsoft PowerPoint" <ppt file path>
This is also working fine.
I know this is a old question, but here is my 2ct anyway.
I add the applications I want to open through command line in /usr/local/bin as a symlink.
I never run into any problems, but as Ken stated it depends how a application handles arguments.
Example with Visual Studio:
First I check what makes the application start bij executing the file inside the App contents like:
$ /Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron
If that works, then I create the symlink as follows (ln -s <path-to-app> <path-to-symlink>):
$ ln -s /Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron /usr/local/bin/vs
After that I can start up Visual Studio with the current folder loaded as:
~/Development/SomeProject $ vs .
If PowerPoint is not opening a document passed as a command-line argument, then that's a reflection on how PowerPoint was coded. There's nothing anybody but Microsoft can do about that.
The OS does not normally use that technique to tell applications to open documents. Instead, it passes Apple Events to the application. Cocoa will, by default, accept command-line arguments and treat them similarly to such Apple Events, but apparently PowerPoint is overriding that default behavior.
If you want to debug or trace PowerPoint, I recommend that you do it in two steps. First, launch it without arguments under the debugger or trace program. Then, tell it to open a document. You can do that in the normal way, using the Finder and/or Dock, or you can use open -a .... Such a request to open a document will not launch a second instance of PowerPoint, it will deliver an event to the already-running PowerPoint which you are debugging/tracing. So, the result should be similar to what you seem to want.
Not sure if this will help you (depends on how you want to do your debugging), but you can use AppleScript from the command line, like this:
%osascript <<<EOD
tell application "Excel" to open "Users:xxx:Documents:sheet.xls"
EOD
When entered this way, your script can contain several lines, it does not have to be limited to a single one.

Resources