Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL support #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

WSL support #52

wants to merge 1 commit into from

Conversation

viktordoronin
Copy link

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.

@viktordoronin viktordoronin changed the title WSL support patched in WSL support Apr 13, 2024
@aparkerdavid
Copy link

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

LionyxML commented Jul 3, 2024

@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
Copy link
Owner

LionyxML commented Jul 8, 2024

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants