From 35b17bc620e7de9c21727caa03b709288c672ca3 Mon Sep 17 00:00:00 2001 From: stax76 Date: Wed, 13 Dec 2023 09:46:17 +0100 Subject: [PATCH] New menu item added to add mpv.net to the path environment variable. --- docs/changelog.md | 4 ++++ docs/manual.md | 3 +++ src/MpvNet.Windows/GuiCommand.cs | 18 ++++++++++++++++++ src/MpvNet/InputHelp.cs | 1 + 4 files changed, 26 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 4f6706f6..58ba9122 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,4 +1,8 @@ +# v7.0.0.3 Beta (2023-??-??) + +- New menu item added at Settings/Setup to add mpv.net to the path environment variable. + # v7.0.0.2 Beta (2023-12-13) - Besides a portable download there is now again a setup installer. diff --git a/docs/manual.md b/docs/manual.md index fbb0619c..5d6ac673 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -204,6 +204,9 @@ mpv.net specific commands mpv.net commands are used when mpv commands don't exist or lack a feature. +### add-to-path +Adds mpv.net to the Path environment variable. + ### load-audio Shows a file browser dialog to open external audio files. diff --git a/src/MpvNet.Windows/GuiCommand.cs b/src/MpvNet.Windows/GuiCommand.cs index df558238..112fd490 100644 --- a/src/MpvNet.Windows/GuiCommand.cs +++ b/src/MpvNet.Windows/GuiCommand.cs @@ -45,6 +45,7 @@ public class GuiCommand ["show-menu"] = args => ShowMenu?.Invoke(), ["show-bindings"] = args => ShowBindings(), ["show-playlist"] = args => ShowPlaylist(), + ["add-to-path"] = args => AddToPath(), // deprecated @@ -263,6 +264,23 @@ public void ShowMediaInfo(IList args) public void ShowBindings() => Command.ShowTextWithEditor("Bindings", Player.UsedInputConfContent); + public void AddToPath() + { + string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User)!; + + if (path.ToLower().Contains(Folder.Startup.TrimEnd(Path.DirectorySeparatorChar).ToLower())) + { + Msg.ShowWarning("mpv.net is already in Path."); + return; + } + + Environment.SetEnvironmentVariable("Path", + Folder.Startup.TrimEnd(Path.DirectorySeparatorChar) + ";" + path, + EnvironmentVariableTarget.User); + + Msg.ShowInfo("mpv.net successfully was added to Path."); + } + public void ShowPlaylist() { var count = Player.GetPropertyInt("playlist-count"); diff --git a/src/MpvNet/InputHelp.cs b/src/MpvNet/InputHelp.cs index 8d6f6fdd..965b2105 100644 --- a/src/MpvNet/InputHelp.cs +++ b/src/MpvNet/InputHelp.cs @@ -154,6 +154,7 @@ public static List GetDefaults() new (_("Settings") + " > " + _("Setup"), _("Register audio file associations"), "script-message-to mpvnet reg-file-assoc audio"), new (_("Settings") + " > " + _("Setup"), _("Register image file associations"), "script-message-to mpvnet reg-file-assoc image"), new (_("Settings") + " > " + _("Setup"), _("Unregister file associations"), "script-message-to mpvnet reg-file-assoc unreg"), + new (_("Settings") + " > " + _("Setup"), _("Add mpv.net to Path environment variable"), "script-message-to mpvnet add-to-path"), new (_("Tools"), _("Set/clear A-B loop points"), "ab-loop", "l"), new (_("Tools"), _("Toggle infinite file looping"), "cycle-values loop-file inf no", "L"),