You are not logged in.

#1 2022-02-21 20:30:51

Sun Serega
Member
Registered: 2022-02-21
Posts: 1

"xdg-mime query default" sais wine is default app when it isn't

I'm using arch+budgie.
Everything is up to date, including all AUR packages.

---

I'm trying to make a utility app for myself, which needs to find all files in a given dir, which are opened with a specific app by default.

I found this post: https://askubuntu.com/a/159900
Fixed it a bit and added "echo"'s to see what's wrong:

#!/bin/bash

# if file is empty - it is seen as just text, so this doesn't work:
#EXTENSION=$1
#SAMPLENAME=$HOME/~webdavhelpersample.$EXTENSION
#touch $SAMPLENAME
#CURMINE=$(xdg-mime query filetype $SAMPLENAME)
#rm $SAMPLENAME

FILENAME=$1
CURMINE=$(xdg-mime query filetype "$FILENAME")
echo "$CURMINE"

CURDSK=$(xdg-mime query default $CURMINE)
echo "$CURDSK"

if [ -f ~/.local/share/applications/$CURDSK ]; then
    TRUEDSK=~/.local/share/applications/$CURDSK
elif [ -f /usr/local/share/applications/$CURDSK ]; then
    TRUEDSK=/usr/local/share/applications/$CURDSK
elif [ -f  /usr/share/applications/$CURDSK ]; then
    TRUEDSK=/usr/share/applications/$CURDSK
else 
    echo "Sorry no executable found for $1"
    exit 1
fi
echo "$TRUEDSK"

#WHATTODO=$(grep "^Exec" $TRUEDSK | head -1)
#echo $WHATTODO
cat "$TRUEDSK"

Now, if I pass regular ".txt" file, which both "xdg-open" and my default filesystem GUI (GNOME's Nautilus) opens in "notepadqq", I get this output:

text/plain
wine-extension-txt.desktop
/home/sun_linux/.local/share/applications/wine-extension-txt.desktop
[Desktop Entry]
Type=Application
Name=notepad
MimeType=text/plain;
Exec=env WINEPREFIX="/home/sun_linux/.wine" wine start /ProgIDOpen txtfile %f
NoDisplay=true
StartupNotify=true
Icon=2E40_notepad.0

So "xdg-mime query filetype" works as expected, but "xdg-mime query default", for some reason, sees "wine"'s .desktop file as default?

The command after "Exec=" works and opens the default windows notepad...

Here is another example output, for the ".png" file:

image/png
wine-extension-png.desktop
/home/sun_linux/.local/share/applications/wine-extension-png.desktop
[Desktop Entry]
Type=Application
Name=Wine Internet Explorer
MimeType=image/png;
Exec=env WINEPREFIX="/home/sun_linux/.wine" wine start /ProgIDOpen pngfile %f
NoDisplay=true
StartupNotify=true
Icon=ECB7_iexplore.0

This time command after "Exec=" launches some beast called "Wine Internet Explorer", which proceeds to not work.

I also found "/home/sun_linux/.config/mimeapps.list" file, which at least doesn't lie for these two file types - here are two relevant lines:

text/plain=notepadqq.desktop;jetbrains-rider.desktop;visual-studio-code.desktop;
image/png=org.gnome.eog.desktop;

Unfortunately, this file doesn't have anything relevant for file types I'm interested in.
And I'd like to find a generic solution because I would probably need it for another utility soon.

Offline

#2 2022-02-22 11:35:59

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 15,256

Re: "xdg-mime query default" sais wine is default app when it isn't

Don't think xdg-mime is lying, wine does install user desktop files that override other settings (which can be very annoying ) .

Check https://wiki.archlinux.org/title/XDG_MI … eapps.list for an overview where mime settings are stored and which have priority .


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

Board footer

Powered by FluxBB