Skip to content

Instantly share code, notes, and snippets.

@taoky
Created December 20, 2024 07:36
Show Gist options
  • Save taoky/793e47cf8260ab1250bb8d421233167d to your computer and use it in GitHub Desktop.
Save taoky/793e47cf8260ab1250bb8d421233167d to your computer and use it in GitHub Desktop.
Show Linux Desktop AppInfo with Gio
import gi
gi.require_version("Gio", "2.0")
from gi.repository import Gio
def main():
# Retrieve all applications using g_app_info_get_all()
app_infos = Gio.AppInfo.get_all()
# Print details for each application
for app_info in app_infos:
# Get various attributes of the application
name = app_info.get_name() # Name of the application
executable = app_info.get_executable() # Executable command
description = app_info.get_description() # Description of the application
id_ = app_info.get_id() # Application ID (can be None)
supports_uris = app_info.supports_uris() # Whether it supports URIs
# Print application details
print(f"Name: {name}")
print(f"Executable: {executable}")
print(f"Description: {description if description else 'No description provided'}")
print(f"Application ID: {id_ if id_ else 'No ID'}")
print(f"Supports URIs: {'Yes' if supports_uris else 'No'}")
print("-" * 40)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment