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

mpv cannot handle $HOME variable in mpv.conf file #15598

Open
torontal7 opened this issue Dec 30, 2024 · 2 comments
Open

mpv cannot handle $HOME variable in mpv.conf file #15598

torontal7 opened this issue Dec 30, 2024 · 2 comments
Labels

Comments

@torontal7
Copy link

torontal7 commented Dec 30, 2024

Reproduction Steps

Define a path in your mpv.conf file like this:

external-file=~/.config/mpv/mpv.webp

Expected Behavior

Excepted behaviour would be that mpv will use the image...

Actual Behavior

mpv says that the file does not exist:

Can not open external file ~/.config/mpv/mpv.webp.

But if you give the path in the form external-file=/home/USERNAME/.config/mpv/mpv.webp, mpv will find the image file.

@mrfragger
Copy link

in lua scripts try this
local homedir = os.getenv("HOME")

in mpv.conf you could try ~~
also this works on Mac so should on Linux I'd think
screenshot-directory=~/datampv/screenshots

@torontal7
Copy link
Author

torontal7 commented Jan 1, 2025

In lua, yes:

$ cat ~/.config/mpv/scripts/mpv.lua 
local homedir = os.getenv("HOME")
local msg = require('mp.msg')

function something_handler()
    msg.info(homedir)
end
mp.add_key_binding("x", "something", something_handler)

When pressed x, in terminal I can see: [mpv] /home/knoppix

It is OK for 'screenshot-directory' option, too:

$ mpv --no-config \
--script=~/.config/mpv/scripts/mpv.lua \
--image-display-duration=inf \
~/.config/mpv/szekelykapu-lego-720p.webp \
--screenshot-directory=~/mpv1
 (+) Video --vid=1 (webp 1280x720 1.000fps)
error: XDG_RUNTIME_DIR not set in the environment.
VO: [gpu] 1280x720 yuv420p
V: 00:00:00 / 00:00:00 (0%) Cache: 0.0s
Screenshot: '/home/knoppix/mpv1/mpv-shot0001.jpg'

But not for 'external-file' option:

$ mpv --no-config \
--script=/home/knoppix/.config/mpv/scripts/mpv.lua \
--image-display-duration=inf \
Downloads/bbq-restaurant.webp \
--external-file=~/.config/mpv/szekelykapu-lego-720p.webp
[file] Cannot open file '~/.config/mpv/szekelykapu-lego-720p.webp': No such file or directory
Failed to open ~/.config/mpv/szekelykapu-lego-720p.webp.
Can not open external file ~/.config/mpv/szekelykapu-lego-720p.webp.

mpv manual: "Some mpv options interpret paths starting with ~" So, it seems that this is how mpv works: not all options can handle it. In my opinion this is not too logic...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants