Advertising

Author Topic: Openbox file associations  (Read 531 times)

Offline niftyprose

  • Newbie
  • *
  • Posts: 18
Openbox file associations
« on: June 05, 2018, 07:07:02 pm »
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.

Offline pavroo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1892
    • SparkyLinux
Re: Openbox file associations
« Reply #1 on: June 05, 2018, 08:39:25 pm »
Try:
Right click on a file-> Properties-> Open with-> choose an application.
Nothing is easy as it looks.
Danielle Steel

Offline niftyprose

  • Newbie
  • *
  • Posts: 18
Re: Openbox file associations
« Reply #2 on: June 06, 2018, 10:57:08 am »
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.

Offline pavroo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1892
    • SparkyLinux
Re: Openbox file associations
« Reply #3 on: June 06, 2018, 04:43:14 pm »
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?
« Last Edit: June 06, 2018, 04:50:35 pm by pavroo »
Nothing is easy as it looks.
Danielle Steel

Offline niftyprose

  • Newbie
  • *
  • Posts: 18
Re: Openbox file associations
« Reply #4 on: June 06, 2018, 05:58:50 pm »
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.

Offline pavroo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1892
    • SparkyLinux
Re: Openbox file associations
« Reply #5 on: June 06, 2018, 06:15:30 pm »
i suggest to check the file:
Code: [Select]
$HOME/.config/mimeapps.listand set/remove/join your file types with your favorite apps.
then re-login to take effects.
Nothing is easy as it looks.
Danielle Steel

Offline niftyprose

  • Newbie
  • *
  • Posts: 18
Re: Openbox file associations
« Reply #6 on: June 07, 2018, 10:46:39 am »
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

Offline niftyprose

  • Newbie
  • *
  • Posts: 18
Re: Openbox file associations
« Reply #7 on: June 11, 2018, 08:31:14 pm »
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