Is window setIcon works on linux?

On Ubuntu 20.04 (Gnome) i can’t add an icon to the window’s title bar?
Is this supposed to work, or am i dumb?
Note that I already tried everything suggested in thread above.

I don’t think ubuntu in their default desktop theme allows to put images in window titlebar (i’m supposing you use the native window title bar for your juce app), as i don’t see any other app showing it.

I normally have a step in my application startup where i do make sure i provide a desktop entry file (for linux) to show the app icon wherever the desktop theme needs it (usually in launch menus, side panel docks, desktop icons, global desktop top bars or taskbars).

auto iconPath = applicationDataDirectory.getChildFile("application.svg");
iconPath.deleteFile();

{
    juce::FileOutputStream iconStream(iconPath);
    if (iconStream.openedOk())
    {
        iconStream.setPosition(0);
        iconStream.write(BinaryData::LogoDark_svg, BinaryData::LogoDark_svgSize);
    }
}

if (iconPath.existsAsFile())
{
    auto localShareApplicationsDirectory = juce::File::getSpecialLocation(juce::File::userHomeDirectory)
        .getChildFile(".local")
        .getChildFile("share")
        .getChildFile("applications");

    if (! localShareApplicationsDirectory.isDirectory())
        Process::executeChildProcess({ "mkdir", "-p", localShareApplicationsDirectory.getFullPathName() }, Process::verboseLog);

    auto applicationDesktopFile = localShareApplicationsDirectory.getChildFile("my_wonderful_app.desktop");
    applicationDesktopFile.deleteFile();

    juce::String content;
    content << "[Desktop Entry]" << juce::newLine;
    content << "Type=Application" << juce::newLine;
    content << "Name=" << juce::JUCEApplication::getInstance()->getApplicationName() << juce::newLine;
    content << "Version=" << juce::JUCEApplication::getInstance()->getApplicationVersion() << juce::newLine;
    content << "Comment=" << juce::newLine;
    content << "Exec=" << targetExecutable.getFullPathName() << juce::newLine;
    content << "Icon=" << iconPath.getFullPathName() << juce::newLine;

    applicationDesktopFile.replaceWithText(content);
}
2 Likes

That what i thought, thanks. :laughing: