KaylorBen / nixcord

Declarative Vencord plugins + options
MIT License
62 stars 7 forks source link

Question: Is it possible to modify `~/.config/vesktop/state.json` and `~/.config/vesktop/settings.json`? #18

Open purrpurrn opened 2 months ago

purrpurrn commented 2 months ago

Is it possible to modify ~/.config/vesktop/state.json and ~/.config/vesktop/settings.json?

KaylorBen commented 2 months ago

Ye there's no reason this can't be implimented. I'll start working on it for at least Vesktop. ~/.config/discord/settings.json should also be added, but it has some really ugly JSON fields that'll take a bit.

KaylorBen commented 2 months ago

Let me know if PR #19 works for you. I haven't gotten a chance to actually test it, but it should work since its pretty simple. Only thing I could imagine is weird interaction with mkVencordCfg messing up the JSON.

KaylorBen commented 1 month ago

should be fixed now after merge of PR #19. lmk if you still get the weird default error, but should be fixed

purrpurrn commented 1 month ago
      vesktop.settings = {
        discordBranch = "stable";
    minimizeToTray = false;
    arRPC = false;
      };
      vesktop.state = {
    firstLaunch = false;
      };

causes this error:

       error: cannot convert a function to JSON
       at /nix/store/l31bbdn540yns7ywnp3xb434cli8vh5s-source/lib.nix:120:18:
          119|
          120|   mkVencordCfg = cfg:
             |                  ^
          121|   let
joinemm commented 1 month ago

Also, this would fundamentally not work as if state.json is read only, vencord crashes.

purrpurrn commented 1 month ago

Should we close this or ask the Vesktop devs if it is possible to fix this? :/

joinemm commented 1 month ago

Judging by the dev's comments it's not likely they will fix it: https://github.com/Vencord/Vesktop/issues/220

But using the patch posted in that thread can be used as a workaround

KaylorBen commented 1 month ago

Ye this doesn't look good for this working. I'll leave the options in, but might add warnings to the documentation that this isn't really supported. That or they could be removed entirely. It might also be possible to create a shell script that generates this file outside of the nix store, but idk what that implementation would look like / if its a good idea.

purrpurrn commented 1 week ago

Why not just use the patch by @n3oney?

diff --git a/src/main/settings.ts b/src/main/settings.ts
index 6fad97f..dfc64e3 100644
--- a/src/main/settings.ts
+++ b/src/main/settings.ts
@@ -26,8 +26,10 @@ function loadSettings<T extends object = any>(file: string, name: string) {

     const store = new SettingsStore(settings);
     store.addGlobalChangeListener(o => {
-        mkdirSync(dirname(file), { recursive: true });
-        writeFileSync(file, JSON.stringify(o, null, 4));
+        try {
+            mkdirSync(dirname(file), { recursive: true });
+            writeFileSync(file, JSON.stringify(o, null, 4));
+        } catch {}
     });

     return store;