raphaelquintao / QRedshiftCinnamon

Linux Cinnamon applet to change screen color temperature
https://cinnamon-spices.linuxmint.com/applets/view/313
Apache License 2.0
93 stars 12 forks source link

Fails to start with "setTimeout is not defined" #32

Closed yrtimiD closed 3 years ago

yrtimiD commented 3 years ago

Cinnamon 3.8.8 Applet version 1.5.5 Debian 10

QRedshift: Created
error t=2021-03-19T15:30:01Z 
[qredshift@quintao]: setTimeout is not defined
[qredshift@quintao]: Failed to evaluate 'main' function on applet: qredshift@quintao/91
trace t=2021-03-19T15:30:01Z 
<----------------
anonymous/QRedshift/<@/home/yrtimid/.local/share/cinnamon/applets/qredshift@quintao/applet.js:214:13
verifyVersion@/home/yrtimid/.local/share/cinnamon/applets/qredshift@quintao/applet.js:259:21
QRedshift@/home/yrtimid/.local/share/cinnamon/applets/qredshift@quintao/applet.js:212:9
main@/home/yrtimid/.local/share/cinnamon/applets/qredshift@quintao/applet.js:787:12
createApplet@/usr/share/cinnamon/js/ui/appletManager.js:573:18
addAppletToPanels@/usr/share/cinnamon/js/ui/appletManager.js:347:22
onEnabledAppletsChanged@/usr/share/cinnamon/js/ui/appletManager.js:290:9
---------------->
raphaelquintao commented 3 years ago

Which Distro you using?

yrtimiD commented 3 years ago

it's Debian 10

raphaelquintao commented 3 years ago

Can you share your sources.list please?

yrtimiD commented 3 years ago

you mean sources.list of apt?

deb http://httpredir.debian.org/debian/ buster main contrib non-free 
deb http://httpredir.debian.org/debian/ buster-updates non-free contrib main 
deb http://security.debian.org/debian-security/ buster/updates main contrib non-free 
deb http://deb.torproject.org/torproject.org/ buster main 
deb [arch=amd64] https://download.docker.com/linux/debian/ buster stable 
deb http://deb.debian.org/debian/ buster-backports non-free contrib main 

and some in sources.list.d... are you looking for something special?

raphaelquintao commented 3 years ago

I wanted to see if your using some testing repository. You see that error on Melange right?

yrtimiD commented 3 years ago

Only stable repo. yes, the error is on Melange.

I searched other applets for setTimeout usage, and all of them use custom implementation like:

function setTimeoutInSeconds(callback, s) {
    return Mainloop.timeout_add_seconds(s, () => {
        callback();
        return false;
    }, null);
}
raphaelquintao commented 3 years ago

Installing Debian here for test...

raphaelquintao commented 3 years ago

I got the same problem here, i will try to fix it.

raphaelquintao commented 3 years ago

I fixed it, but i cant make a pull request now, because i'm working a big update.

So if your are familiar with code, you can fix it yourself by editing the ~/.local/share/cinnamon/applets/qredshift@quintaoapplet.js and replacing the this.verifyVersion() function call with this one. Starts on line 213

        // --- Async Loading ---
        this.verifyVersion(() => {
            this.menu = this._applet_context_menu;

            this.timeout_info = Mainloop.timeout_add_seconds(1, () => {
                qLOG('Redshift required!');
                this.setIcon();
                this.set_applet_label(_("REDSHIFT NOT INSTALLED!"));
                this.set_applet_tooltip(_("Requires Redshift: sudo apt-get install redshift"));
            }, null);

        }, (success) => {
            Mainloop.source_remove(this.timeout_info)
            // Set Menu
            this.menu = this.appMenu;

            // Disable Redshift
            this.disableRedshiftService()

            // Load Informations
            this.setAdjustmentMethods(false);
            this.setLocation(false);

            this.doUpdate();

        });

Thanks for the report! 🍻

raphaelquintao commented 3 years ago

Let me know if works.

yrtimiD commented 3 years ago

Works perfectly! Thanks!

raphaelquintao commented 3 years ago

Fixed in version 1.6.0