player/command: add env property#17577
Conversation
|
I don't think it's a good idea to allow environmental variables snooping. We already allow clipboard snooping and it isn't quite liked feature, see #17367. |
Yes, and this feature can be implemented by a simple lua script, it's not worth adding a property for it. add this script, and then you can access environment variable through ${user-data/env/...} in input.conf local utils = require('mp.utils')
local env = {}
for _, v in ipairs(utils.get_env_list()) do
local i = v:find('=', 1, true)
env[v:sub(1, i - 1)] = v:sub(i + 1)
end
mp.set_property_native('user-data/env', env) |
This isn't even remotely comparable.
|
|
You can easily read environment variable in scripts of course, but config files are more convenient for users. (The above script doesn't work for mpv.conf). Notably there are no This has been requested in #mpv a few times and the implementation is trivial so I think it's a fine addition. |
kasper93
left a comment
There was a problem hiding this comment.
I don't think unpredictable config behavior based on current runtime env is a good thing. But there seems to be strong need for this features, so it's fine.
JSON IPC clients previously cannot get the environment of mpv, now they can even when they belong to processes different from mpv and normally cannot access mpv's process local environment. |
{
"command": {
"name": "subprocess"
"playback_only": false,
"args": [
"sh",
"-c",
"env > /tmp/mpv.env # or send wherever"
],
}
}Not to mention, you can read other processes' env from |
these properties cannot be used directly and require a sub-property. document this explicitly.
mainly so that env vars can be accessed from within config files.
|
As a future exercise, someone can make Edit: Actually probably not. Turns out that |
Making the windows But what about the returned table? |
env vars are case insensitive on windows so getenv should compare them as such. Fixes: mpv-player#17577 (comment)
|
@verygoodlee please test #17691 and report back in there. |
env vars are case insensitive on windows so getenv should compare them as such. Fixes: #17577 (comment)
env vars are case insensitive on windows so getenv should compare them as such. Fixes: mpv-player#17577 (comment)

mainly so that env vars can be accessed from within input.conf.