Skip to content

[Proposal] Icon support Linux desktop application #53229

Open

Description

@nandgator

Use case

The default Linux application icon looks ugly...🥴 Flutter is way worthy than that... 😎

image

Proposal

This looks much better (photo-shopped)

image

Activity

  1. changed the title [-]💡: Icon for Linux desktop application[/-] [+][Proposal] Icon support Linux desktop application[/+] on Mar 25, 2020
  2. added
    a: qualityA truly polished experience
    frameworkflutter/packages/flutter repository. See also f: labels.
    c: proposalA detailed proposal for a change to Flutter
    c: new featureNothing broken; request for a new capability
    platform-linuxBuilding on or for Linux specifically
    on Mar 25, 2020
  3. added
    a: buildBuilding flutter applications with the tool
    toolAffects the "flutter" command-line tool. See also t: labels.
    and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Mar 25, 2020
  4. stuartmorgan-g commented on Mar 26, 2020

    @stuartmorgan-g
    Contributor

    The reason this hasn't been done is that there isn't really a solution to this on Linux that is within the scope of Flutter; see google/flutter-desktop-embedding#630.

    That said, @kenvandine, I think it was you who suggested we have a stub .desktop file in the build output as a starting point for people who want to configure one; do you have a suggestion about what exactly should be in that stub, or a pointer to projects that do something along those lines to compare with?

  5. nandgator commented on Mar 26, 2020

    @nandgator
    Author

    @stuartmorgan thanks for the response.

    I got it!

    image

    Not photo-shopped! 😄

    This is what I manually did:

    • Figured out where the $app_name binary is located
    • Created a *.desktop file with following content:
    [Desktop Entry]
    Version=1.0
    Type=Application
    Name=demo_app
    Exec=/home/$USER/path/to/project/build/linux/debug/./demo_app
    Icon=/home/$USER/.icons/flutter.png
    Comment=Welcome to the flutterverse!
    Categories=Development;
    Terminal=false
    StartupNotify=true;

    If we automate it, the sequence goes like this:

    1. Put a template *.desktop file at ~/.local/share/application/ and put an app icon at ~/.icons/
    2. Then link the icon to the desktop file as Icon=/home/$USER/.icons/flutter.png

    These two steps need to be done only once and can be executed at either flutter create - project creation or at flutter SDK installation time.

    1. Watch the ~/.../demo_app/build/linux/debug for the creation of $app_name binary. This can be accomplished by many tools like inotify-tools (C) or watchdog (python). (I think inotify is better as it comes pre-installed in most Linux system).

    2. The file creation event in the previous step triggers an action which appends the *.desktop file at

      • Name= with the $name of the debug application.
      • Exec= with the absolute path to the debug binary.
        (with some regex matching).

    That's it!

  6. stuartmorgan-g commented on Mar 26, 2020

    @stuartmorgan-g
    Contributor

    Watch the ~/.../demo_app/build/linux/debug for the creation of $app_name binary.

    It would be far easier to just add an install target to your Makefile that makes and installs a .desktop file.

    To be clear, the issue isn't that building that into Flutter would be difficult, it's that it's not particularly useful in the long term since building and running Flutter applications from source is not what I expect the usual distribution model to be.

  7. kenvandine commented on Mar 26, 2020

    @kenvandine
    Contributor
  8. nandgator commented on Mar 27, 2020

    @nandgator
    Author

    It would be far easier to just add an install target to your Makefile that makes and installs a .desktop file.

    Yes, that would be the better approach.

    To be clear, the issue isn't that building that into Flutter would be difficult, it's that it's not particularly useful in the long term since building and running Flutter applications from source is not what I expect the usual distribution model to be.

    Yes, may not be... but there are people like me who want to packages things with AppImages Flatpak or Snap but find it difficult to do so. I think flutter can fill that void, at least for web apps.

  9. 44 remaining items

  10. luizmarinhojr commented on Jun 5, 2024

    @luizmarinhojr

    On linux, first you need to publish your app ("flet build linux").

    Afterward, create a file named "nameyourapp.desktop" at {your_home}/.local/share/applications

    Inside nameyourapp.desktop, type all the information for your app and save it:

    [Desktop Entry]
    Name=Name of your app
    Comment=Description of your app
    Exec=the-path-to-your-executable-file
    Icon=the-path-to-your-icon-app.png
    Terminal=false
    Type=Application
    StartupWMClass=the-name-of-your-executable-file
    Categories=your-choice-here;
    

    Maybe you need to log out and log back in for the changes to take effect.

    The StartupWMClass is essential as it teaches your launcher manager how to associate the window on the desktop environment's window manager with the launcher's icon.

    This method worked on my Fedora 39 and 40 with Gnome.

    The WM_CLASS is basically the name that the desktop environment's window manager associates with a window of a running program.

    Usually, by default, this WM_CLASS attribute of the program published by flet build linux is the same name as the executable generated by flet.

    If it's not the same, checking the WM_CLASS name is quite simple.

    If you are using Wayland, start your flet program by the generated executable and then, with the program open, press ALT + F2, type "lg" and press Enter, then click on "Windows" and check the name associated with the wmclass of your program.

  11. 2zqa commented on Jun 6, 2024

    @2zqa

    @luizmarinhojr, this requires a separate file, essentially "installing" the binary to your system, or at least locking down the location. Does GNOME support icons bundled with a binary, as far as you are aware?

  12. added
    team-linuxOwned by the Linux platform team
    and removed on Jun 6, 2024
  13. flutter-triage-bot commented on Jun 6, 2024

    @flutter-triage-bot

    The triaged-desktop label is irrelevant if there is no team-desktop label or fyi-desktop label.

  14. zhanyce commented on Aug 6, 2024

    @zhanyce

    any update?

  15. Merrit commented on Sep 12, 2024

    @Merrit
    Contributor

    For anyone facing icon issues on Wayland despite having setup a .desktop file, such as the icon not showing on the window decorations, task switchers and Overview-type effects:

    A fix has been merged to resolve this for newly created projects in the future, and can be applied to existing projects like so:

    Add g_set_prgname to the function at the end of the linux/my_application.cc file:

    MyApplication* my_application_new() {
    + g_set_prgname(APPLICATION_ID);
    
      return MY_APPLICATION(g_object_new(my_application_get_type(),
                                         "application-id", APPLICATION_ID,
                                         "flags", G_APPLICATION_NON_UNIQUE,
                                         nullptr));
    }

    Also ensure that in the linux/CMakeLists.txt file, the line set(APPLICATION_ID "<your_app_id>") is set to your desired application ID (often the reverse domain name of your app, e.g. com.example.myapp).

    Now if the app's .desktop and icon files are named the same as the application ID, the app's window should be correctly associated and the icons should show up correctly. (e.g. com.example.myapp.desktop and com.example.myapp.svg)

  16. AliYar-Khan commented on Nov 28, 2025

    @AliYar-Khan

    This should have been implemented by now. Is there any progress for an official way, or do we have to live with the workarounds?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: buildBuilding flutter applications with the toola: desktopRunning on desktopa: qualityA truly polished experiencec: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterplatform-linuxBuilding on or for Linux specificallyteam-linuxOwned by the Linux platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-linuxTriaged by the Linux platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions