pcmanfm - How to set the preferred order of "open with" ?

Hello all,

Currently I can rightclick a python source file and than select an application to open it with. Is there a way to change the order of this list ? I would like to put a text editor on top, followed by Thonny (for both python as well as python3 shebanged files).

Yes, I did my due duty by first trying to google it, but somehow I (again) can't find much of anything about it (most of the stuff is more than 5 years old).

Looking at my own stuff, I have python files (with the shebang line "#! /usr/bin/env python"), which shows "Geany", "Thonny", "Text editor" and "Libre Office writer" in that order. I would like to get rid of the "Libre office writer" entry entirely (and possibly "geany" too) , and have the "Text editor" and "Thonny" in that order as the first two.

I also have python3 files (with the shebang line "#! /usr/bin/env python3") which shows the same list, but with "mu" added to the top. Same problem. "Text editor" and 'Thonny" as the first two, and we can talk about the rest. :-)

One of my problems is that I've searched, starting from "/usr", for all "*.desktop" files containing "python", and have not found either "Text editor" nor "Libre office writer" among them. The same search using "python3" added "Geany" to be absent.

In short, I have no idea how "Text editor", "Geany" and "Libre office writer" become part of the "open with" list for the above two python version files.

hmmm.... A quick check of my .sh, .c and .h files show that "Libre office writer" thinks it has some right to those filetypes too - even though the "libreoffice-writer.desktop" file mentions none of them. :-(

tl;dr:

So, how do I (primary) sort the entries in the "open with" list ? (secondary) get rid of certain "open with" entries - especially when their .desktop configurations do not mention the files mimetype ?

Regards, Rudy Wieser

Reply to
R.Wieser
Loading thread data ...

To: R.Wieser > From Newsgroup: comp.sys.raspberry-pi

Here's a good place to start ...

formatting link

--- Synchronet 3.17c-Win32 NewsLink 1.110 Alleycat! BBS - telnet://alleycat.synchro.net

Reply to
Gregg Somes

Gregg,

I already know the relevant part (mimetypes) of those .desktop files, and am aware that I can remove mimetypes from the relevant entries to make them disappear from the "open with" list.

The problem is that some applications (Libre office writer, geany) appear in such "open with" list even though they do not show to support the mimetype of the file. I do not see any thing in that regard.

Also, the main problem, the word "sort" appears exactly once in that document (in the second paragraph), and gives no information how to influence the order of items in a "open with" list.

The word "mime" appears twice, once in a "its supposed to handle this too" line but with no further information, and once in a link - which (rather tersely) mentions how you create hem, but nothing about managing them.

Thanks for trying though.

Regards, Rudy Wieser

Reply to
R.Wieser

On Sun, 10 Nov 2019 14:34:25 +0100, "R.Wieser" declaimed the following:

Part of this may come back down to "file"...

pi@rpi3bplus-1:~$ file -k -r *.py test1.py: Python script text executable Python script, ASCII text executable

- test2.py: Python script text executable

- a /usr/bin/python3 script text executable Python script, ASCII text executable

- tst.py: ASCII text

- pi@rpi3bplus-1:~$

Note how all three have the tag "ASCII text"... That likely triggers any application that handles "text/plain".

As for Geany -- since you manage to have file return text/x-python3 for some files, you may have to add that to the geany.desktop to get it to show for those files.

I suspect you can't reorder the list -- it's either alphabetical (based upon some field in the .desktop file) or it's the order the .desktop files were scanned when building the menu.

--
	Wulfraed                 Dennis Lee Bieber         AF6VN 
	wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/
Reply to
Dennis Lee Bieber

Following up...

On Sun, 10 Nov 2019 14:34:25 +0100, "R.Wieser" declaimed the following:

pi@rpi3bplus-1:~$ grep -r -i "text/plain" /usr/share/mime/* |grep "python" /usr/share/mime/subclasses:text/x-python text/plain /usr/share/mime/text/x-python.xml: pi@rpi3bplus-1:~$

From which I deduce that any application that handles text/plain will be considered valid for text/x-python (I still have no idea why text/x-python3 is so irregular on this system -- it shows up in some files but not others).

You might want to study the contents of the directory /user/share/mime

AH -- there it may be... pi@rpi3bplus-1:~$ cat /usr/share/mime/text/x-python3.xml Python 3 script

Reply to
Dennis Lee Bieber

Dennis,

I'm sorry, but I don't get that. I've gotten the idea that the desktop and pcmanfm have their own way to determine a mimetype (as returned by "xdg-mime query filetype"), but suddenly now the output of "file -k -r" / "file -i" becomes relevant again ? What the blases is going on there ? How am I to make sense of that ?

No. It would mean that whomever wrote pcmanfm made a mess of things, and that I do not (yet) believe.

Definitily not alphabetical, as I've seen 'Text editor" below "Thonny", "LibreOffice writer" below "Text editor" and "Geany" below "mu".

... and sometimes ordered differently. Like a .c file having "Geany" and than "Text editor", but a .txt file having them in the reverse order.

In other words, /something/ is influencing the order of the "open with" entries - likely based on the files mimetype (but thats a guess).

As I could not find much of anything, I decided to remove the "mime-type=" line from the "/usr/share/applications/libreoffice-writer.desktop" file (and calling "update-mime-database" just in case) and rebooting, but the "libreoffice writer" entry was still there in the "open with" list. :-\ Any idea (what program I should use to get the changes I made accepted by pcmanfm - if that is what it takes that is) ?

I've also spend quite a bit more time googeling, but have not found anything further. Other than someone, years ago, saying that info on what I want/try to do should be easily findable. Yeah, right :-|

I'm a bit put-off to be honest: Even the simpelest of things in relation to the desktop and filebrowser (creating a desktop shortcut with icon, adding a filetype, changing an "open with" list) are schrouded in things-you-just-have-to-know, as related information is only sparsely and fragmented available - if at all. :-(

Not funny, not funny /at all/.

Regards, Rudy Wieser

Reply to
R.Wieser

Dennis,

Sounds reasonable. So, I removed all lines mentioning "python" (3 or 4), updated the database and rebooted (for good measure). Alas, no change in the contents or order of the "open with" list of either a python or python3 list. Absolutily nothing ...

No. Currently I'm getting a bit tired of this guessing game, and instead want to find/have information. Sorry.

The contents of those files (in the "text" folder) get generated by updating the mime database. Hence the actual info must be somewhere else. Where ? Your guess is as good as mine I'm afraid.

And those weights ? Those /could/ have something to do with the ordering in the "open with" list. But again, thats just guessing (already tried googeling for it). And thats apart of how they get determined, 'cos its certainly not in the xml mimetype definition file.

Lets hope that I will look differently at it tomorrow ...

Regards, Rudy Wieser

Reply to
R.Wieser

A very Windows way of doing things. Open a shell, type name of command then its arguments. Problem solved.

Reply to
mm0fmf

mm0fmf,

"Solving" a problem by ignoring it. Yeah, right. :-)

Also, starting a /program/ was, and is not the problem.

I'm trying to learn something new here, and you're not helping.

Regards, Rudy Wieser

Reply to
R.Wieser

You were expecting kid gloves or something?

This is usenet, not Romper Room :-/

--
Mike Easter
Reply to
Mike Easter

Re: pcmanfm - How to set the preferred order of "open with" ? By: R.Wieser to All on Sun Nov 10 2019 14:34:25

Reply to
Mike Powell

Mike,

Pardon me ? Whats that suposed to mean ?

But if you want a comparision, its like having bought a car but not getting a "users manual" with it - nor does such information seem to be available anywhere*. Now how am I supposed to figure out where to change the oil, or worse, what kind of oil needs to go in there ?

*and yes, I've already spend a couple of days looking for it.

Exactly. I don't think I'm the first or only one who bumped into it, and hoped that I would reach someone would already have gone thru it and thus could give me a pointer or two.

But, seeing that you have your disdain at ready but have not even hinted anything in the direction of a solution, should I take it you have no clue yourself either ? Yeah, that would be true Usenet form nowerdays. :-(

Regards, Rudy Wieser

Reply to
R.Wieser

No, its not like having BOUGHT a car, its like having been *given* one.

Well the info is and isn't available, depending on how hard you look.

Once I phoned a major company and was passed to...the guy who wrote the software! In fact TWICE.

Of course with Linux you can look at the source code.

The problem is that in order to give linux the pretty face and 'user friendliness' of Windows, the modern GUI contains a lot of 'this is the one way we are going to let you do it - just like windows - and you like it or lump it'.

I doubt that anyone has a clue. It took me over a day to find out in Mint Mate how NOT to have automatically created 'default user directories' . I would delete the bastards and there they were again. Eventually web searching gave me a hint that there was some 'DONT TOUCH THIS' config file buried somewhere listing these and if you TOUCHED it and deleted the entry, they didn't get remade on boot.

Probably the guy who wrote that bit of code has forgetotten how he did it anyway. So truly no one knows. I have forgotten ALL the code I wrote in my working life apart from a few salient exceptions that were interesting.

--
Gun Control: The law that ensures that only criminals have guns.
Reply to
The Natural Philosopher

On Sun, 10 Nov 2019 21:18:46 +0100, "R.Wieser" declaimed the following:

Unfortunately, that is going to require a LOT of Google (and man page) searches, trying various keywords.

For example, finding out how update-mime-database works led me to

formatting link

This was in the midst of playing with the sequence of operations shown next, when I encountered a file that said DO NOT EDIT and that was generated by the update command.:

-=-=-=- Open With > Geany Thonny Python IDE Text Editor gVim Vim LibreOffice Writer

pi@rpi3bplus-1:~$ sudo vim /usr/share/applications/mousepad.desktop Change GenericName=Text Editor To GenericName=MousePad {Also changed the [en_AU] and [en_GB] lines}

No immediate change on menu

pi@rpi3bplus-1:~$ sudo vim /usr/share/applications/gvim.desktop Added gVim to genericname (no effect) Added ;Development to Categories

gVim now shows up on Programming menu (beside on Accesories)

{here's where the update-mime-database search led me} pi@rpi3bplus-1:~$ sudo vim /usr/share/mime/packages/freedesktop.org.xml Commented out for the text/x-python section; but left text/x-python3 as sub-class of text/x-python pi@rpi3bplus-1:~$ sudo update-mime-database /usr/share/mime

Open With > Geany Thonny Python IDE

Removing the text/plain subclass removed all the generic text editors

pi@rpi3bplus-1:~$ sudo vim /usr/share/applications/gvim.desktop Added text/x-python; to end of MimeTypes list

No change to right click menu; REBOOT Still no change on menu; getting specific entries back is the next step

Open with > Open with... Selected gVim and [X]Set selected ... default

Do same.

Open With > gVim Geany Thonny Python IDE

Redid (on both .py file) Open with.../selected Thonny and [X]Set selected ...

Open With > Thonny Python IDE gVim Geany

Reboot to see if setting stays

It did (at least once)...

-=-=-=-

So... It looks like I was able to "resort" the Open With > menu. It required using the Open with... sub-menu, [X] the Set selected flag, and select the one you want last (it will become the top). Repeat with each candidate so the previous selections get pushed down.

You have to do this for each different MIME type the files are identified as (eg; python vs python3).

NOTE: I'm still running the default file manager for Raspbian, which I believe is Thunar. Don't know if the one you are running will behave the same way.

--
	Wulfraed                 Dennis Lee Bieber         AF6VN 
	wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/
Reply to
Dennis Lee Bieber

I was making a critical remark in the context of your me-me-me-centric reaction to the 'alternate point of view' remark of mm0fmf.

So? You're feeling frustrated.

So far, your problem hasn't been nailed here. I suspect it won't be.

Correct; the part about I have no clue either.

In the context I placed my critical remark, I thought your 'reaction' to mm0fmf was 'suboptimal'.

--
Mike Easter
Reply to
Mike Easter

Dennis,

First off, my apologies for having put it that blunt. You've been nothing than helpfull to me. But after having done my best for a number of days and gotten nowhere I was near to just dropping (almost literally) the whole (Raspberry Pi) thing.

I've been scouring the web for any-and-all info I could find for days now - only to find stuff thats 5 years or more old (likely not applicable anymore/to rapbian) from others wanting to know the same. No answers.

I found similar, but saw that those and yours alike stop where the jucy bit is supposed to start:: There is /no/ information about how the information in there causes stuff to happen. In short, I can change stuff in that file, but have zero idea what it actually results in.

And by the way, that last line there is right, but rather incomplete. Remember those files in the /usr/share/mine/text folder you found stuff in ? Those also get rewritten. As do a few others. Making changes in them might look like a good idea, but on call to the database updater program and they are gone. :-\

:-) I was not even looking at that (just the "open with" list you see directly after rightclicking), but thats a nice find. It shows how the grouping works.

:-) You found it too. It was only after I took a peek in it that I realized that that one is where the file-to-mimetype translation is taking place. And yes, I've already been playing in it too. As a result I've given both the python and python3 sourcefiles the same "Thonny", "Geany" order.

I already had the idea, if all else would fail, to change the name of the "text/x-python" mimetype name to something else, and see how far I could go (hey, a single change there ? That /should/ be easy to follow, right ? :-)

....

I assumed that that would happen, but wanted tho keep the "Text editor" choice in the list. And, if I get my way, as the first entry (with, for Python, "Thonny" as the second).

Thats a good one! I did not assume that the "open with" list would contain the preferred-open-by entry.

:-) I think you've solved my problem there. Thanks.

And even without needing to dig deep into Linux innards and edit configuration files !

Though I wil probably visit those innards anyway, just to see if-and-how I can get those changes by editing config files - just to see if I can.

The same here.

I think that the name of my file manager is "pcmanfm". At least, I've been using "sudo pcmanfm" for a while now to easily access and be able to edit the files in the /user/share/mime (and other) subtrees.

There is only one way to know ... Yep, it looks like it.

Furthermore, it survives an update-mime-database call (just thought to do a quick test).

... Though I tried to open a Scratch2 project (dont ask) with the "text editor", and now its a permanent entry in that list. :-|

Which means I will most likely have to do that digging anyway. :-)

Thanks for your help.

Regards, Rudy Wieser

Reply to
R.Wieser

On Tue, 12 Nov 2019 09:28:15 -0500, Dennis Lee Bieber declaimed the following:

Whatever it is, it is different from the behavior of Debian under xfce (my VirtualBox image). Under xfce the right-click menu shows the default opener, and the open-with submenu has a section of "recommended" applications, followed by a listing of all applications on the system.

In experimenting, I managed to locate (this is Debian)

-=-=- wulfraed@debian:~$ cat ~/.config/mimeapps.list [Added Associations] text/html=firefox-esr.desktop; text/plain=mousepad.desktop; text/x-python=python3.7.desktop;gvim.desktop;code.desktop; x-scheme-handler/http=exo-web-browser.desktopx-scheme-handler/https=exo-web-browser.desktopx-scheme-handler/mailto=exo-mail-reader.desktopapplication/xml=gvim.desktop;text/x-scheme=gvim.desktop;application/vnd.kde.kxmlguirc=gvim.desktop;

[Default Applications] text/x-python3=gvim.desktop text/x-python=gvim.desktop wulfraed@debian:~$

-=-=-

(and on Raspbian)

-=-=- pi@rpi3bplus-1:~/.config$ cat ~/.config/mimeapps.list [Default Applications] text/x-python3=Thonny.desktop text/x-python=Thonny.desktop text/plain=gvim.desktop

[Added Associations] text/x-python3=Thonny.desktop;gvim.desktop;userapp-python3.7-9AM0A0.desktop; text/x-python=Thonny.desktop;gvim.desktop; text/plain=gvim.desktop; pi@rpi3bplus-1:~/.config$

-=-=-

Which leads (Google) to

formatting link

Hand editing the mimeapps.list files might be faster than piecemeal "set default" applications. Also, the "set default" action is per user (the above sample files), but you could edit a global file.

NOTE: Debian/Raspbian appears to use /usr/share/applications/mimeinfo.cache

... and editing pi@rpi3bplus-1:~$ sudo vim /usr/share/applications/mimeinfo.cache

did NOT adjust the menu order... only the ~/.config/mimeapps.list seemed to affect the ordering.

--
	Wulfraed                 Dennis Lee Bieber         AF6VN 
	wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/
Reply to
Dennis Lee Bieber

Mike,

Lolz, *my* me-me-me centric response ? I suggest you re-read mm0fmf's one.

Not a single thought about why I would want to do what I asked. A downright snidy "just use what /I/ alway use, you Windows GUI users are dumb anyway" remark - while not having the faintest idea about my (Windows) background with either GUIs or consoles.

So, who's "me, me, me" attitude where you talking about again ?

But, if you want you can condemn me for wanting to solve a problem - and not directly dropping it on the suggestion of a wiseass.

Yeah, quite. And than a fool like you comes along and throws oil on those flames. Does that make you proud of yourself ?

Why ? How is it that a thing like that isn't encountered by scores of people using the Raspberry ? Or should I assume that either noone actually uses the (GUI part of the) OS, or just does like mm0fmf suggests: run away from problems ?

And by the way: about half an hour before your current post dennis lee bieber already did. And in a shamefull easy way too. You where saying ?

What ? Did you think that me being nice to him and beg for another solution would have helped ? I don't.

Lolz. Not ever having used the OS than I must assume - seeing how easy it is both to encounter, and to get it to work.

And by the way, I hope you weren't "expecting kid gloves or something". :-)

Regards, Rudy Wieser

Reply to
R.Wieser

Correct.

--
Mike Easter
Reply to
Mike Easter

Dennis,

I do have a mimeapps.list, though its located in /usr/share/raspi-ui-overrides-applications. But checking its "last modified" date it shows way before the NOOBs package was installed on my Pi (which is two weeks ago). Same for the "mimeinfo.cache" file next to it. In other words, they seem to be default/unaltered.

Also, no "[Added Associations]" in the first.

I've found a few of the above (looked like a good keyphrase), but only in the /usr/lib subfolders.

It looks like that idea (finding either de list of current defaults or the changes one) died fast ...

And odd: I did a grep -r "text/x-python3" on the /usr/share folder, but although I've set my .py files to open with "Text editor", all I can find is the mimetype coupled to "Thonny.desktop" and "applications-thonny.desktop" ...

Regards, Rudy Wieser

Reply to
R.Wieser

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.