Comments (6)
Interesting. I will need to look into this
from joshuto.
I added the following to memo.lua
script:
function get_full_path()
local path = mp.get_property("path")
if path == nil then return end
-- additions
print("file_path")
print(path)
print("working-directory")
print(mp.get_property("working-directory", ""))
print("$PWD")
print(os.getenv("PWD"))
print("pwd command output:")
local t = os.execute("pwd")
When I tested it with a video file via mpv
, I got the following output:
[memo] file_path
[memo] abc_video.mp4
[memo] working-directory
[memo] /home/kamiyaa/builds/joshuto
[memo] $PWD
[memo] /home/kamiyaa/builds/joshuto
[memo] pwd command output:
/home/kamiyaa/videos
AO: [alsa] 48000Hz stereo 2ch float
VO: [gpu] 1920x1080 yuv420p
So joshuto
is correctly setting the current directory within the process (as pwd
command output shows)
However, mpv
's mp.get_property("working-directory", "")
is still returning the incorrect path.
Looking into mpv
's code on how it determines its current directory, its becomes clear that they read a PWD
environment variable which joshuto
does not set. [3]
I'm not sure if its unix tradition to set the PWD
variable, but I imagine setting this variable before running mpv
should resolve it.
Weird that this is the way mpv
determines its current directory.
Another solution is to unset the PWD
variable and force mpv to use the getcwd()
function. [3]
EDIT:
it looks like ranger
and potentially other file managers set the PWD env var properly
[memo] file_path
[memo] /home/kamiyaa/videos/abc_video.mp4
[memo] working-directory
[memo] /home/kamiyaa/videos
[memo] $PWD
[memo] /home/kamiyaa/videos
[memo] pwd command output:
/home/kamiyaa/videos
References
[1] https://github.com/mpv-player/mpv/blob/1608059d64532e0461e3bec09b20a71802dcb2aa/player/command.c#L3939
[2] https://github.com/mpv-player/mpv/blob/3bdf702b1de8b0d0e0fb700b234b0fc69e04a630/player/command.c#L3192
[3] https://github.com/mpv-player/mpv/blob/master/options/path.c#L327
from joshuto.
@xfzv Let me know if fd188e9 fixes it
from joshuto.
Closing!
from joshuto.
Also breaks oltodosel/mpv-scripts/total_playtime.lua.
The total playtime of current playlist cannot be calculated (returns 00:00:00 (inf%)
) unless joshuto
was started from the video directory.
from joshuto.
Yes, it does.
from joshuto.
Related Issues (20)
- Latest release doesn't build HOT 1
- v0.9.7 - `Cargo.toml` does not match `Cargo.lock` HOT 2
- feature request: change, simplify joshuto image preview HOT 2
- [BUG] Fatal crash when I return to joshuto from a shell HOT 4
- Use of `--change-directory` command line argument? HOT 1
- Configure ratatui-image preview background/frame color.
- [BUG] Linemode 'sizemtime' unknown. HOT 1
- [FEATURE] More linemodes and sort modes
- linux gnu build error
- Directory chooser HOT 2
- [Help wanted] Creating a custom script to use joshuto to control imv. HOT 1
- Feature request: delete colon to exit command mode
- Feature request: implement scrollable preview area HOT 2
- [Bug] File preview(with bat) does not update after file modification with vim
- Feature request: Add options to pre-select a file on start HOT 2
- Unable to select neovim config with NVIM_APPNAME environment variable
- Feature Request: add more useful variables for shell/spawn commands HOT 1
- Feature request: keybinding `v` by default to mark all files / folders in current view
- Feature request: add `bat` as fallback for viewing HTML / JSON in `preview_file.sh`
- symlink not work on macos
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from joshuto.