:right-sidebar: True DesktopAppInfo =================================================================== .. currentmodule:: gi.repository.Gio .. class:: DesktopAppInfo(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gio.AppInfo` ``GDesktopAppInfo`` is an implementation of :obj:`~gi.repository.Gio.AppInfo` based on desktop files. Note that ```` belongs to the UNIX-specific GIO interfaces, thus you have to use the ``gio-unix-2.0.pc`` pkg-config file or the ``GioUnix-2.0`` GIR namespace when using it. Constructors ------------ .. rst-class:: interim-class .. class:: DesktopAppInfo :no-index: .. classmethod:: new(desktop_id: str) -> ~gi.repository.Gio.DesktopAppInfo | None Creates a new :obj:`~gi.repository.Gio.DesktopAppInfo` based on a desktop file ID. A desktop file ID is the basename of the desktop file, including the ``.desktop`` extension. GIO is looking for a desktop file with this name in the ``applications`` subdirectories of the XDG data directories (i.e. the directories specified in the ``XDG_DATA_HOME`` and ``XDG_DATA_DIRS`` environment variables). GIO also supports the prefix-to-subdirectory mapping that is described in the `Menu Spec `__ (i.e. a desktop ID of ``kde-foo.desktop`` will match ``/usr/share/applications/kde/foo.desktop``\). :param desktop_id: the desktop file ID .. classmethod:: new_from_filename(filename: str) -> ~gi.repository.Gio.DesktopAppInfo | None Creates a new :obj:`~gi.repository.Gio.DesktopAppInfo`\. :param filename: the path of a desktop file, in the GLib filename encoding .. classmethod:: new_from_keyfile(key_file: ~gi.repository.GLib.KeyFile) -> ~gi.repository.Gio.DesktopAppInfo | None Creates a new :obj:`~gi.repository.Gio.DesktopAppInfo`\. .. versionadded:: 2.18 :param key_file: an opened :obj:`~gi.repository.GLib.KeyFile` Methods ------- .. rst-class:: interim-class .. class:: DesktopAppInfo :no-index: .. method:: get_action_name(action_name: str) -> str Gets the user-visible display name of the `‘additional application actions’ `__ specified by ``action_name``\. This corresponds to the ``Name`` key within the keyfile group for the action. .. versionadded:: 2.38 :param action_name: the name of the action as from :obj:`~gi.repository.Gio.DesktopAppInfo.list_actions` .. method:: get_boolean(key: str) -> bool Looks up a boolean value in the keyfile backing ``info``\. The ``key`` is looked up in the ``Desktop Entry`` group. .. versionadded:: 2.36 :param key: the key to look up .. method:: get_categories() -> str | None Gets the categories from the desktop file. .. method:: get_filename() -> str | None When ``info`` was created from a known filename, return it. In some situations such as a :obj:`~gi.repository.Gio.DesktopAppInfo` returned from :obj:`~gi.repository.Gio.DesktopAppInfo.new_from_keyfile`\, this function will return ``NULL``\. .. versionadded:: 2.24 .. method:: get_generic_name() -> str | None Gets the generic name from the desktop file. .. classmethod:: get_implementations() -> list[~gi.repository.Gio.DesktopAppInfo] Gets all applications that implement ``interface``\. An application implements an interface if that interface is listed in the ``Implements`` line of the desktop file of the application. .. versionadded:: 2.42 .. method:: get_is_hidden() -> bool A desktop file is hidden if the ```Hidden`` key `__ in it is set to ``True``\. .. method:: get_keywords() -> list[str] Gets the keywords from the desktop file. .. versionadded:: 2.32 .. method:: get_locale_string(key: str) -> str | None Looks up a localized string value in the keyfile backing ``info`` translated to the current locale. The ``key`` is looked up in the ``Desktop Entry`` group. .. versionadded:: 2.56 :param key: the key to look up .. method:: get_nodisplay() -> bool Gets the value of the ```NoDisplay`` key `__ which helps determine if the application info should be shown in menus. See ``G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY`` and :obj:`~gi.repository.Gio.AppInfo.should_show`\. .. versionadded:: 2.30 .. method:: get_show_in(desktop_env: str | None = None) -> bool Checks if the application info should be shown in menus that list available applications for a specific name of the desktop, based on the ```OnlyShowIn`` `__ and ```NotShowIn`` `__ keys. ``desktop_env`` should typically be given as ``NULL``\, in which case the ``XDG_CURRENT_DESKTOP`` environment variable is consulted. If you want to override the default mechanism then you may specify ``desktop_env``\, but this is not recommended. Note that :obj:`~gi.repository.Gio.AppInfo.should_show` for ``info`` will include this check (with ``NULL`` for ``desktop_env``\) as well as additional checks. .. versionadded:: 2.30 :param desktop_env: a string specifying a desktop name .. method:: get_startup_wm_class() -> str | None Retrieves the ``StartupWMClass`` field from ``info``\. This represents the ``WM_CLASS`` property of the main window of the application, if launched through ``info``\. .. versionadded:: 2.34 .. method:: get_string(key: str) -> str | None Looks up a string value in the keyfile backing ``info``\. The ``key`` is looked up in the ``Desktop Entry`` group. .. versionadded:: 2.36 :param key: the key to look up .. method:: get_string_list(key: str) -> list[str] Looks up a string list value in the keyfile backing ``info``\. The ``key`` is looked up in the ``Desktop Entry`` group. .. versionadded:: 2.60 :param key: the key to look up .. method:: has_key(key: str) -> bool Returns whether ``key`` exists in the ``Desktop Entry`` group of the keyfile backing ``info``\. .. versionadded:: 2.36 :param key: the key to look up .. method:: launch_action(action_name: str, launch_context: ~gi.repository.Gio.AppLaunchContext | None = None) -> None Activates the named application action. You may only call this function on action names that were returned from :obj:`~gi.repository.Gio.DesktopAppInfo.list_actions`\. Note that if the main entry of the desktop file indicates that the application supports startup notification, and ``launch_context`` is non-``NULL``\, then startup notification will be used when activating the action (and as such, invocation of the action on the receiving side must signal the end of startup notification when it is completed). This is the expected behaviour of applications declaring additional actions, as per the `desktop file specification `__\. As with :obj:`~gi.repository.Gio.AppInfo.launch` there is no way to detect failures that occur while using this function. .. versionadded:: 2.38 :param action_name: the name of the action as from :obj:`~gi.repository.Gio.DesktopAppInfo.list_actions` :param launch_context: a :obj:`~gi.repository.Gio.AppLaunchContext` .. method:: launch_uris_as_manager(uris: list[str], launch_context: ~gi.repository.Gio.AppLaunchContext | None, spawn_flags: ~gi.repository.GLib.SpawnFlags, user_setup: ~typing.Callable[[~typing.Any], None] | None = None, user_setup_data: ~typing.Any = None, pid_callback: ~typing.Callable[[~gi.repository.Gio.DesktopAppInfo, int, ~typing.Any], None] | None = None, pid_callback_data: ~typing.Any = None) -> bool This function performs the equivalent of :obj:`~gi.repository.Gio.AppInfo.launch_uris`\, but is intended primarily for operating system components that launch applications. Ordinary applications should use :obj:`~gi.repository.Gio.AppInfo.launch_uris`\. If the application is launched via GSpawn, then ``spawn_flags``\, ``user_setup`` and ``user_setup_data`` are used for the call to :obj:`~gi.repository.GLib.spawn_async`\. Additionally, ``pid_callback`` (with ``pid_callback_data``\) will be called to inform about the PID of the created process. See :obj:`~gi.repository.GLib.spawn_async_with_pipes` for information on certain parameter conditions that can enable an optimized ```posix_spawn()`` `__ code path to be used. If application launching occurs via some other mechanism (for example, D-Bus activation) then ``spawn_flags``\, ``user_setup``\, ``user_setup_data``\, ``pid_callback`` and ``pid_callback_data`` are ignored. :param uris: List of URIs :param launch_context: a :obj:`~gi.repository.Gio.AppLaunchContext` :param spawn_flags: :obj:`~gi.repository.GLib.SpawnFlags`\, used for each process :param user_setup: a [callback``GLib``\.SpawnChildSetupFunc], used once for each process. :param user_setup_data: User data for ``user_setup`` :param pid_callback: Callback for child processes :param pid_callback_data: User data for ``callback`` .. method:: launch_uris_as_manager_with_fds(uris: list[str], launch_context: ~gi.repository.Gio.AppLaunchContext | None, spawn_flags: ~gi.repository.GLib.SpawnFlags, user_setup: ~typing.Callable[[~typing.Any], None] | None, user_setup_data: ~typing.Any, pid_callback: ~typing.Callable[[~gi.repository.Gio.DesktopAppInfo, int, ~typing.Any], None] | None, pid_callback_data: ~typing.Any, stdin_fd: int, stdout_fd: int, stderr_fd: int) -> bool Equivalent to :obj:`~gi.repository.Gio.DesktopAppInfo.launch_uris_as_manager` but allows you to pass in file descriptors for the stdin, stdout and stderr streams of the launched process. If application launching occurs via some non-spawn mechanism (e.g. D-Bus activation) then ``stdin_fd``\, ``stdout_fd`` and ``stderr_fd`` are ignored. .. versionadded:: 2.58 :param uris: List of URIs :param launch_context: a :obj:`~gi.repository.Gio.AppLaunchContext` :param spawn_flags: :obj:`~gi.repository.GLib.SpawnFlags`\, used for each process :param user_setup: a [callback``GLib``\.SpawnChildSetupFunc], used once for each process. :param user_setup_data: User data for ``user_setup`` :param pid_callback: Callback for child processes :param pid_callback_data: User data for ``callback`` :param stdin_fd: file descriptor to use for child’s stdin, or ``-1`` :param stdout_fd: file descriptor to use for child’s stdout, or ``-1`` :param stderr_fd: file descriptor to use for child’s stderr, or ``-1`` .. method:: list_actions() -> list[str] Returns the list of `‘additional application actions’ `__ supported on the desktop file, as per the desktop file specification. As per the specification, this is the list of actions that are explicitly listed in the ``Actions`` key of the ``Desktop Entry`` group. .. versionadded:: 2.38 .. classmethod:: search() -> list[list[str]] Searches desktop files for ones that match ``search_string``\. The return value is an array of strvs. Each strv contains a list of applications that matched ``search_string`` with an equal score. The outer list is sorted by score so that the first strv contains the best-matching applications, and so on. The algorithm for determining matches is undefined and may change at any time. None of the search results are subjected to the normal validation checks performed by :obj:`~gi.repository.Gio.DesktopAppInfo.new` (for example, checking that the executable referenced by a result exists), and so it is possible for :obj:`~gi.repository.Gio.DesktopAppInfo.new` to return ``NULL`` when passed an app ID returned by this function. It is expected that calling code will do this when subsequently creating a :obj:`~gi.repository.Gio.DesktopAppInfo` for each result. .. classmethod:: set_desktop_env() -> None Sets the name of the desktop that the application is running in. This is used by :obj:`~gi.repository.Gio.AppInfo.should_show` and :obj:`~gi.repository.Gio.DesktopAppInfo.get_show_in` to evaluate the ```OnlyShowIn`` `__ and ```NotShowIn`` `__ keys. Should be called only once; subsequent calls are ignored. .. deprecated:: 2.42 do not use this API. Since 2.42 the value of the ``XDG_CURRENT_DESKTOP`` environment variable will be used. Properties ---------- .. rst-class:: interim-class .. class:: DesktopAppInfo :no-index: .. attribute:: props.filename :type: str The type of the None singleton.