mpv-bookmarker icon indicating copy to clipboard operation
mpv-bookmarker copied to clipboard

Support for portable mpv installation

Open maliayas opened this issue 3 years ago • 2 comments

Portable mpv installation uses portable_config folder in the root of mpv installation for storing personal data. This plugin might detect that and use that folder in order to store bookmarker.json. Thanks in advance.

maliayas avatar Mar 17 '21 19:03 maliayas

For future readers, this patch does the job:

diff --git a/bookmarker-menu.lua b/bookmarker-menu.lua
index 848d309..079ee05 100644
--- a/bookmarker-menu.lua
+++ b/bookmarker-menu.lua
@@ -31,6 +31,8 @@ local mode = "none"
 local bookmarkStore = {}
 local oldSlot = 0
 
+CONFIG_ROOT = utils.split_path(mp.find_config_file("."))
+
 -- // Controls \\ --
 
 -- List of custom controls and their function
@@ -262,11 +264,7 @@ end
 
 -- Get the filepath of a file from the mpv config folder
 function getFilepath(filename)
-  if isWindows() then
-  	return os.getenv("APPDATA"):gsub("\\", "/") .. "/mpv/" .. filename
-  else	
-	return os.getenv("HOME") .. "/.config/mpv/" .. filename
-  end
+  return CONFIG_ROOT .. filename
 end
 
 -- Load a table from a JSON file

maliayas avatar Mar 18 '23 00:03 maliayas

is there a way to force bookmarker json to be created in the portable folder? rather than the appdata folder

maddrog avatar Jan 05 '24 22:01 maddrog