I really love TeXStudio, but it has one feature that started to annoy me lately.

Whenever I want to get more workspace, I start hitting the Esc button. This is a common (among various IDEs) shortcut to a function which is called "Close something", and it basically closes the secondary floating windows one by one.

However, if I continue hitting Esc after all floating windows are already closed (and it happens all the time by inertia) then a pop-up window with a yellow duck appears:

enter image description here

I tried to search the Internet about this, but got only a couple of minor reports that described this behaviour as an "easter egg". IMHO this is a bit intrusive to be an easter egg, so I would be glad if someone told me how to get rid of this.

Edit by CarLaTeX: (& KJO) TeXStudio duck has been updated, TikZducks appear now!

enter image description here

  • 5
    I did and I'm not getting a duck. This is on Ubuntu, so switching to Ubuntu would do it. Would you accept that as answer? ;-)
    – JPi
    Oct 3, 2016 at 0:48
  • 10
    Is that Paulo's duck??? Oct 3, 2016 at 2:18
  • 1
    @Steven: It's quite amusing. :) Oct 3, 2016 at 7:13
  • 2
    Now I feel bad that Ubuntu has been left out of all the duck-fun. :(
    – A Feldman
    Oct 5, 2016 at 1:06
  • 2
    I am voting to have an option to disable this. Seriously.
    – Matsmath
    Jun 14, 2019 at 8:11

3 Answers 3


I have to declare a conflict of interests, as of the commit I really cannot support removing this lovely duck!

However I can answer on how to replace the generic yellow duck with a customised version :)

If you don't mind compiling a new version from source, I guess the important line is

    txsInformation("<html><head></head><body><img src=':/images/egg.png'></body></html>");

from texstudio.cpp, l. 6646. If one would remove this line, the new window with the duck would not open, but of course this is not what we want. Instead replace this image by your favourite duck, for example:

enter image description here

  • 2
    Wow a TeXstudio duck!
    – CarLaTeX
    Dec 26, 2017 at 4:28
  • I think the duck might feel uncomfortable in the spotlight.
    – Skillmon
    Sep 24, 2018 at 13:42
  • @Skillmon As long as the spotlight does not get too hot, the duck is fine. Otherwise there is the risk of roasted duck ... Sep 24, 2018 at 15:21
  • You call that a risk? I think it'd be an opportunity :)
    – Skillmon
    Sep 24, 2018 at 15:58
  • @Skillmon David will be proud of you :) Sep 24, 2018 at 16:02

The following part of the code is responsible for the rubber duck in the function void Texstudio::viewCloseSomething():

QTime ct = QTime::currentTime();
if (ct.second() % 5 != 0) return;
for (int i=2; i<63; i++) if (ct.minute() != i && ct.minute() % i == 0) return;
txsInformation("<html><head></head><body><img src=':/images/egg.png'></body></html>");

Before this part of code, several cases are handled when the pressing Esc has real effect. If it would do nothing, the quoted code will be executed.

This means that the rubber duck appears exactly when the following conditions are all satisfied:

  1. Esc is pressed, and

  2. it would cause no other effect, and

  3. the current second is a multiple of 5, and, finally,

  4. the current minute is a prime number.


It works on Ubuntu, too

  • 11
    Pretty inefficient prime number testing for the minutes. I would suggest a patch to for (int i=2;i<7;i++) in order to show the duck a few milliseconds quicker. Or explicitly test for i=2,3,5,7. Aug 18, 2017 at 12:36
  • 4
    No need to do this. As 8*8=64>59, a minute's number will not be a multiple of a larger prime number than 7. If it were, that prime number p would need a smaller "partner" x so that p*x=Minute. However, we should have found that partner number when trying the smaller primes. Aug 18, 2017 at 13:14
  • 1
    Honestly, this happens way too often for someone a bit nervous on the ESC side. There are 17 prime minutes between 0 and 60. So you've got a 28.3% chance for the first condition to happen in a given hour, and a 20% chance of being in a second (mod 5) which ends up being an average 5.6% chance of being in a second where the easter egg triggers in a given hour. Since I type "ESC" generally multiple times per minute, this is quite painful. Jan 22, 2018 at 9:19
  • 1
    just press ESC again and it'll go away. No big deal, really. Feb 22, 2018 at 14:31
  • @PixelMaster aaactually, it is a kinda big deal. When you edit documents every day, those seconds you lose add up.
    – ScumCoder
    Jun 15, 2019 at 11:38

Current code was changed to be more seasonal (see latest images in Question above)

6918    // easter egg 
6919    QTime ct = QTime::currentTime(); 
6920    if (ct.second() % 5 != 0) return; 
6921    for (int i = 2; i < 63; i++) if (ct.minute() != i && ct.minute() % i  == 0) return; 
6922    QDate cd = QDate::currentDate(); 
6923    const char * mode = ""; 
6924    if (cd.month() == 12 && cd.day() >= 20) mode = "-santa"; 
6925    else if ( (cd.month() == 10 && cd.day() >= 30) || (cd.month() == 11 && cd.day() == 1)) mode = "-witch"; 
6926      else if ( (cd.month() == 3 && cd.day() >= 22) || (cd.month() == 4 && cd.day() <= 25)) mode = "-easter"; 
6927    UtilsUi::txsInformation(QString("<html><head></head><body><img src=':/images/egg%1.png'></body></html>").arg(mode)); 
6928  }

So in addition to BMV's Answer

  1. If time/date meets conditions from 1 to 4, and is Easter / Halloween / Christmas you see a themed Duck.

Kudos to @CarLaTeX for updating and @BMV for explaining frequency of appearances

Spoiler alert is down to me .ò_ó. see if you can work out which days they will appear.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.