You are not logged in.

#201 2019-11-15 08:36:19

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,425

Re: mimeo: open files by mimetype or file name

You have to rebuild mimeo against python 3.8 explicitly, or wait for xyne to rebuild if you got it from their repo. The latest release is 2019.07 so doesn't look deprecated to me

Last edited by V1del (2019-11-15 08:37:20)

Offline

#202 2019-11-18 22:57:52

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: mimeo: open files by mimetype or file name

Follow the discussion about rebuilding for Python 3.8 here. If it's not done by tomorrow night, nag me about it there smile


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#203 2021-02-11 00:13:28

tleydxdy
Member
Registered: 2017-10-11
Posts: 21

Re: mimeo: open files by mimetype or file name

I realized xdg-open can "run" desktop files directly, and it seem like mimeo don't. This is what I got from running a desktop file generated by my web browser

WARNING: failed to determine command precursor for /home/tleydxdy/Desktop/some.desktop
WARNING: failed to determine command(s) for /home/tleydxdy/Desktop/some.desktop

is there some way to fix this?

Last edited by tleydxdy (2021-02-11 00:14:06)

Offline

#204 2021-02-11 12:30:28

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: mimeo: open files by mimetype or file name

I've added an "--exec" option to run the "Exec" field of desktop file arguments, e.g. "mimeo --exec vlc.desktop" will open vlc. If you want to make this the default behavior, create a custom desktop file and make it the default for the desktop MIME-type:

mimeo --create exec_desktop.desktop 'Desktop Runner' 'mimeo --exec %F' 'application/x-desktop' noterm
mimeo --prefer 'application/x-desktop' exec_desktop.desktop

edit: @all
While adding the above option I also addressed the numerous pylint errors and warnings. Almost all of the changes are transparent for users of the command-line utility but several keyword arguments have been renamed internally to conform to naming conventions. Anyone who uses the module directly will need to update their code.

The only command-line change is the fifth argument to the "--create" command, which should now be "term" for terminal applications and anything else for non-terminal applications.

The executable is also a proper python script too now instead of a bash wrapper.

Last edited by Xyne (2021-02-11 12:36:07)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#205 2021-02-12 01:45:45

tleydxdy
Member
Registered: 2017-10-11
Posts: 21

Re: mimeo: open files by mimetype or file name

much thanks!

Offline

#206 2021-02-12 02:53:19

tleydxdy
Member
Registered: 2017-10-11
Posts: 21

Re: mimeo: open files by mimetype or file name

the change is not quite working. firstly, /usr/bin/mimeo produces a error, changing the shebang line for /usr/bin/mimeo to the usual fixed it

#!/usr/bin/env python3

secondly, when I do

mimeo --exec the.desktop

it just exits and nothing happens, when I run the Exec= line in the file manually it launches correctly. This I have no clue, I tried to add some echo lines to the command it invokes but there still is no output

Offline

#207 2021-02-12 04:19:52

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: mimeo: open files by mimetype or file name

package ()
{
  cd "$srcdir/$pkgname-$pkgver"
  python setup.py install --prefix=/usr --root="$pkgdir" --optimize=1
  install -Dm755 "$pkgname" "$pkgdir/usr/bin/$pkgname"
}

Installing the script file is redundant since "python setup.py install" handles that; furthermore, it overwrites the version of the script that setup.py installed. This is problematic since "#!python" relies on setup.py adjusting the shebang for you, to point at the python interpreter which invoked setup.py.

The manual install -Dm755 line appears to be a legacy leftover from before "The executable is also a proper python script too now instead of a bash wrapper." An oversight...


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#208 2021-02-12 07:13:32

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: mimeo: open files by mimetype or file name

eschwartz wrote:

An oversight...

Yep, sorry. The fix will be uploaded in a few minutes.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#209 2021-02-12 08:24:00

tleydxdy
Member
Registered: 2017-10-11
Posts: 21

Re: mimeo: open files by mimetype or file name

okay, so this is really strange, the desktop file will launch successfully with one filename, but if I rename it it won't launch again

Offline

#210 2021-02-12 10:13:14

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: mimeo: open files by mimetype or file name

"I changed something and now it no longer works" isn't enough information for me to help you.

Did you change the .desktop extension? If so, why? Does "mimeo -m /path/to/renamed/file" still detect the MIME-type as "application/x-desktop"? If not, either fix the extension or add the new MIME-type to the generated desktop file above.

Mimeo uses Python's standard mimetypes module for MIME-type detection so there isn't much that I can do to improve that. MIME-type detection is basically guesswork and a lot of it relies on things like standard file extensions.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#211 2021-02-12 12:01:15

tleydxdy
Member
Registered: 2017-10-11
Posts: 21

Re: mimeo: open files by mimetype or file name

yes I renamed it but preserved .desktop, mimeo detects both as application/x-desktop.

Offline

#212 2021-02-13 13:15:03

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: mimeo: open files by mimetype or file name

Post the output of

mimeo -m /path/to/desktop/file
mimeo -c /path/to/desktop/file
mimeo --exec -c /path/to/desktop/file

for both the original and renamed desktop file.

edit
If both report the same MIME-type then the behavior should be the same. Are you running the commands as different users (e.g. with sudo)? If so then you will need to set the preferences for the other user too.

Last edited by Xyne (2021-02-13 13:17:50)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#213 2021-02-14 06:30:51

tleydxdy
Member
Registered: 2017-10-11
Posts: 21

Re: mimeo: open files by mimetype or file name

$ mimeo -m ~/Desktop/brave-ppkpacoaenkjhabjboajcamojdgbjdgd-Profile.desktop
/home/tleydxdy/Desktop/brave-ppkpacoaenkjhabjboajcamojdgbjdgd-Profile.desktop
  application/x-desktop
$ mimeo -m ~/Desktop/element.desktop
/home/tleydxdy/Desktop/element.desktop
  application/x-desktop
$ mimeo -c ~/Desktop/brave-ppkpacoaenkjhabjboajcamojdgbjdgd-Profile.desktop
/usr/bin/mimeo --exec /home/tleydxdy/Desktop/brave-ppkpacoaenkjhabjboajcamojdgbjdgd-Profile.desktop
$ mimeo -c ~/Desktop/element.desktop
/usr/bin/mimeo --exec /home/tleydxdy/Desktop/element.desktop
$ mimeo --exec -c ~/Desktop/brave-ppkpacoaenkjhabjboajcamojdgbjdgd-Profile.desktop
/usr/lib/brave-bin/brave --user-data-dir=/home/tleydxdy/.config/BraveSoftware/Brave-Browser/Main --profile-directory=Profile --app-id=ppkpacoaenkjhabjboajcamojdgbjdgd
$ mimeo --exec -c ~/Desktop/element.desktop
$ diff ~/Desktop/brave-ppkpacoaenkjhabjboajcamojdgbjdgd-Profile.desktop ~/Desktop/element.desktop
$

Offline

#214 2021-02-14 20:28:23

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: mimeo: open files by mimetype or file name

Can you post the contents of the desktop files? It seems that element.desktop contains the path to brave-ppkpacoaenkjhabjboajcamojdgbjdgd-Profile.desktop so I suspect that one is not a copy of the other.
Also post the output of the following files if you have them:

  • /home/tmp/xyne/.config/mimeo/associations.txt

  • /etc/xdg/mimeo/associations.txt


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#215 2021-02-15 06:33:38

tleydxdy
Member
Registered: 2017-10-11
Posts: 21

Re: mimeo: open files by mimetype or file name

The two file are the same, which is what I was trying to show with the diff command

I think I have figured out what is causing it, but I am still unsure of the why. So when I installed the PWA, the browser added copies of the desktop files to

~/.local/share/applications/
~/.gnome/apps/
~/Desktop/

One would think they are independent, but somehow they are not. specifically the ~/Desktop version will only run when the corresponding ~/.local version is present. This is what caused element.desktop to not work, once I copied element.desktop to ~/.local they both will work correctly.

note:
~/.Desktop version have this line at the top and is set to executable, the ~/.local one does not and is not executable (this doesn't effect the bug tho (I have xdg-open symlinked to mimeo))

#!/usr/bin/env xdg-open

Offline

#216 2021-02-15 16:21:03

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: mimeo: open files by mimetype or file name

The diff command in the output immediately followed the "mimeo --exec -c" command so I thought it was the output, which I found very confusing.

I've just tested mimeo with executable desktop files and the shebang #!/usr/bin/env mimeo and it works as expected after creating the custom desktop and preference as in my previous post. Aside from the use of the custom desktop file to handle the application/x-desktop MIME-type, it should be completely independent of the target desktop's location. There must be something in the desktop files under ~/Desktop beyond the shebang that differs from their counterparts in $XDG_DATA_HOME.

Without the contents of the desktop files I cannot reproduce or debug this.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#217 2021-02-20 01:42:46

tleydxdy
Member
Registered: 2017-10-11
Posts: 21

Re: mimeo: open files by mimetype or file name

Here's my current working setup

$ diff ~/Desktop/element.desktop ~/.local/share/applications/element.desktop
1d0
< #!/usr/bin/env xdg-open
$ cat ~/Desktop/element.desktop
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Terminal=false
Type=Application
Name=Element
Exec=/usr/lib/brave-bin/brave --user-data-dir=/home/tleydxdy/.config/BraveSoftware/Brave-Browser/Main --profile-directory=Profile --app-id=ppkpacoaenkjhabjboajcamojdgbjdgd
Icon=brave-ppkpacoaenkjhabjboajcamojdgbjdgd-Profile
StartupWMClass=crx_ppkpacoaenkjhabjboajcamojdgbjdgd

I think it's best if you use your browser to install a PWA, this will obviously not run on your machine.

Offline

#218 2022-09-30 21:47:49

maplepy
Member
Registered: 2022-09-30
Posts: 4

Re: mimeo: open files by mimetype or file name

Hello,

I'm sorry to post after all of this time but I couldn't find a way to do what I want even when reading this forum. So basically I have multiple firefox profiles with unique extensions for each profiles, I have one for private browsing, one for media like twitch/youtube/reddit for instance etc.

What I'd like to do is to open every link in the private profile by default (set to default in firefox so that's ok) and open any media link say "^https?://twitch.tv" links in the media profile but i'm not sure how to do that. I have firefox set to default right now (the private profile) and want to use firefox with the profile called "social" for twitch links so I tried this in "~/.config/mimeo/associations.txt"

/usr/bin/firefox -p social %U
  ^https?://(www.)?twitch.tv/

but that won't open firefox

mimeo -c https://www.twitch.tv/lirik
/usr/bin/firefox -p social https://www.twitch.tv/lirik

The output seems right but the action isn't. It's like it doesn't care about the arguments

Last edited by maplepy (2022-10-07 20:26:47)

Offline

#219 2022-10-07 20:20:32

maplepy
Member
Registered: 2022-09-30
Posts: 4

Re: mimeo: open files by mimetype or file name

I actually need help, thought I had it but it doesn't work so I edited my comment back hmm

If anyone knows how I can use mimeo to do what I want that'd be awesome!

Edit:

this works fine for instance:

/usr/bin/firefox -p social https://www.twitch.tv/lirik

Last edited by maplepy (2022-10-07 20:21:45)

Offline

#220 2022-10-10 20:12:33

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: mimeo: open files by mimetype or file name

            if pargs.command:
                print_cmd(cmd)
            else:
                run_cmd(cmd, quiet=pargs.quiet)

The command that you see with the '-c" flag is the same command that is run without it. Are you running Mimeo as the user with that Firefox profile?

What does the log show if you run the command with "--debug"? Try it with and without the "-c" flag.

Last edited by Xyne (2022-10-10 20:14:20)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#221 2022-10-10 20:19:30

maplepy
Member
Registered: 2022-09-30
Posts: 4

Re: mimeo: open files by mimetype or file name

mimeo https://www.twitch.tv/lirik --debug                                                    
DEBUG: loading arguments from /home/maplepy/.config/mimeo/default_arguments.txt
DEBUG: checking /home/maplepy/.config/mimeo/associations.txt
DEBUG: loading /home/maplepy/.config/mimeo/associations.txt
DEBUG: /usr/bin/firefox -P social --class social https://www.twitch.tv/lirik

Both outputs are the exact same with and without the "-c" flag. Weirdest thing is, when I type mimeo and a twitch link for instance it works now but not when i click on it

Offline

#222 2022-10-10 20:31:25

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: mimeo: open files by mimetype or file name

maplepy wrote:

Both outputs are the exact same with and without the "-c" flag. Weirdest thing is, when I type mimeo and a twitch link for instance it works now but not when i click on it

Where are you clicking the link? In your web browser? Console?
Wherever it is, you need to configure the program to invoke mimeo with the link. Mimeo cannot intercept clicks on its own.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#223 2022-10-10 20:40:55

maplepy
Member
Registered: 2022-09-30
Posts: 4

Re: mimeo: open files by mimetype or file name

Tried in the console or in apps and they always open in the default firefox not the "mimeo one", I know clicking it inside a web browser itself wont work

How do I do that? Do I need xdg-utils-mimeo or is it something else?

Offline

#224 2022-12-03 10:23:12

hully
Member
Registered: 2022-11-14
Posts: 149

Re: mimeo: open files by mimetype or file name

Is it possible to use wildcards when changing mimetypes associations?

Like:

mimeo --prefer "image/*" imv

to change the image viewer all the once for all image file types

EDIT: ok I have edited `~/.config/mimeapps.list ` directly and it seems to be working smile

Last edited by hully (2022-12-03 10:25:46)

Offline

#225 2022-12-10 00:29:46

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: mimeo: open files by mimetype or file name

hully wrote:

Is it possible to use wildcards when changing mimetypes associations?

Like:

mimeo --prefer "image/*" imv

to change the image viewer all the once for all image file types

You can use

mimeo --prefer 'glob:image/*' ...

for glob matching. It's also possible to use regular expressions with the "regex:" prefix. See

mimeo --help
mimeo --mimeman-help

for details.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

Board footer

Powered by FluxBB