LionyxML / auto-dark-emacs

Auto-Dark-Emacs is an auto changer between 2 themes, dark/light, following MacOS, Linux or Windows Dark Mode settings
GNU General Public License v2.0
140 stars 34 forks source link

WSL support #52

Open viktordoronin opened 4 months ago

viktordoronin commented 4 months ago

Hello! This package doesn't work under WSL, so I've come up with my own detection method and patched it in. It evaluates (string-match "microsoft-standard-WSL" (shell-command-to-string "uname -a")) to find out whether the host system is WSL(the only way to detect a WSL host, to my knowledge). The dark theme detection method is similar to the method powershell, the difference is because running a Windows shell under Linux shell under Emacs makes string comparison complicated. It looks scuffed, but it works well. I only tested this patch under WSL so I don't know for certain if it doesn't break under other systems. It shouldn't AFAIK, but I'm new to Emacs so there's a possibility I introduced my changes in an incorrect/dangerous way. If there are any problems that need fixing, feel free to reach out to me or change the code as you see fit.

aparkerdavid commented 3 months ago

Thanks for figuring this out! One issue I found: I have to manually set auto-dark-detection-method variable in order for this to work. It looks like it's hitting the cond case for 'dbus on line 283 in auto-dark--determine-detection-method. I don't think you can rely on the dbus feature being absent under WSL.

LionyxML commented 3 months ago

So, "what if" we move the wsl check to before d-bus?

It would work under wsl loading the "windows" settings, never hitting d-bus, and it would not matter on real systems that use d-bus.

viktordoronin commented 3 months ago

Linux detection methods not working under WSL led me to believe we can't rely on dbus, else it would have worked out of the box. Thus the entire patch.

@aparkerdavid not sure what you mean by:

"I have to manually set auto-dark-detection-method variable in order for this to work"

Are you trying this under WSL or is it breaking under actual Linux? Because under WSL I just load the package and enable it and that's it. If you have this under WSL, what's your distribution? Is it from Microsoft store or something you loaded yourself?

@LionyxML

It would work under wsl loading the "windows" settings, never hitting d-bus, and it would not matter on real systems that use d-bus.

I don't think that would be valid since exal-exp (eq system-type 'windows-nt) returns nil, as far es Emacs is concerned it's running under Linux. However, note how my check is at the very end, in an attempt to avoid confusions such as this. Perhaps bundling it with the rest of Linux checks(line 283 and onward) would help? At any rate, since I'm an Emacs beginner(and don't have a Linux machine on hand), I'd really prefer if somebody more competent than me would try to fix this, simply for the sake of practicality.

LionyxML commented 1 month ago

@viktordoronin Just letting you know this is on my (veeery long) task list! I'll check it as soon as I can.

Not forgotten!

LionyxML commented 1 month ago

Quick question @viktordoronin , this is supposed to work with WSL 1/2 or both?

I am trying to figure if there is any diference between both as far as using "dbus"