MagicMirror² v2.12.0 is available! For more information about this release, check out this topic.

A command to refresh magic mirror page



  • Hi all! Previously I was working on a course project based on magic mirror, and it’s required that the smart mirror could be refreshed by a command (because I updated the config.js). I searched around the forum but didn’t find any ready-to-run command. Luckily, I finally figured it out, and would like to share with those who might need it in the future!

    Firstly, here’s the one-line solution:

    xdotool windowactivate --sync $(xdotool search --class electron | awk 'FNR == 3 {print}') key ctrl+r
    

    You might already know that we can use keyboard stroke “ctrl+R” to refresh the smart mirror, and the command above is basically emulating this behavior. As for preparation, you need to use apt-get to download xdotool, which is used to send keyboard stroke command to a given window, in our case the smart mirror. Now I would explain this command in steps:

    xdotool search --class electron
    

    This command searches for existing windows whose name includes “electron”. From my observation, I found that this word “electron” appears in the name of our smart mirror window (though I don’t know what electron is).

    awk 'FNR == 3 {print}'
    

    From the previous step, 3 windows were found. In my case, the 3rd one is the smart mirror window that I’m interested in (maybe in your case it’s not, so remember to test it out!). This command selects it out.

    xdotool windowactivate --sync ... key ctrl+r
    

    This command sends the keystroke “ctrl+R” signal to the window we located in the previous steps.

    Hope this would help!


Log in to reply