On this page
Create and remove native desktop entries across platforms: Linux .desktop files, macOS .app bundles, and Windows Start Menu shortcuts from one API.
#src.wesktop.entries
#src.wesktop.entries
Cross-platform desktop entry creation and removal for Linux .desktop files, macOS .app bundles, and Windows Start Menu shortcuts.
#create_entry
def create_entry(name: str, command: str, *, icon: str | Path | None=None, comment: str='', categories: str='Utility;') -> PathCreate a platform-native desktop entry. Returns the path of the created entry.
command is a full, already-quoted command line. On Linux/macOS, quote arguments with shlex.quote. On Windows, double-quote any path or argument containing spaces (see :func:quote_windows_command).
#remove_entry
def remove_entry(name: str) -> boolRemove a desktop entry (and its launcher script, if any).
Returns True if something was removed.
#entry_exists
def entry_exists(name: str) -> boolCheck whether a desktop entry already exists for name on this platform.
#launcher_name
def launcher_name(name: str) -> strDerive the launcher script name for an app: slugged name + '-open'.
#launcher_path
def launcher_path(name: str) -> PathPath of the launcher script for name (POSIX platforms).
#create_launcher
def create_launcher(name: str, command: str) -> PathCreate an executable launcher script for name that execs command.
command must be a fully shell-quoted POSIX command line. Only supported on Linux and macOS -- a POSIX shell script cannot execute on Windows, so Windows shortcuts must point directly at their target instead.
#remove_launcher
def remove_launcher(name: str) -> boolRemove the launcher script for name. Returns True if it existed.
#_split_windows_command
def _split_windows_command(command: str) -> tuple[str, str]Split a Windows command line into (target, arguments).
Quoting contract: a target path containing spaces MUST be double-quoted, e.g. '"C:\Program Files\app.exe" --arg'. Unquoted commands split at the first whitespace. An unquoted absolute-path target whose first token has no file extension is almost certainly a spaces-in-path target truncated at the first space -- that is a hard error instead of silently producing a shortcut to a nonexistent target.
#quote_windows_command
def quote_windows_command(parts: Sequence[str]) -> strJoin command parts into a Windows command line.
Follows the quoting contract of :func:_split_windows_command: any part containing whitespace is double-quoted.
#_windows_com_available
def _windows_com_available() -> boolWhether the pywin32 COM backend is importable.