Class DesktopShortcutService
- Namespace
- McServerLauncher.Services
- Assembly
- McServerLauncher.dll
Puts a shortcut to the app on the user's desktop.
Each desktop means something different by "shortcut": Windows wants a .lnk, Linux a
.desktop entry that has to be executable and, on GNOME, explicitly trusted, and macOS a
symlink to the bundle. What they share is that the target must be whatever this copy is really
running from — an AppImage the user dropped in Downloads, a bundle in /Applications — and not a
guessed install path.
public static class DesktopShortcutService
- Inheritance
-
DesktopShortcutService
- Inherited Members
Properties
IsAvailable
True when a desktop folder exists to put anything in.
public static bool IsAvailable { get; }
Property Value
LaunchTarget
Where this copy of the app should be launched from.
public static string? LaunchTarget { get; }
Property Value
Remarks
For an AppImage that is the .AppImage file itself, not the executable inside its mount: the mount point disappears when the app closes, so a shortcut to it would break instantly.
Methods
Create()
Creates (or refreshes) the shortcut. Returns the path it wrote.
public static string Create()
Returns
Exceptions
- InvalidOperationException
With a message meant for the user.
RefreshInstalledIcon()
Brings an already-installed desktop icon back in line with the build that is running. Called at startup; does nothing at all on Windows and macOS.
public static void RefreshInstalledIcon()
Remarks
Windows and macOS need no such thing: their shortcut points at the executable or the .app bundle, both of which the updater replaces wholesale, so the icon they draw is always the current one. Linux is the odd one out because the .desktop entry cannot point into the AppImage — the icon only exists under $APPDIR, a /tmp mount that is gone the moment the app exits — so what it points at is a copy, taken once when the shortcut was created. Updating replaces the AppImage and nothing else, which leaves that copy showing the old icon forever.
Deliberately never creates anything: putting the app on someone's desktop is the Settings button's job, not startup's. It also never rewrites the .desktop entry, because deleting and recreating that file is what loses an icon's position on the desktop.