nikp123 / xava

X11 Audio Visualizer for ALSA
http://nikp123.github.io/xava
Other
129 stars 14 forks source link

[Feature Request] Pull colors from pywal #59

Closed make-42 closed 2 months ago

make-42 commented 2 months ago

Hello! I have a small feature request! For X11 and Wayland users, XAVA could load its colors from pywal (plain text file located at ~/.cache/wal/colors) for those using pywal. An example file looks like this:

#0D1443
#5851BB
#6E72BD
#2264CC
#19939E
#57AFB4
#609FD8
#c2c4d0
#676a7d
#5851BB
#6E72BD
#2264CC
#19939E
#57AFB4
#609FD8
#c2c4d0

Thank you!

make-42 commented 2 months ago

inserting this at line 159 of src/output/graphical_x11/main.c works for X11:

    int lineNumber = 1;
    static const char b[] = "/.cache/wal/colors";
    int lena = strlen(getenv("HOME"));
    int lenb = strlen(b);
    char *filename = malloc(lena+lenb+1);
    // copy & concat (including string termination)
    memcpy(filename,getenv("HOME"),lena);
    memcpy(filename+lena,b,lenb+1);   
    FILE *file = fopen(filename, "r");
    int count = 0;
    if ( file != NULL )
    {
        char line[256]; /* or other suitable maximum line size */
        while (fgets(line, sizeof line, file) != NULL) /* read a line */
        {
            if (count == lineNumber)
            {
                sscanf(line, "#%06X", colorNum);
                fclose(file);
                break;
            }
            else
            {
                count++;
            }
        }
    }

I still can't figure out how colors are handled for wayland though...

make-42 commented 2 months ago

I also implemented Wayland support

make-42 commented 2 months ago

See #60

nikp123 commented 2 months ago

Merged