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

Windows color logging #70

Merged
merged 3 commits into from
Oct 12, 2024
Merged

Conversation

clach04
Copy link
Contributor

@clach04 clach04 commented Sep 21, 2024

No description provided.

@clach04
Copy link
Contributor Author

clach04 commented Sep 21, 2024

NOTE this is based on #69, which ideally would be merged before reviewing/merging this.

I've successfully seen pywal16 working under Windows 10 with CPython 3.12.1. For example:

wal --cols16  -i C:\code\py\pywal16\tests\test_files\test.jpg  --backend  colorthief -e -n -p test

@ykhan21
Copy link

ykhan21 commented Oct 12, 2024

Will this work on terminals on Windows that support ANSI colors such as Wezterm and MSYS?
You might want to add a check to see if needs to be called.

@ykhan21
Copy link

ykhan21 commented Oct 12, 2024

There was also a refactoring of the Windows console so that the next Windows Terminal release will support sixel images, so this might not be needed.
The current Windows Terminal Preview includes this refactor.

@eylles
Copy link
Owner

eylles commented Oct 12, 2024

no idea, i've not used a microsoft windows OS since about 2012 so cannot comment on werether or not pywal works there, i just merge whatever windows users PR, hopefully it'll work on windows, else they will open more PRs.

@eylles eylles merged commit c7e5254 into eylles:master Oct 12, 2024
@ykhan21
Copy link

ykhan21 commented Oct 13, 2024

@clach04, does this just get the output log to work right after running wal on the stock windows console? It already works in Windows Terminal.

wal on command prompt:
image

@ykhan21
Copy link

ykhan21 commented Oct 13, 2024

In any case, the the output log doesn't show the new colors, even on Windows Terminal. It'll always show the default.

image

You need to manually cat ~/.cache/wal/sequences in powershell for the change to take effect.

@clach04
Copy link
Contributor Author

clach04 commented Oct 13, 2024

Will this work on terminals on Windows that support ANSI colors such as Wezterm and MSYS? You might want to add a check to see if needs to be called.

I'm a mintty (as used by msys/msys2) user myself, yes it works. I can't comment on Wezterm (I've tried a few new Windows terminals and none work well for me for day-to-day use). Only negative thing I can say about mintty is that out of the box it doesn't support color emoji (which the Microsoft Termain does handle well).

There is no point in adding a check to be called, that's the responsibility of Colorama. If we find a problem case we should either fix Colorama or report a bug upstream.

Here are a few screenshots showing the working logging with colors:

Windows CMD

image

mintty with Windows CMD

image

mintty with bash

image

In all cases, ignore the preview, they are showing the current colors NOT the new pywal generated one.

@clach04
Copy link
Contributor Author

clach04 commented Oct 13, 2024

@clach04, does this just get the output log to work right after running wal on the stock windows console? It already works in Windows Terminal.

Correct. As per PR title.

@clach04
Copy link
Contributor Author

clach04 commented Oct 13, 2024

In any case, the the output log doesn't show the new colors, even on Windows Terminal. It'll always show the default.

image

You need to manually cat ~/.cache/wal/sequences in powershell for the change to take effect.

There are ways around this, at least for CMD and mintty. I'd not thought of using powershell with Windows Terminal to set the new colors, neat idea 👍 !

For CMD there is a Microsoft color tool that could be used with pywal output - Windows Console Colortool https://github.com/microsoft/terminal/releases/tag/1708.14008

For mintty there is a way to refresh the active color scheme - BUT I've not had chance to play with that yet. Your cat technique may be the most straight forward option :-)

I've not yet looked into logic in pywal for trigging scripts before the color preview is shown.

@ykhan21
Copy link

ykhan21 commented Oct 13, 2024

Interesting, so that is why winwal uses colortool. It is for cmd, apparently.

There is no point in adding a check to be called, that's the responsibility of Colorama. If we find a problem case we should either fix Colorama or report a bug upstream.

Colorama doesn't appear actively maintained.

I'm a mintty (as used by msys/msys2) user myself, yes it works.

There are a few open issues for colorama for mintty. I don't know what these issues are about though.
https://github.com/tartley/colorama/issues?q=mintty

Also, the next release of console and Windows Terminal support sixels, so command prompt / windows console may support ANSI colors (I'm not sure though).

@clach04
Copy link
Contributor Author

clach04 commented Oct 13, 2024

Looks like there is 1 open issue and one open PR (for that issue) https://github.com/tartley/colorama/issues?q=mintty+is%3Aopen

If we encounter issues with pywal and Colorama, I'm willing to fork/fix those. @ykhan21 Have you had any issues with this code change on your machine.

Thanks for the winwal link, I'd not seen that before. Annoyingly I already created a ColorTool template and if I'd seen this I could have save myself a few minutes.

@ykhan21
Copy link

ykhan21 commented Oct 13, 2024

Looks like there is 1 open issue and one open PR (for that issue) https://github.com/tartley/colorama/issues?q=mintty+is%3Aopen

If we encounter issues with pywal and Colorama, I'm willing to fork/fix those. @ykhan21 Have you had any issues with this code change on your machine.

I haven't had a chance to test it yet.

winwal calls pywal and does some additional things. Two useful things winwal does that pywal doesn't do is set the colors for the Windows Terminal gui and use colortool so cmd can have color. Everything else can be done with pywal. wal -i img.png generates your colors in .cache/wal/ and adding something like cat .cache/wal/sequences to your powershell profile is like how nix/mac users theme their shell (here).

It might make more sense for the workflow to be reversed, where pywal is called, then the powershell functions you need are called in a script passed to pywal with -o. You can run wal -i img.png -o post_pywal.cmd, where post_pywal.cmd is a script that can refresh the firefox / chromium pywal plugin, call the function you need from winwal, etc.

There is some discussion of pywal on windows here if you're interested.
amnweb/yasb#49
https://github.com/scaryrawr/winwal/tree/main?tab=readme-ov-file#using

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