gabfv / logitech-g-hub-settings-extractor

This is a small python tool to extract the json file stored inside the "settings.db" file of the Logitech G Hub app. This allows you to update the json and then replace the file blob inside the db with the new json.
MIT License
73 stars 10 forks source link

Can't update settings.db on Windows #7

Closed JD-Softcode closed 2 months ago

JD-Softcode commented 2 months ago

The G Hub settings.db database won't update when using G Hub 2024.6.6 on Windows 11. I used your code in my project, WoW Lights a couple of years ago. I'm updating WoW Lights now and things are fine on MacOS. But on testing Windows the changes I try to make in G Hub are ignored. First issue: quitting G Hub isn't enough anymore; the lghub agent holds the database open too; I was able to force-quit that. But, second issue: the database now has settings.db-wal and settings.db-shm files which indicate Logitech is using write-ahead logging and shared memory features in Sqlite. I think this breaks your code. Any suggestions, please?

gabfv commented 2 months ago

I'm on the same version for G Hub on Windows, and yeah, I do see those two other files (shm and wal). I'm not well-versed enough in sqlite to know exactly what this is but I'll take a look into this.

gabfv commented 2 months ago

@JD-Softcode You can test the new version, it should be fixed. I modified some minor thing on my G Hub instance and it seemed to have worked for me on Windows. It's also backwards-compatible.

JD-Softcode commented 2 months ago

@gabfv awesome quick reply! The code runs fine, but I still have issues making G Hub changes. I created a profile using G Hub, then used this code to change the profile, then deleted the profile. My code is reporting that the deleted profile is still visible in the data base. It does not appear in G Hub. Maybe the database has the data marked as "inactive" but it's still there. Weird. I'm working through this before I can report the issue is fixed. More oddly, after stepping away and rebooting the machine that caused me to report this bug, I looked at G Hub again and the "ignored" changes from 2 hours ago with the old Python code now appeared as changed in G Hub! There's some weird latency/caching going on that may be outside your code.

gabfv commented 2 months ago

Out of curiosity, you use an account with G Hub?

JD-Softcode commented 2 months ago

Hadn't thought about that in ages. On Windows, no account. I have not tried to set that up. On Mac, I have an account but it looks like I'm currently logged out. Have not tried to log back in.

gabfv commented 2 months ago

I'm not sure why a reboot would suddenly makes changes work. Maybe some shenanigans with VSS on Windows? That's the only thing I can think of that would keep a file pinned (as a snapshot) and even then, I'm not even sure why it would trigger like that. Or maybe some backup/sync apps, like Backblaze, Crashplan, Proton Drive, Google Drive, One Drive, etc?

JD-Softcode commented 2 months ago

Back at it tonight, and it seems to work fine. Last night I quit G Hub before making changes, but not LGHUB Agent, which I noticed prevents deleting config.db. And presumably editing it also. Tonight I quit/ended BOTH processes then started editing the config file. After each change, I restarted G Hub and checked the results and everything was as expected. Interestingly, re-starting G Hub never restarted LGHUB Agent; it was off through all the changes. Worked fine this way. That may be a necessary first step? Will close this with my thanks, Gabfv!