Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browsing the directory #5

Closed
smarek opened this issue Sep 17, 2019 · 10 comments
Closed

Browsing the directory #5

smarek opened this issue Sep 17, 2019 · 10 comments

Comments

@smarek
Copy link

smarek commented Sep 17, 2019

When launching mvi through xdg-open (see #4 ), and the same when launching mvi through cli, it will only play the file(s) we opened.

Usually image browsers do support switching between images (in alphabetical order) in the same directory right away.

I've very naive solution to this, which uses last file from provided arguments and adds whole directory to allow browsing (sincerely from the first file in alphabetical order away)

It would be cool, if the mvi, when launched with single file argument, added whole directory as playlist and switched to file in argument in created playlist appropriately.
I think this would not work well when launched with multiple arguments (disregard if those are files or folders)

My solution:

#!/bin/bash

LASTARG="${@: -1}"
REAL=$(realpath "$LASTARG")
DIR=$(dirname "$REAL")
if [[ -f $REAL ]];
then
  ADD=$DIR
else
  ADD=""
fi

# will pass original arguments and then folder determined from last argument, if determined
mpv --config-dir=$HOME/.config/mvi/ "$@" "$ADD"
@occivink
Copy link
Owner

I recommend using the autoload.lua script from mpv for this. (also thanks for the .desktop file issue, I'll address it at some point)

@smarek
Copy link
Author

smarek commented Sep 17, 2019

Thank you, that seems like the best way, I've added the file in ~/.config/mvi/scripts/ directory and it autoloaded, sadly it does not work.
Check on line 105 ( https://github.com/mpv-player/mpv/blob/master/TOOLS/lua/autoload.lua#L105 ) will return immediately, and will not add surrounding files to current playlist.
You might know why?

(cheers, #4 was fun, it as well might not be integrated, i'm just happy it works in my case)

@occivink
Copy link
Owner

It looks like the script only runs when the file you're playing matches any of these extensions, try changing that?
https://github.com/mpv-player/mpv/blob/master/TOOLS/lua/autoload.lua#L25-L28

@smarek
Copy link
Author

smarek commented Sep 18, 2019

Thank you, works correctly after adding appropriate extensions, could you probably include modified script in your repo?

@occivink
Copy link
Owner

I don't really like the idea of duplicating the script, but I think the mpv people would accept a pull request that makes these changes, if you feel like submitting one.

@smarek
Copy link
Author

smarek commented Sep 24, 2019

We could try, however since MPV is video player, i don't think they'll accept it. Maybe patch file and script would suit you better?

@occivink
Copy link
Owner

I'd only accept a patch if they explicitly refused to add these formats. I think it's just as in scope as audio formats.

@smarek
Copy link
Author

smarek commented Oct 2, 2019

Well mpv-player/mpv#6990 got merged, so I guess we could provide instructions on how to use / configure that autoload now?

@occivink
Copy link
Owner

occivink commented Oct 3, 2019

It's actually already mentioned in the "Others" section in the README (even though I had never tested that it works for us). Is there something you would add? The script is very much paste and forget

@smarek
Copy link
Author

smarek commented Oct 3, 2019 via email

@occivink occivink closed this as completed Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants