Results 1 to 10 of 13
Hello,
sorry for the stupid question,
but I have a problem and haven't found any solution to it on this forum so far.
The problem is how to recognize different ...
Enjoy an ad free experience by logging in. Not a member yet? Register.

 04252007 #1
 Join Date
 Jan 2007
 Location
 Germany
 Posts
 73
File extension problem under KDE
sorry for the stupid question,
but I have a problem and haven't found any solution to it on this forum so far.
The problem is how to recognize different file types under KDE.
I have Mathematica files (with extension .nb and plain text format).
I want them to be opened with Mathematica.
I try to edit them as [Rightclick]Properties>Settings>... and choose Filename patterns *.nb *.NB to be declared as Mathematica notebooks and opened with Mathematica. But after this all the plain text files (.txt, .cpp, .h ) are opened with Mathematica. When I declare these (.txt, .cpp, .h ) to be opened with KWrite, Mathematica notebooks are also opened with KWrite.
How is it possible to make KDE aware of the new filetypes ?
Thanks in advance,
Xaleandr
PS: Below are the first few lines of .nbfile if this might help:
Code:(************** Contenttype: application/mathematica ************** CreatedBy='Mathematica 5.2' MathematicaCompatible Notebook
 05072007 #2
 Join Date
 Sep 2005
 Location
 CZ
 Posts
 164
KDE Control center  KDE components (or something similar, I have localised version...)  File associations  select Text  click Add
 05082007 #3
 Join Date
 Jan 2007
 Location
 Germany
 Posts
 73
Thanks a lot !!! It works !!!
 05092007 #4
 Join Date
 Jan 2007
 Location
 Germany
 Posts
 73
One more question (related to the previous one) :
KDE is able to recognize some file types without any extension.
For example, if You rename files MyFile.zip and MyFile.avi to MyFile1 and MyFile2, KDE will correctly open them with ark and xine.
My question is how to make KDE recognize other files (in particular .nb) without extension.
I found in Google that Konsole reads file information from
/usr/share/misc/file/magic; I found that file contains
Code:0 string (*********************** Mathematica 5.0 notebook
Code:MyName@MyMachine: ~> file MyFile.txt MyFile.txt: Mathematica, or Pascal, Modula2 or 3 code text
Thanks in advance,
Xaleandr
 05092007 #5
 Join Date
 Sep 2005
 Location
 CZ
 Posts
 164
An explanation is provided in KDE Help center  User manual  VI. KDE for Administrators  26. Customizing KDE  File Associations
or here.
The search phrase is "KDE" + "MIME types"
 05092007 #6
 Join Date
 Jan 2007
 Location
 Germany
 Posts
 73
Thanks a lot for the prompt reply,
but my question was slightly different. Actually I have seen these pages (similar pages to be exact), my problem is that "magic" file is ignored and KDE somewhy uses "extensionbased" files recognition (a la Windows) and I wonder if it is possible to make "contentsbased" recognition for custom file types.
For builtin file types, even without any extension, KDE can easily distinguish, e.g. "html" from "postscript" (though both are just plain text files).
Of course I understand that in principle it is possible to use always extensions for the custom file types and not to have this problem. But I wanted to understand in detail if this is possible.
Xaleandr
 05092007 #7
 Join Date
 Sep 2005
 Location
 CZ
 Posts
 164
Well, let's try it step by step along with this old document: did you find the mimelnk directories? Did you find .desktop files there? Did you try to make your own .desktop for Mathematica?
 05102007 #8
 Join Date
 Jan 2007
 Location
 Germany
 Posts
 73
Hello,
Yes, I did. The Mathematica.desktop files in mimelnk/text were created automatically when I added filetype "Mathematica" from "Personal settings". As far as I understand these .desktop files are responsible for extensionbased filetype recognition, and this works fine, it is Ok.
Have a look at the document You cited in more detail, section about "magic". It is claimed that contentbased file recognition in KDE is defined in files
$KDEBASE/share/mimelnk/magic
$HOME/.kde/share/mimelnk/magic
I have these files and have entries for " (****** " pattern inside, but the files are NOT recognised.
I mean, any file will be opened with Mathematica if and only if it has extension .nb or .NB.
Xaleandr
 05102007 #9
 Join Date
 Sep 2005
 Location
 CZ
 Posts
 164
Strange, that should be enough... What is the content of Mathematica.desktop file?
 05112007 #10
 Join Date
 Jan 2007
 Location
 Germany
 Posts
 73
File Mathematica.desktop:
Code:[Desktop Entry] Comment=Mathematica Notebook Hidden=false Icon=/usr/local/Wolfram/Mathematica/5.0/SystemFiles/FrontEnd/SystemResources/X/mathematica.xpm MimeType=text/Mathematica Patterns=*.nb;*.NB Type=MimeType