wesktop v0.10.0 /src.wesktop.entries
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

python
def create_entry(name: str, command: str, *, icon: str | Path | None=None, comment: str='', categories: str='Utility;') -> Path

Create 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

python
def remove_entry(name: str) -> bool

Remove a desktop entry (and its launcher script, if any).

Returns True if something was removed.

#entry_exists

python
def entry_exists(name: str) -> bool

Check whether a desktop entry already exists for name on this platform.

#launcher_name

python
def launcher_name(name: str) -> str

Derive the launcher script name for an app: slugged name + '-open'.

#launcher_path

python
def launcher_path(name: str) -> Path

Path of the launcher script for name (POSIX platforms).

#create_launcher

python
def create_launcher(name: str, command: str) -> Path

Create 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

python
def remove_launcher(name: str) -> bool

Remove the launcher script for name. Returns True if it existed.

#_split_windows_command

python
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

python
def quote_windows_command(parts: Sequence[str]) -> str

Join 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

python
def _windows_com_available() -> bool

Whether the pywin32 COM backend is importable.