Find the answer to your Linux question:
Results 1 to 7 of 7
I wanted to replace the default action of opening .txt file with gedit to opening them with a script (the script opens up Notepad++). I looked in usr/share/applications/defaults.lst and i ...
  1. #1
    Just Joined!
    Join Date
    Oct 2011
    Posts
    67

    Question File associations and defaults.lst

    I wanted to replace the default action of opening .txt file with gedit to opening them with a script (the script opens up Notepad++).
    I looked in usr/share/applications/defaults.lst and i spotted the line

    Code:
    text/plain=gedit.desktop
    Now how can i make text/plain open up with a script called launch.sh ??
    Any suggestions ?? Is this even possible ??

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    This is NOT a good idea. Notepad will put CR/LF for newlines, where Linux uses LF only for newlines. IE, it will break most Linux utilities, shell scripts, and such. I would suggest you use an editor such as nedit, which if it detects that you are using a DOS/Windows file, will adjust accordingly, or you can override the newline settings in the preferences.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Oct 2011
    Posts
    67
    Interesting point..

  4. #4
    Just Joined!
    Join Date
    Oct 2011
    Posts
    67
    so i started using nedit and i have to admit that although its not as good as notepadd++ but its better than gedit and ill stick to nedit for now. However out of curiosity how would we go about accomplishing the above task ??

  5. #5
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    You need to run the notepad++ tool directly. Find the exe in "~/.wine/drive_c", using the command "find ~/.wine -iname 'notepad*'", then use that path directly in your script. IE, if the file is ~/.wine/drive_c/notepad.exe, then the script should use that path directly. If it has a space in the path, such as "Program Files", then enclose the entire thing in double quotes, except for the target filename argument. Example:
    Code:
    # use_notepad script
    "~/.wine/drive_c/Program Files/Notepad++/notepad++.exe" "$1"
    Note that the argument / filename "$1" is also in double quotes. This is because it may be a path with spaces as well.

    I hope this helps. Alternatively, you can simple associate some file types, such as .txt files, with the notepad++ executable. I do that for some programs that I have to run in Wine, such as when I want to run WinRar (.rar files) or QuickPar (.par and .par2 files).
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  6. #6
    Just Joined!
    Join Date
    Oct 2011
    Posts
    67
    Hi thanks for the great response. However I already have a script (sh) script that loads the notepad++.exe application. What i wanted to know was how to adjust the parameters in
    defaults.lst
    which is
    Code:
    text/plain=gedit.desktop
    am i just suppose to replace the gedit.desktop with that script ??? I am a bit confused with your response is that a shell script ??

  7. #7
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    The .desktop files are what lay behind the icons on most of the desktop which you see. I have a link to a Wine application call Enterprise architect. Here is an image of its Properties window. If you right-click on your desktop, you can select "Create Launcher", which will create one of these icons on the desktop which you can then use to start your editor. You can also alter the properties of your files ending in .txt (for example) so that double-clicking on the file name in the explorer will launch the notepad++ application.
    Attached Images Attached Images
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

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