Skip to content
Permalink
Browse files

To be able use ShokoDesktop with different settings, use -settings (#597

)

argument:

 ShokoDesktop -settings=nas.json
  • Loading branch information...
bond4u authored and da3dsoul committed Jan 25, 2019
1 parent 31421d5 commit 20a762ad1d11cb8580d0cbf2a1d0d342e3f6d048
Showing with 15 additions and 4 deletions.
  1. +15 −4 Shoko.Desktop/AppSettings.cs
@@ -60,15 +60,26 @@ public static string JMMServerPath

public static string DefaultImagePath => Path.Combine(ApplicationPath, "images");

public static string SettingsFileName {
get {
string[] args = Environment.GetCommandLineArgs();
foreach (var arg in args){
if (null != arg && arg.StartsWith("-settings=")) {
return arg.Substring(10);
}
}
return "settings.json";
}
}
public static string JMMServerImagePath
{
get
{
if (!Directory.Exists(JMMServerPath) || !File.Exists(Path.Combine(JMMServerPath, "settings.json")))
if (!Directory.Exists(JMMServerPath) || !File.Exists(Path.Combine(JMMServerPath, SettingsFileName)))
return null;
Dictionary<string, string> serverSettings =
JsonConvert.DeserializeObject<Dictionary<string, string>>(
File.ReadAllText(Path.Combine(JMMServerPath, "settings.json")));
File.ReadAllText(Path.Combine(JMMServerPath, SettingsFileName)));
if (serverSettings.ContainsKey("ImagesPath"))
return serverSettings["ImagesPath"];
return null;
@@ -87,7 +98,7 @@ public static void SaveSettings()
if (appSettings.Count <= 1)
return; //Somehow debugging may fuck up the settings so this shit will eject

string path = Path.Combine(ApplicationPath, "settings.json");
string path = Path.Combine(ApplicationPath, SettingsFileName);
File.WriteAllText(path, JsonConvert.SerializeObject(appSettings, Formatting.Indented));
}
}
@@ -135,7 +146,7 @@ public static void LoadSettings()
}
}

string path = Path.Combine(ApplicationPath, "settings.json");
string path = Path.Combine(ApplicationPath, SettingsFileName);
if (File.Exists(path))
appSettings = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(path));
else

0 comments on commit 20a762a

Please sign in to comment.
You can’t perform that action at this time.