Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
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.
  1. #1
    Just Joined!
    Join Date
    Jan 2007
    Location
    Germany
    Posts
    73

    File extension problem under KDE


    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 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 [Right-click]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 .nb-file if this might help:
    Code:
    (************** Content-type: application/mathematica **************
                         CreatedBy='Mathematica 5.2'
    
                        Mathematica-Compatible Notebook

  2. #2
    Linux Newbie
    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

  3. #3
    Just Joined!
    Join Date
    Jan 2007
    Location
    Germany
    Posts
    73
    Thanks a lot !!! It works !!!

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    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
    so even if I rename MyFile.nb-->MyFile.txt, in Konsole the file is correctly recognized :
    Code:
    MyName@MyMachine: ~> file MyFile.txt
    MyFile.txt: Mathematica, or Pascal,  Modula-2 or 3 code text
    My question is how to make KDE also check this file.

    Thanks in advance,
    Xaleandr

  6. #5
    Linux Newbie
    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"

  7. #6
    Just Joined!
    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 "extension-based" files recognition (a la Windows) and I wonder if it is possible to make "contents-based" recognition for custom file types.
    For built-in 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

  8. #7
    Linux Newbie
    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?

  9. #8
    Just Joined!
    Join Date
    Jan 2007
    Location
    Germany
    Posts
    73
    Hello,

    Quote Originally Posted by Lost_scrib View Post
    did you find the mimelnk directories? Did you find .desktop files there? Did you try to make your own .desktop for Mathematica?
    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 extension-based 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 content-based 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

  10. #9
    Linux Newbie
    Join Date
    Sep 2005
    Location
    CZ
    Posts
    164

    Question

    Strange, that should be enough... What is the content of Mathematica.desktop file?

  11. #10
    Just Joined!
    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

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •