Add config file
This commit is contained in:
parent
208e3b7958
commit
a723b029b4
21
OBSBlur/Config.cs
Normal file
21
OBSBlur/Config.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System.Text.Json.Serialization;
|
||||
// ReSharper disable FieldCanBeMadeReadOnly.Global
|
||||
// ReSharper disable ConvertToConstant.Global
|
||||
|
||||
namespace OBSBlur;
|
||||
|
||||
public struct Config
|
||||
{
|
||||
[JsonRequired]
|
||||
public string ObsWebsocketUrl = "ws://localhost:4444";
|
||||
[JsonRequired]
|
||||
public string ObsWebsocketPassword = "";
|
||||
[JsonRequired]
|
||||
public string[] EnabledScenes = { "Desktop" };
|
||||
[JsonRequired]
|
||||
public string[] BlurPrograms = { "Discord", "thunderbird", "Signal" };
|
||||
|
||||
public Config()
|
||||
{
|
||||
}
|
||||
}
|
@ -1,9 +1,19 @@
|
||||
using GlaxLogger;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using OBSBlur;
|
||||
using OBSBlur.OBS;
|
||||
|
||||
string configFilePath = "config.json";
|
||||
|
||||
Logger logger = new (filteredLevel: LogLevel.Trace, consoleOut: Console.Out);
|
||||
Blur _ = new ("ws://localhost:4444", "", new []{"Desktop"}, new []{ "Discord", "VRCX", "thunderbird", "Signal" }, logger);
|
||||
Config config = File.Exists(configFilePath) switch
|
||||
{
|
||||
true => JsonConvert.DeserializeObject<Config>(File.ReadAllText(configFilePath)),
|
||||
_ => new Config()
|
||||
};
|
||||
File.WriteAllText(configFilePath, JsonConvert.SerializeObject(config));
|
||||
Blur _ = new (config.ObsWebsocketUrl, config.ObsWebsocketPassword, config.EnabledScenes, config.BlurPrograms, logger);
|
||||
|
||||
while (true)
|
||||
Thread.Sleep(100);
|
Loading…
Reference in New Issue
Block a user