Advertising

Welcome to SparkyLinux forums
Zapraszamy również na polsko-języczne Forum https://forum.linuxiarze.pl

Openbox file associations

Started by niftyprose, June 05, 2018, 07:07:02 PM

Previous topic - Next topic

niftyprose

Hi guys, I have a feeling that this has been asked before, but I couldn't figure out how to phrase a generic question. Apologies if I cause frustration.

I'm on Sparky/Openbox. I use Geany for text editing (esp. coding) and TKOutline for brainstorming and scheduling.

Geany stores .txt files. TKO stores text files with its own markup language in .tko format.

If I right-click on a .tko or .txt file and choose an application to open it, I get the familiar 'Use as default for this kind of file' option. But this results either in .txt files being opened in TKO or .tko files being opened in Geany, (depending on which application I last selected).

Is there a way to handle file associations based on suffix, so that .txt files are always opened by Geany and .tko files by TKOutlline?

Best, NP.

pavroo

Try:
Right click on a file-> Properties-> Open with-> choose an application.
Nothing is easy as it looks. Danielle Steel
Join #sparkylinux.org at [url="//irc.libera.chat"]irc.libera.chat[/url]

niftyprose

Thankx, Pavroo, but you misunderstand me I think.

Can I set things up so that:
{Doubleclicking on a .txt file launches Geany} && {Doubleclicking on a .tko file launches TKOutline}
...despite the fact that .tko files are just .txt files with some unusual markup in the text?

I guess I could parse that as: can I make file associations based on file suffix rather than filetype?

TIA, NP.

pavroo

#3
Hhmm...
It was what I was trying to say...
Right click at a .txt file and set (via the Properties) Geany to the default app to be opened all .txt files, then right click at a .tko file and set the TKOutline as default.
Is it what you need now?
Nothing is easy as it looks. Danielle Steel
Join #sparkylinux.org at [url="//irc.libera.chat"]irc.libera.chat[/url]

niftyprose

Ah, OK, you *did* understand me, Pavroo.


I'd have expected the solution you (patiently) explained to work. But what happens is that, if I make the file association between .tko  and TKOutline, .txt files will then also open TKO. Conversely, if I associate Geany with .txt files, Geany is launched when I double-click a .tko file.


Presumably this is unusual behaviour in Sparky? I wonder if it's to do with TKOutline's relationship with TCL?


Best, W.

pavroo

i suggest to check the file:
$HOME/.config/mimeapps.list
and set/remove/join your file types with your favorite apps.
then re-login to take effects.
Nothing is easy as it looks. Danielle Steel
Join #sparkylinux.org at [url="//irc.libera.chat"]irc.libera.chat[/url]

niftyprose

Hi Pavroo, thank you for setting me on the right course. I've been messing with /.config/mimeapps.list and /etc/mime.types. No luck yet, but the root of my problem is clearly that I need to identify .tko files to the system as a distinct form of text file needing special handling. I've enquired elsewhere about the necessary mimetype setup forTKOutline/ TCL and will report back. Best, NP

niftyprose

Hi, Pavroo and everyone,

I finally sorted this out. Although it's pretty obscure, I guess someone out there in the wider Debian community might want to define their own mime type, too. I had thought the problems described in my first post on this topic were specific to text files originating in TCL. Now I think that my problem was an instance of a more general issue about mime registration.

After Pavroo's useful intervention, I mailed the developer of TKOutline for advice. He had never needed to associate a new filetype to work with his software, but he gave me a pointer:

___SNIP___

1. Associate mime type to file extension
2. Associate the mime type with an application .desktop file to execute
3. Write the application .desktop file and place it in a proper location
...
For #1, I think this line needs added to /etc/mime.types or $HOME/mime.types

application/x-tkoutline  tko

For #2 something like this in the ~/.config/mimeapps.list:

application/x-tkoutline=tkoutline.desktop;

For #3, something like this should work (replace with your actual path
to tkoutline-devel-linux
(https://help.ubuntu.com/community/UnityLaunchersAndDesktopFiles for
some related details):

[Desktop Entry]
Type=Application
Name=Tkoutline
Comment=Edit hierarchical outlines
Terminal=false
MimeType=application/x-tkoutline;
Exec=/home/btheado/Downloads/tkoutline-devel-linux %U

From what I read, that .desktop file should either be in
$HOME/.local/share/applications or /usr/share/applications.

____ENDSNIP___

This *is* what you're supposed to do, but when I tried it it didn't work. I then checked in the Ubuntu documentation and found a note from someone else for whom it hadn't worked (https://help.ubuntu.com/community/AddingMimeTypes and scroll to 'Another way'.) Their recipe, which involves manually editing an XML file contained in /usr/share/mime/application didn't work for me either, but at least it got me looking in the right part of the file system.

What finally did work was this: https://stackoverflow.com/questions/30931/register-file-extensions-mime-types-in-linux

As per the instruction:

i. I installed xdg-utils
ii. created the following XML file:
<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
   <mime-type type="application/x-tkoutline">
   <comment>Outliner</comment>
   <glob pattern="*.tko"/>
  </mime-type>
</mime-info>
iii. gave it the name x-tko.xml
iv. issued the command xdg-mime install x-tko.xml

I can now launch TKOutline by double-clicking a .tko file. Phew!

Best, NP

View the most recent posts on the forum