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
    Commented Oct 3, 2016 at 0:48
  • 10
    Is that Paulo's duck??? Commented Oct 3, 2016 at 2:18
  • 1
    @Steven: It's quite amusing. :) Commented Oct 3, 2016 at 7:13
  • 2
    Now I feel bad that Ubuntu has been left out of all the duck-fun. :(
    – A Feldman
    Commented Oct 5, 2016 at 1:06
  • 2
    I am voting to have an option to disable this. Seriously.
    – Matsmath
    Commented Jun 14, 2019 at 8:11

4 Answers 4


I tend to hit my ESC key even if I know it won't do anything. I was constantly bothered by this annoying duck (sorry but this is entirely intruisive and I hate when something pops in the middle of my screen). So here is a solution based on the TeXStudio macro system:

  • Remove the Esc current shortcut for the Close Element (Options > Configure TeXstudio > Shortcuts > Menus > View > Close Element). You won't be able to disable the default shortcut but you can disable the other ones.

  • In Options > Configure TeXstudio > Shortcuts, enable Close Log-View and Close Embedded Viewer.

  • Open the macro editor and create a macro script with shortcut Esc:

    /* for old TexStudio versions, uncomment the following line 
     * to indicate that the macro is to be executed as a script 
    // %SCRIPT
    panel = app.getManagedAction("main/view/show/outputview")
    /* open a fake panel if none exists */
    if (pdfs.length === 0 && !panel.checked) panel.trigger()
    /* close the menu or anything that should be closed */
    /* close the fake panel if needed */
    if (panel.checked) panel.trigger()

The script works as follows: if you have the messages panel opened or if the PDF viewer is opened, then it only closes the element (this is what would have happened by default). If not, it opens the panel and closes the current element (which can either be this panel or another element to close). If another menu was opened (e.g., something like "Insert Unicode Character" or the auto-completer which is impossible to get the state of in QtScript), the fake panel is closed again.

That way, the duck won't be triggered since the action always does something.

  • FINALLY. God bless you.
    – ScumCoder
    Commented Jun 6, 2023 at 22:52

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
    Commented Dec 26, 2017 at 4:28
  • I think the duck might feel uncomfortable in the spotlight.
    – Skillmon
    Commented 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 ... Commented Sep 24, 2018 at 15:21
  • You call that a risk? I think it'd be an opportunity :)
    – Skillmon
    Commented Sep 24, 2018 at 15:58
  • 1
    If you don't mind compiling a new version from source --- suppose you do mind compiling from source (say, since you need Windows builds of TeXstudio); are there any (official or unofficial) builds with the duck already disabled? (I mean, yes, it's cute, but it does get annoying after a while if you're spending most of your working day in TeXstudio...)
    – chsk
    Commented Apr 21, 2022 at 11:05

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

  • 13
    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. Commented 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. Commented 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. Commented Jan 22, 2018 at 9:19
  • 2
    just press ESC again and it'll go away. No big deal, really. Commented Feb 22, 2018 at 14:31
  • 1
    @PixelMaster aaactually, it is a kinda big deal. When you edit documents every day, those seconds you lose add up.
    – ScumCoder
    Commented 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .