gabrielzschmitz / Tomato.C

A pomodoro timer written in pure C.
GNU General Public License v3.0
316 stars 20 forks source link

Noise icons not loading + issues with noise #15

Closed indigomarxist closed 1 year ago

indigomarxist commented 1 year ago

The icons on the top left aren't loading and just render as rectangles, and only the rain sound effect works. Nerd font (Mononoki) installed and up-to-date. MacOS Big Sur kitty terminal

gabrielzschmitz commented 1 year ago

About just the rain working. It's my bad, just replace all the void toggleNoise(appData * app, int noise) function at util.c by this:

void toggleNoise(appData * app, int noise){
    if(noise == 1){
        if(app->playRainNoise == 0){
            app->playRainNoise = 1;
            if(app->runRainOnce == 0){
                char * rainnoisecmd[] = {
                    "/usr/local/share/tomato/sounds/ambience-rain.wav",
                    app->rainVolume, "tomato noise rain",
                    NULL};
                app->rainNoisePID = fork();
                app->runRainOnce = 1;
                if(app->rainNoisePID == 0)
                    execv(TOMATONOISE, rainnoisecmd);
            }
            else{
                FILE *tmpfile;
                tmpfile = fopen("/tmp/tomato_rain_state", "w");
                fprintf(tmpfile, "%s ON", app->rainVolume);
                fclose(tmpfile);
            }
        }
        else if(app->playRainNoise == 1){
            FILE *tmpfile;
            tmpfile = fopen("/tmp/tomato_rain_state", "w");
            fprintf(tmpfile, "%s ON", "0");
            fclose(tmpfile);
            app->playRainNoise = 0;
        }
    }
    else if(noise == 2){
        if(app->playFireNoise == 0){
            app->playFireNoise = 1;
            if(app->runFireOnce == 0){
                char * firenoisecmd[] = {
                    "/usr/local/share/tomato/sounds/ambience-fire.wav",
                    app->fireVolume, "tomato noise fire",
                    NULL};
                app->fireNoisePID = fork();
                app->runFireOnce = 1;
                if(app->fireNoisePID == 0)
                    execv(TOMATONOISE, firenoisecmd);
            }
            else{
                FILE *tmpfile;
                tmpfile = fopen("/tmp/tomato_fire_state", "w");
                fprintf(tmpfile, "%s ON", app->fireVolume);
                fclose(tmpfile);
            }
        }
        else if(app->playFireNoise == 1){
            FILE *tmpfile;
            tmpfile = fopen("/tmp/tomato_fire_state", "w");
            fprintf(tmpfile, "%s ON", "0");
            fclose(tmpfile);
            app->playFireNoise = 0;
        }
    }
    else if(noise == 3){
        if(app->playWindNoise == 0){
            app->playWindNoise = 1;
            if(app->runWindOnce == 0){
                char * windnoisecmd[] = {
                    "/usr/local/share/tomato/sounds/ambience-wind.wav",
                    app->windVolume, "tomato noise wind",
                    NULL};
                app->windNoisePID = fork();
                app->runWindOnce = 1;
                if(app->windNoisePID == 0)
                    execv(TOMATONOISE, windnoisecmd);
            }
            else{
                FILE *tmpfile;
                tmpfile = fopen("/tmp/tomato_wind_state", "w");
                fprintf(tmpfile, "%s ON", app->windVolume);
                fclose(tmpfile);
            }
        }
        else if(app->playWindNoise == 1){
            FILE *tmpfile;
            tmpfile = fopen("/tmp/tomato_wind_state", "w");
            fprintf(tmpfile, "%s ON", "0");
            fclose(tmpfile);
            app->playWindNoise = 0;
        }
    }
    else if(noise == 4){
        if(app->playThunderNoise == 0){
            app->playThunderNoise = 1;
            if(app->runThunderOnce == 0){
                char * thundernoisecmd[] = {
                    "/usr/local/share/tomato/sounds/ambience-thunder.wav",
                    app->thunderVolume, "tomato noise thunder",
                    NULL};
                app->thunderNoisePID = fork();
                app->runThunderOnce = 1;
                if(app->thunderNoisePID == 0)
                    execv(TOMATONOISE, thundernoisecmd);
            }
            else{
                FILE *tmpfile;
                tmpfile = fopen("/tmp/tomato_thunder_state", "w");
                fprintf(tmpfile, "%s ON", app->thunderVolume);
                fclose(tmpfile);
            }
        }
        else if(app->playThunderNoise == 1){
            FILE *tmpfile;
            tmpfile = fopen("/tmp/tomato_thunder_state", "w");
            fprintf(tmpfile, "%s ON", "0");
            fclose(tmpfile);
            app->playThunderNoise = 0;
        }
    }
}

and replace this part at tomatonoise.c:

    char line[25];
    int save;

    FILE *tmpfile;
-    tmpfile = fopen(tmppath, "r");
-    if(tmpfile){
-        tmpfile = fopen(tmppath, "w");
-        fprintf(tmpfile, "%s", volume);
-        fclose(tmpfile);
-    }
-    else{
-        tmpfile = fopen(tmppath, "w");
-        fprintf(tmpfile, "%s", volume);
-        fclose(tmpfile);
-    }
+    tmpfile = fopen(tmppath, "w");
+    fprintf(tmpfile, "%s ON", volume);
+    fclose(tmpfile);

    // Done setting up options.
    mpvCheckError(mpv_initialize(mpvCtx));

It's my bad, I pushed the paths to the files in debug mode :(

Now, about the icons, i don't really know why this happen. Try using just icons on and return me a screenshot, so I know if is just the nerdicons or just the text itself! Maybe the fix of the files path just fix the icons too, but give me feedback.

indigomarxist commented 1 year ago

This did fix the noise issue! However, the icon issue still persists. I'm not sure what you mean by this:

Now, about the icons, i don't really know why this happen. Try using just icons on and return me a screenshot, so I know if is just the nerdicons or just the text itself! Maybe the fix of the files path just fix the icons too, but give me feedback.

Thank you so much for the help! I truly love the project.

Edit: As for the icons I believe it may be on my end, I'm experimenting with what icons will display in my terminal.

gabrielzschmitz commented 1 year ago

You need to place the font at your terminal config or xresources and about that:

Now, about the icons, i don't really know why this happen. Try using just icons on and return me a screenshot, so I know if is just the nerdicons or just the text itself! Maybe the fix of the files path just fix the icons too, but give me feedback.

I was talking about editing the config.h and using "iconson" at ICONS, and send me a screenshot. static const char * ICONS = "iconson";