Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 489524 - xdg-open behaviour about %i contradicts desktop entry standard
Summary: xdg-open behaviour about %i contradicts desktop entry standard
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Freedesktop bugs
URL: https://bugs.freedesktop.org/show_bug...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-27 00:39 UTC by Olivier Diotte
Modified: 2014-11-27 11:59 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Diotte 2013-10-27 00:39:09 UTC
As described upstream: https://bugs.kde.org/show_bug.cgi?id=326711#c0

Reproducible: Always

Steps to Reproduce:
1. Run "xdg-open /path/to/file.pdf"
Actual Results:  
-An okular window appears displaying file.pdf
-An empty okular window with title '%c' appears
-A popup window saying "could not open /home/myuser/%i" appears

Expected Results:  
Only the file.pdf okular window appears
Comment 1 Johannes Huber (RETIRED) gentoo-dev 2013-10-27 15:25:32 UTC
Upstream says this is fixed in newer xdg-utils?!

@freedesktop is this already fixed in tree?
Comment 2 Olivier Diotte 2013-10-27 17:17:49 UTC
I just upgraded to x11-misc/xdg-utils-1.1.0_rc1_p20130921 and, after removing the '-icon ' part I had added to the .desktop files (and running "xdg-mime default okular.desktop application/pdf" since my PDFs opened in Gimp), I get the same behaviour.

Does anyone else get the same behaviour? Maybe it is just my setup (I'm using just a window manager instead of a full DE) though I don't think this is likely to give the behaviour I get.
Comment 3 Johannes Huber (RETIRED) gentoo-dev 2013-11-24 12:31:06 UTC
Its an xdg bug.
Comment 4 Michael Palimaka (kensington) gentoo-dev 2014-02-26 09:36:22 UTC
Did anyone report this to freedesktop upstream?
Comment 5 Olivier Diotte 2014-02-26 15:31:29 UTC
(In reply to Michael Palimaka (kensington) from comment #4)
> Did anyone report this to freedesktop upstream?

I forgot to.

I just tested with 1.1.0-rc2 and it still doesn't work.

Here is the freedesktop bug report: https://bugs.freedesktop.org/show_bug.cgi?id=75530
Comment 6 Samuli Suominen (RETIRED) gentoo-dev 2014-02-26 16:17:31 UTC
Do you have okular set to open PDF files in ~/.local/share/applications/mimeapps.list (or defaults.list, which is an older name for the same file)?

Does KDE install it's own global mimeapps.list (or defaults.list) somewhere that's grabbed when the desktop starts?
As in, does Gentoo as a KDE vendor set Okular to be the default PDF reader by shipping a mimeapps.list file for the users like they could?

If there is no mimeapps.list or defaults.list, then last application that can handle the pdf mimetype will be used:

From my system:

$ grep Mime.*pdf *.desktop
mupdf.desktop:MimeType=application/pdf;application/x-pdf;application/x-cbz;application/oxps;application/vnd.ms-xpsdocument;image/jpeg;image/pjpeg;image/png;image/tiff;image/x-tiff;
zathura-pdf-poppler.desktop:MimeType=application/pdf;
zzz-gimp.desktop:MimeType=image/bmp;image/g3fax;image/gif;image/x-fits;image/x-pcx;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/x-psd;image/x-sgi;image/x-tga;image/x-xbitmap;image/x-xwindowdump;image/x-xcf;image/x-compressed-xcf;image/x-gimp-gbr;image/x-gimp-pat;image/x-gimp-gih;image/tiff;image/jpeg;image/x-psp;image/png;image/x-icon;image/svg+xml;application/pdf;image/x-xcursor;

So 3 possible programs that can handle PDF.  If I don't select one, myself, last one installed will by used since my desktop, Xfce, doesn't ship anykind of mimeapps.list (or the old name, defaults.list) for the users.

Tried with xdg-utils-1.1.0_rc2 and xdg-mime. Everything seems to be in order:

$ xdg-mime default zathura-pdf-poppler.desktop application/x-pdf
$ grep pdf ~/.local/share/applications/mimeapps.list
[Default Applications] 
application/x-pdf=zathura-pdf-poppler.desktop

Now 'xdg-open foo.pdf' opens zathura as a PDF reader.

I don't see how this is an XDG bug...?!
Comment 7 Olivier Diotte 2014-02-26 16:51:05 UTC
(In reply to Samuli Suominen from comment #6)
> Do you have okular set to open PDF files in
> ~/.local/share/applications/mimeapps.list (or defaults.list, which is an
> older name for the same file)?
> 
I do not see how to configure this (there doesn't seem to be such an option in Okular's 'Settings' menu).

Also, ~/.local/share/applications doesn't exist. Please note I am not using a Desktop Environment (DE), just wmii that I start manually with 'startx' (although AFAIK I installed the kde-runtime thing that Gentoo requires me to install to be in a 'supported setup').

P.S.: After some tests, xdg-mime didn't like the applications folder not existing, so I created it (I still get the bug though).

> Does KDE install it's own global mimeapps.list (or defaults.list) somewhere
> that's grabbed when the desktop starts?
> As in, does Gentoo as a KDE vendor set Okular to be the default PDF reader
> by shipping a mimeapps.list file for the users like they could?
> 
> If there is no mimeapps.list or defaults.list, then last application that
> can handle the pdf mimetype will be used:
 
> I don't see how this is an XDG bug...?!

I don't use KDE, I set the application to use with 'xdg-mime default okular.desktop application/pdf' (although, on this computer it was okay at the moment so I didn't touch it):

$ xdg-mime query default application/pdf
kde4-okularApplication_pdf.desktop

I still get the error pop-ups with okular when writing 'xdg-open /path/to/file.pdf', isn't this a bug?
Comment 8 Samuli Suominen (RETIRED) gentoo-dev 2014-02-26 17:28:47 UTC
(In reply to Olivier Diotte from comment #7)
> I don't use KDE, I set the application to use with 'xdg-mime default
> okular.desktop application/pdf' (although, on this computer it was okay at
> the moment so I didn't touch it):
> 
> $ xdg-mime query default application/pdf
> kde4-okularApplication_pdf.desktop
> 
> I still get the error pop-ups with okular when writing 'xdg-open
> /path/to/file.pdf', isn't this a bug?

Did the line get inserted to ~/.local/share/applications/mimeapps.list after the xdg-mime command?

You sure the okular.desktop has MimeType= line for application/pdf?

Are you sure it's application/pdf instead of application/x-pdf? For example, mupdf's .desktop file has reference to both, 'pdf' and 'x-pdf'

What does okular use in it's .desktop file that has the MimeType= reference to pdf for an Exec=? %f? %U?

$ grep Exec zathura-pdf-poppler.desktop mupdf.desktop zzz-gimp.desktop 
zathura-pdf-poppler.desktop:Exec=zathura %f
mupdf.desktop:Exec=mupdf-select-file %f
mupdf.desktop:TryExec=mupdf-select-file
mupdf.desktop:Exec=mupdf %f
zzz-gimp.desktop:Exec=gimp-2.8 %U
zzz-gimp.desktop:TryExec=gimp-2.8

When you referenced in Comment #0 '/path/to/file', what does that exactly mean, what is the path and does it has some spacing?

Just trying to get an overall picture of what the problem is.
Comment 9 Samuli Suominen (RETIRED) gentoo-dev 2014-02-26 17:32:34 UTC
Also, do you have USE="perl" enabled for x11-misc/xdg-utils? If not, you should enable it, since if using 'generic' desktop (as in, xdg-utils detects your DE as generic) then dev-perl/File-MimeInfo is necessary.
And, if you do have dev-perl/File-MimeInfo installed, have you upgraded dev-lang/perl recently? Did you remember to run `perl-cleaner --all` to refresh the perl module for the currently installed perl version?
Comment 10 Olivier Diotte 2014-02-26 23:21:13 UTC
(In reply to Samuli Suominen from comment #8)
> Did the line get inserted to ~/.local/share/applications/mimeapps.list after
> the xdg-mime command?
>
Yes:
$ cat .local/share/applications/mimeapps.list 

[Default Applications]
application/pdf=kde4-okularApplication_pdf.desktop

 
> You sure the okular.desktop has MimeType= line for application/pdf?
>
They should be the default files as I haven't modified them (I removed the modification to the Exec= line and IIRC I may even have re-emerged the package that owns those files afterwards anyway).

$ find /usr/share/applications/ -iname '*okular*' -exec grep -nHi 'MimeType' {} \;
/usr/share/applications/kde4/okularApplication_plucker.desktop:2:MimeType=application/prs.plucker;
/usr/share/applications/kde4/okularApplication_kimgio.desktop:2:MimeType=image/bmp;image/x-dds;image/x-eps;image/x-exr;image/gif;image/x-hdr;image/x-ico;image/jp2;image/jpeg;video/x-mng;image/x-portable-bitmap;image/x-pcx;image/x-portable-graymap;image/png;image/x-portable-pixmap;image/x-psd;image/x-rgb;image/x-tga;image/tiff;image/x-xbitmap;image/x-xcf;image/x-xpixmap;image/x-gzeps;image/x-bzeps;
/usr/share/applications/kde4/okularApplication_fax.desktop:2:MimeType=image/fax-g3;image/g3fax;
/usr/share/applications/kde4/okularApplication_xps.desktop:2:MimeType=application/oxps;application/vnd.ms-xpsdocument;
/usr/share/applications/kde4/okularApplication_dvi.desktop:2:MimeType=application/x-dvi;application/x-gzdvi;application/x-bzdvi;
/usr/share/applications/kde4/okular.desktop:132:MimeType=application/vnd.kde.okular-archive;
/usr/share/applications/kde4/okularApplication_fb.desktop:2:MimeType=application/x-fictionbook+xml;
/usr/share/applications/kde4/okularApplication_tiff.desktop:2:MimeType=image/tiff;
/usr/share/applications/kde4/okularApplication_txt.desktop:2:MimeType=text/plain;
/usr/share/applications/kde4/okularApplication_ooo.desktop:2:MimeType=application/vnd.oasis.opendocument.text;
/usr/share/applications/kde4/okularApplication_pdf.desktop:2:MimeType=application/pdf;application/x-gzpdf;application/x-bzpdf;application/x-wwf;
/usr/share/applications/kde4/okularApplication_ghostview.desktop:2:MimeType=application/postscript;image/x-eps;application/x-gzpostscript;application/x-bzpostscript;image/x-gzeps;image/x-bzeps;
/usr/share/applications/kde4/okularApplication_comicbook.desktop:2:MimeType=application/x-cbz;application/x-cbr;application/x-cbt;

It seems the right application (kde4-okularApplication_pdf.desktop) has the entry, but not okular.desktop. On my two laptops (similar setups), one uses okular.desktop, the other (this one) has kde4-okularApplication_pdf.desktop (I set it to the default when testing). Both exhibit the bug.
 
> Are you sure it's application/pdf instead of application/x-pdf? For example,
> mupdf's .desktop file has reference to both, 'pdf' and 'x-pdf'
> 
On one laptop, xdg-mime query application/x-pdf returned nothing (?), on the other, it returned qpdfview as the viewer. xdg-open /path/to/file.pdf always opens okular on both laptops.


> What does okular use in it's .desktop file that has the MimeType= reference
> to pdf for an Exec=? %f? %U?
> 
$ find /usr/share/applications/ -iname '*okular*' -exec egrep -l 'MimeType.*pdf.*' {} \; | xargs grep -H 'Exec'
/usr/share/applications/kde4/okularApplication_pdf.desktop:Exec=okular %U %i -caption %c


> When you referenced in Comment #0 '/path/to/file', what does that exactly
> mean, what is the path and does it has some spacing?
> 
I usually use xdg-open with a relative path, most often the same dir. Here is an example, ran from ~:
$ xdg-open DQ965CO_TechProdSpec.pdf 
START /usr/bin/okular "DQ965CO_TechProdSpec.pdf" %i -caption %c
okular(13775)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
okular(13775)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
okular(13775)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
okular(13775)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
okular(13775)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
okular(13775)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
okular(13775)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
okular(13775)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
okular(13775)/kio (KDirWatch) KDirWatchPrivate::removeEntry: doesn't know "/home/dioo/%i" 



(In reply to Samuli Suominen from comment #9)
> Also, do you have USE="perl" enabled for x11-misc/xdg-utils?
>
I do (which must mean it's a mandatory USE flag, as I'm not a big Perl user) (I use the generic 'desktop' Gentoo profile, so that might be why).

> should enable it, since if using 'generic' desktop (as in, xdg-utils detects
> your DE as generic) then dev-perl/File-MimeInfo is necessary.
$ equery list '*Mime*'
 * Searching for *Mime* ...
[IP-] [  ] dev-perl/File-MimeInfo-0.170.0:0

> And, if you do have dev-perl/File-MimeInfo installed, have you upgraded
> dev-lang/perl recently? Did you remember to run `perl-cleaner --all` to
> refresh the perl module for the currently installed perl version?
I try to run it everytime emerge tells me to (although I happen to miss it sometimes). That being said, I did run perl-cleaner --reallyall since I reported this bug. I'll rerun it now and report back if it changes anything.
Comment 11 Johannes Huber (RETIRED) gentoo-dev 2014-08-06 18:00:32 UTC
(In reply to Olivier Diotte from comment #10)
[snip]
>That being said, I did run perl-cleaner --reallyall since I
> reported this bug. I'll rerun it now and report back if it changes anything.

Any news?
Comment 12 Olivier Diotte 2014-10-13 05:27:50 UTC
(In reply to Johannes Huber from comment #11)
> (In reply to Olivier Diotte from comment #10)
> [snip]
> >That being said, I did run perl-cleaner --reallyall since I
> > reported this bug. I'll rerun it now and report back if it changes anything.
> 
> Any news?

Actually yes! I still had the problem so I investigated and I seem to have found the problem. I have submitted a patch, see my comment upstream: https://bugs.freedesktop.org/show_bug.cgi?id=75530#c4
Comment 13 Olivier Diotte 2014-10-19 02:34:46 UTC
As I found the bug and reported it upstream, this is not a bug with KDE.