Add Linux .desktop file (#38038)

I'm trying to use Servo as a daily driver. I like to pin the most often
used apps to the my taskbar (Dash to Panel in Gnome). I also launch apps
from the menu (Arc Menu). Adding a .desktop file make it show up in the
menu. I could not get pinning to work until I set the name with `winit`.
This is because the name is used to match it with the icon. I used the
Gnome Looking Glass (lg) command to determine that the name was not set.

Testing: I followed the instructions that I put in the .desktop file. I
copied the .desktop file to the right folder, set up a link to the svg
icon, and adjusted the paths to point to the compiled executable.

---------

Signed-off-by: Michael Mc Donnell <michael@mcdonnell.dk>
This commit is contained in:
Michael Mc Donnell 2025-07-13 19:07:12 -04:00 committed by GitHub
parent cd1fdbbeeb
commit c2df8a1bf5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 39 additions and 0 deletions

View file

@ -33,6 +33,8 @@ use winit::event::{
};
use winit::event_loop::ActiveEventLoop;
use winit::keyboard::{Key as LogicalKey, ModifiersState, NamedKey};
#[cfg(target_os = "linux")]
use winit::platform::wayland::WindowAttributesExtWayland;
#[cfg(any(target_os = "linux", target_os = "windows"))]
use winit::window::Icon;
#[cfg(target_os = "macos")]
@ -96,6 +98,10 @@ impl Window {
// happen before the window is shown for the first time.
.with_visible(false);
// Set a name so it can be pinned to taskbars in Linux.
#[cfg(target_os = "linux")]
let window_attr = window_attr.with_name("org.servo.Servo", "Servo");
#[allow(deprecated)]
let winit_window = event_loop
.create_window(window_attr)