You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Proposal] Icon support Linux desktop application #53229
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?
[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:
Put a template *.desktop file at ~/.local/share/application/ and put an app icon at ~/.icons/
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.
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).
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).
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.
On Thu, Mar 26, 2020 at 12:22 PM stuartmorgan ***@***.***> wrote:
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.
I think that's desirable. We should provide a skeleton desktop file,
probably as part of the template. Same for an application icon, probably a
stub icon that can be replaced by the app developer. The desktop file and
icon would then be installed via the build system to the appropriate
locations relative to DATADIR. I'd be happy to help with that.
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.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#53229 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAANMBLO2OAR22DAJO5QDZTRJN6MPANCNFSM4LTIAVFA>
.
--
Ubuntu - "I am what I am because of who we all are"
Reacted by nandgator, Valentin Hăloiu, Oirio Joshi, Boris Kayi, Francesco Iapicca, Tom Raganowicz and Suraj
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 AppImagesFlatpak or Snap but find it difficult to do so. I think flutter can fill that void, at least for web apps.
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.
@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?
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:
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)
Reacted by 2zqa, Amin Beheshti, Damiano Ferrari, mx1up, LM. Garret and Danang Rahmatullah
Activity
[-]💡: Icon for Linux desktop application[/-][+][Proposal] Icon support Linux desktop application[/+]stuartmorgan-g commentedon Mar 26, 2020
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
.desktopfile 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?nandgator commentedon Mar 26, 2020
@stuartmorgan thanks for the response.
I got it!
Not photo-shopped! 😄
This is what I manually did:
$app_namebinary is located*.desktopfile with following content:If we automate it, the sequence goes like this:
*.desktopfile at~/.local/share/application/and put an app icon at~/.icons/Icon=/home/$USER/.icons/flutter.pngWatch the
~/.../demo_app/build/linux/debugfor the creation of$app_namebinary. This can be accomplished by many tools likeinotify-tools (C)orwatchdog (python). (I thinkinotifyis better as it comes pre-installed in most Linux system).The file creation event in the previous step triggers an action which appends the
*.desktopfile atName=with the$nameof the debug application.Exec=with the absolute path to the debug binary.(with some regex matching).
That's it!
stuartmorgan-g commentedon Mar 26, 2020
It would be far easier to just add an
installtarget to your Makefile that makes and installs a.desktopfile.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.
kenvandine commentedon Mar 26, 2020
nandgator commentedon Mar 27, 2020
Yes, that would be the better approach.
Yes, may not be... but there are people like me who want to packages things with
AppImagesFlatpakorSnapbut find it difficult to do so. I think flutter can fill that void, at least for web apps.44 remaining items
luizmarinhojr commentedon Jun 5, 2024
On linux, first you need to publish your app ("
flet build linux").Afterward, create a file named "nameyourapp.desktop" at
{your_home}/.local/share/applicationsInside nameyourapp.desktop, type all the information for your app and save it:
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 linuxis 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.
2zqa commentedon Jun 6, 2024
@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?
flutter-triage-bot commentedon Jun 6, 2024
The
triaged-desktoplabel is irrelevant if there is noteam-desktoplabel orfyi-desktoplabel.zhanyce commentedon Aug 6, 2024
any update?
fix(Linux): specify application id for Wayland
fix(Linux): specify application id for Wayland
fix(Linux): specify application id
fix(Linux): specify application id (#154522)
Merrit commentedon Sep 12, 2024
For anyone facing icon issues on Wayland despite having setup a
.desktopfile, 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_prgnameto the function at the end of thelinux/my_application.ccfile: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.txtfile, the lineset(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
.desktopand 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.desktopandcom.example.myapp.svg)Fix: Resolve app icon not showing on Wayland
AliYar-Khan commentedon Nov 28, 2025
This should have been implemented by now. Is there any progress for an official way, or do we have to live with the workarounds?