linuxmint / nemo

File browser for Cinnamon
GNU General Public License v2.0
1.19k stars 298 forks source link

opening .desktop Type=Link with "Open with..." context menu (right cick)->(text editor) opens the link url not the '.desktop' file #2854

Open dubiouscript opened 2 years ago

dubiouscript commented 2 years ago
 * Nemo version (nemo --version)
 * afaik windowed nemo

 * 64 bit

Issue

right clicking on test.desktop open's the URL from the test.desktop

eg

  13404 pts/6    S+     0:00  |   |   \_ sudo strace nemo ~/Desktop
  13408 pts/6    S+     0:00  |   |   |   \_ strace nemo ~/Desktop
  13411 pts/6    Sl+    0:01  |   |   |       \_ nemo ~/Desktop
  13434 pts/6    Sl+    0:00  |   |   |           \_ xed http://www.askubuntu.com/

Steps to reproduce creating a file -> test.desktop

[Desktop Entry]
Encoding=UTF-8
Name=Link to Ask Ubuntu
Type=Link
URL=http://www.askubuntu.com/
Icon=text-html

right click open with text editor

opens a file with the title / on askubuntu.com and content

<!DOCTYPE html>

    <html class="html__responsive ">

    <head>

        <title>Ask Ubuntu</title>
        <link rel="shortcut icon" href="https://cdn.sstatic.net/Sites/askubuntu/

which i imadgin is not the expected behavior

Expected behaviour launch $EDITOR ~/Desktop/text.desktop xed test.desktop

Other information

xdg-open ./test.desktop works as expected eg opens xed ./test.desktop

Jeremy7701 commented 2 years ago

Desktop files supply information to a GUI to run the a specified program. There are thousands of them, but they tend to be well hidden. So your desktop file appears to be working properly (although it's possibly missing a couple of lines).

Since they are text files, right-click gives an option to use a text editor.

dubiouscript commented 2 years ago

@Jeremy7701 hi it appear there is some confusion ???

how about you try yourself to follow

'Steps to reproduce'

https://github.com/linuxmint/nemo/issues/2854#issue-1040307797 Steps to reproduce creating a file -> test.desktop

[Desktop Entry]
Encoding=UTF-8
Name=Link to Ask Ubuntu
Type=Link
URL=http://www.askubuntu.com/
Icon=text-html

right click open with text editor

https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#introduction

Desktop files supply information to a GUI to run the a specified program.

im happy you appear to know what a desktop file is

There are thousands of them, but they tend to be well hidden.

i dont see how this is relevent to this issue tbh ?

what im missing wrt your reply is how

0) the purpose/function of desktop files 1) the number of desktop files

leads you to conclude

So your desktop file appears to be working properly (although it's possibly missing a couple of lines).

thanks for taking the time to share your thaughts

i dont agree

desktop file appears to be working properly

questions


how can a plain text file 'work properly' ? something other than the text file is what is doing the work hear (dont you think???) ...probably some component of nemo is doing the working hear ..

so perhaps we can agree if nemo is doing the work of opening this (plain text) desktop file then nemo is NOT opening the file as expected when using right click -> open with editor


what component of nemo is processing right click -> open with editor ?

what component of nemo is doing the work of opening desktop files ?

is it posible to change eather of the above so right click open with editor actualy works as expected?

:upside_down_face:

Jeremy7701 commented 2 years ago

I followed your instructions. I got a file with mimetype test.desktop which outputs "test.desktop: application/x-desktop" - so this isn't a plain text file, once its got valid desktop data in it. It also shows as a link (presumably due to 'Type=Link') - with the URL keyword specifying the file to open. As to which component handles desktop files, I would guess that it isn't part of nemo, since the "system" appears to generate XML file(s) for each desktop file to tie mimetypes with application. [I don't understand the desktop/mimetype/XML tie-up properly though].

dubiouscript commented 2 years ago

ftr curently

$cat /etc/issue
Linux Mint 20.2 Uma

[I don't understand the desktop/mimetype/XML tie-up properly though].

same curently in this context ...

allthough i have previously (now seamingly distant past) looked into this in various distros ...

and (ftr) found some intresting approaches http://web.archive.org/web/20211104204325/http://forum.tinycorelinux.net/index.php/topic,23614.0.html - minimalistic approach to MIME types / filetype associations

that thread hints at xdg-utils as the canonical sloution

all though : https://github.com/linuxmint/nemo/search?p=1&q=%22open+with%22 persumably this has some part to play
https://github.com/linuxmint/nemo/blob/8b9cdfcbbd53d383823a43c8b5c5ec2320077057/src/nemo-mime-actions.c#L1151

& https://github.com/linuxmint/nemo/blob/7fe83632eca5801a55992dc08c52767b6d8685cb/src/nemo-properties-window.c#L4730

  • or desktop files. We don't get the open-with menu for these anyway.
  • Also don't show it for folders. Changing the default app for folders
  • leads to all sort of hard to understand errors.

https://github.com/linuxmint/nemo/blob/8b9cdfcbbd53d383823a43c8b5c5ec2320077057/src/nemo-mime-actions.c#L1526 ... https://github.com/linuxmint/nemo/blob/8b9cdfcbbd53d383823a43c8b5c5ec2320077057/src/nemo-mime-actions.c#L1583 https://github.com/linuxmint/nemo/blob/8b9cdfcbbd53d383823a43c8b5c5ec2320077057/src/nemo-mime-actions.c#L1585 (i guess) it appears this switch statement handles the case for each "action"

:thinking:

will have a go at geting more debug out put , and see it is posible to identfy which (if any??) case it's geting handled as =S

any hints ??!!


---edit--- https://github.com/linuxmint/nemo/blob/287075b2dc0d114cabb67543ed2f92d3a07efddf/files/usr/share/nemo/actions/sample.nemo_action#L6

$ nemo --quit $ NEMO_DEBUG=Actions nemo --debug via : https://github.com/linuxmint/nemo/issues/2824#issuecomment-908455930

...

Nemo actions don't have the ability to look at uri schemes (file, sftp..) which I only now realize might be something useful to add https://github.com/linuxmint/nemo/issues/2824#issuecomment-908552245

:raised_eyebrow:

dubiouscript commented 2 years ago

perhaps related

https://github.com/linuxmint/nemo/issues/2498 - .desktop link opens unexpected application

dubiouscript commented 2 years ago

how ever ( in 2021 :roll_eyes: ) this appears curently not posible :thinking:

hi @mtwebster any clue what should be expected when using "Open with..." context menu to open a desktop file with texteditor ?

my view is the expected result from this action should be xed ./test.desktop or similar

navid-zamani commented 8 months ago

META INFORMATION

This is still a problem in 2023/2024, but the problem is deeper.

The core problem here, is that .desktop files are a Windowsism (.lnk) files, that got copied (I think by KDE).
And as a Windowsism, it inherently treats the user as an idiot (if necessary, until he damn well IS), has things appear as something else than they are (for “simplification”, aka being condescending), and does “automagic” things. None of this is welcome, and people who use Linux, use it exactly to get away from being treated that way.
But now we are stuck with it, because too many luddite “techies” came over to Linux and think “Look at me. I’m the expert now. … And this is how Linux should be. Just Windows/macOS again.“. (E.g. Valve, Poettering, etc.)

The thing is. Mint, by extension of Ubuntu, IS by its very definition, an OS for such people. (Apple users, to be precise, because Gnome. But … details …)
So while, yes, the behavior of .desktop files is a mess and right up crazy alley… they are plain text files, but they are meant to be treated specially by desktop environments, making even more special treatment/code necessary when you don’t want that, and just want to edit them normally… (Compare: HTML files.)

While all that is true… it still must be said, that if you’re not that type of user, then Mint (or any SystemD/Linux or Android/Linux etc) is simply the wrong distribution for you, and you should use GNU/Linux or a Unix like BSD instead, where you’re the boss, full stop.
That way everyone gets what he wants, and is happy.
Complaining that your submarine doesn’t fly, instead of just getting on a plane, gets one nowhere. :)


WORKAROUND

1) For what it’s worth, you can of course still open those files from the CLI (even with Kate, but also with vim). 2) Alternatively, Nemo offers user actions and user scripts inside .local/share/nemo/. Here’s a helpful script to let you interactively add actions to Nemo:

#! /bin/bash
# REQUIRES ZENITY
xdg-open /usr/share/nemo/actions/sample.nemo_action &
name="$( zenity --entry --title="Add action" --width=800 --ok-label="Continue »" --text="Title:" )" && \
auswahl="$( zenity --entry --title="Add action" --width=800 --ok-label="Continue »" --text="Selection ([s]ingle,[m]multi,any,notnone,none,<number>):" --entry-text="notnone" )" && \
endungen="$( zenity --entry --title="Add action" --width=800 --ok-label="Continue »" --text="Type (dir,none,nodirs,any,<file extension>):"  --entry-text="any;" )" && \
befehl="$( zenity --text-info --title="Add action" --width=800 --height=200 --ok-label="Create" --editable )" && \
na="/tmp/$name.nemo_action" && \
echo "[Nemo Action]" > "$na" && \
echo "Name=$name" >> "$na" && \
echo "Exec=$befehl" >> "$na" && \
echo "Selection=$auswahl" >> "$na" && \
echo "Extensions=$endungen" >> "$na" && \
echo "Quote=double" >> "$na" && \
mv "$na" "$HOME/.local/share/nemo/actions/" || rm -f "$na"

Put it in .local/share/nemo/scripts/, make it executable, and then restart Nemo. It should appear in the context menu, inside the Scripts sub-menu.
The sample action is opened as documentation.

dubiouscript commented 8 months ago

@navid-zamani

The core problem here, is that .desktop files are a Windowsism

:scream: you know ms train there ai on all this text :wink:

https://www.adminspotting.org/

That way everyone gets what he wants, and is happy.

tbh idgaf who whats what or is happy pretty shore that shit is way OT for git hub issues ( tho i do wander if the unspecified behaviors like this might bring some joy to those with darker hats) :roll_eyes:

just trying to understand why abc is doing xyz and tbh that's still a daydream

Complaining that your submarine doesn’t fly, instead of just getting on a plane, gets one nowhere. :)

as they say

“Vision without action is a daydream,” “Action without vision is a nightmare.”

:raised_eyebrow:

navid-zamani commented 8 months ago

tbh idgaf who whats what or is happy

Here’s the thing: People can tell, and it will have consequences in what you can get from them. And teamwork always wins out over lizard-braining. Even psychopaths understand that. In fact, according to research, even crows, monkeys, squirrels, and possibly even pigs and molluscs understand this. The only ones with higher intelligence who don’t (want to) understand this are a certain special kind of human psychopaths and people raised in their culture. Usually from a … certain country. ;)

And yes, it’s off-topic. I just wanted to be helpful. And the big picture … the meta … is often left away, even though it makes everything much easier. My account is supposed to be deleted anyway. Apparently GitHub thinks it can ignore such GDPR requests. (Good luck trying to do business in the EU!) But one useful way that worked in the past, is to get oneself banned. So GitHub admins, here’s your opportunity to help me achieve that. ^^

dubiouscript commented 7 months ago

The thing is. Mint, by extension of Ubuntu, IS by its very definition, an OS for such people. (Apple users, to be precise, because Gnome. But … details …)

human psychopaths and people raised in their culture. Usually from a … certain country.

how you classify a) people b) software

is irelevent to this issue

somthing :ghost: bring you to this issues to comment on who is who and what is what (as you see it)

PLEASE find some place else for that obvious bullshit ( perhaps politics or psycology? economics (both involove verry un-scientific catogoisaton manipulation and scapegoating) )

it seams verry odd you bring such things to this forum non of which will fix this issue perhaps NOT fixing the issue is your actual goal ?idk tbh

navid-zamani commented 7 months ago

@dubiouscript: You know what’s funny? Claiming something is wrong, while doing exactly that too. Especially when the “other side” isn’t even. I chose to post it because it was useful. You needed to post yours because it rustled your jimmies. How about editing yours, so it contributes something too, instead of just uncontrolled venting for us all to hear?
And: Strong emotional reaction to something they claim is meaningless, as if they are that criticized thing; Attacks on the person, for lack of arguments against the actual argument; Claiming the own reality is absolute and everyone else’s is “bullshit”… You know yourself, where we’ve all seen that behavioral pattern before. And it always ends in tears. Either in a suicide bombing, or a floor full of broken iPhone shards.

Also, I suggest not trying to explain what is scientific and what not, to a literal expert who does this almost for a job, for decades. :)
Instead, ask yourself … why you keep imagining my existence. :D
Kidding. … In reality, I am not your enemy. Everything I wrote was to improve your life too. It is not me who is interpreting it differently. And given how you reacted, it is probably not you either.

Regarding fixing the problem (not “IsSuE”): The bug fix is to instead install GNU/Linux, BSD, or a self-written OS, for example. And if not the case, ideally become a person/individual beforehand. E.g. by questiong one’s firmest assumptions.
Of course staying with Microsoft Systrmd/Lindows is a choice too, and that is everyone’s good right. But then one loses the right to complain too, because it is what one chose. Can’t have it both ways.
So the bug is only properly fixed on a meta level, and not inside this tiny box.
I already said all that
, but apparently one has to hit it in with a sledgehammer before it gets through. I cannot do more than that.

So have a nice day. I will now unsubscribe from this bug, and for the sake of your happiness, I tecommend you do too. :)

dubiouscript commented 5 months ago

https://github.com/aircrack-ng/rtl8188eus/issues/281 :rofl: