NurioHin / mpv-bookmarker

A bookmarker menu to manage all your bookmarks in MPV
97 stars 24 forks source link

Support for portable mpv installation #11

Open maliayas opened 3 years ago

maliayas commented 3 years ago

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 commented 1 year ago

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
maddrog commented 9 months ago

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

Digita1Menace commented 2 weeks ago

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
```Where does this go in the lua file? can you just post the whole modified lua? thanks.
evoyy commented 1 day ago

mp.find_config_file() seems to be an undocumented function. It doesn't appear in the manual; maybe it has been, or will be removed, so I wouldn't recommend this.