Skip to content

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

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

Closed
torontal7 opened this issue Dec 30, 2024 · 2 comments · Fixed by #15730
Closed

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

torontal7 opened this issue Dec 30, 2024 · 2 comments · Fixed by #15730
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...

Dudemanguy added a commit to Dudemanguy/mpv that referenced this issue Jan 25, 2025
There's several path-related options that do not handle common shortcuts
(like ~). Fix this by using mp_get_user_path where appropriate which
expands the path so users get more intuitive behavior. Fixes mpv-player#15598.
Dudemanguy added a commit to Dudemanguy/mpv that referenced this issue Jan 25, 2025
There's several path-related options that do not handle common shortcuts
(like ~). Fix this by using mp_get_user_path where appropriate which
expands the path so users get more intuitive behavior. Fixes mpv-player#15598.
Dudemanguy added a commit to Dudemanguy/mpv that referenced this issue Jan 25, 2025
There's several path-related options that do not handle common shortcuts
(like ~). Fix this by using mp_get_user_path where appropriate which
expands the path so users get more intuitive behavior. Fixes mpv-player#15598.
Dudemanguy added a commit to Dudemanguy/mpv that referenced this issue Jan 26, 2025
There's several path-related options that do not handle common shortcuts
(like ~). Fix this by using mp_get_user_path where appropriate which
expands the path so users get more intuitive behavior. Fixes mpv-player#15598.
Dudemanguy added a commit to Dudemanguy/mpv that referenced this issue Jan 27, 2025
There's several path-related options that do not handle common shortcuts
(like ~). Fix this by using mp_get_user_path where appropriate which
expands the path so users get more intuitive behavior. Fixes mpv-player#15598.
Dudemanguy added a commit to Dudemanguy/mpv that referenced this issue Jan 27, 2025
There's several path-related options that do not handle common shortcuts
(like ~). Fix this by using mp_get_user_path where appropriate which
expands the path so users get more intuitive behavior. Fixes mpv-player#15598.
Dudemanguy added a commit to Dudemanguy/mpv that referenced this issue Jan 27, 2025
There's several path-related options that do not handle common shortcuts
(like ~). Fix this by using mp_get_user_path where appropriate which
expands the path so users get more intuitive behavior. Fixes mpv-player#15598.
Dudemanguy added a commit to Dudemanguy/mpv that referenced this issue Jan 28, 2025
There's several path-related options that do not handle common shortcuts
(like ~/). Fix this by using mp_get_user_path where appropriate which
expands the path so users get more intuitive behavior. Fixes mpv-player#15598.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants