Skip to content

Instantly share code, notes, and snippets.

@h4k1m0u
Last active March 10, 2024 14:32
Show Gist options
  • Save h4k1m0u/08ecffbb8ee8a8dc5812e222552b06bd to your computer and use it in GitHub Desktop.
Save h4k1m0u/08ecffbb8ee8a8dc5812e222552b06bd to your computer and use it in GitHub Desktop.
Notions about Gnome to develop extensions in GJS (from https://gjs.guide/extensions/)

D-Bus

  • Interprocess communication (IPC) system for apps.
  • Runs as a service.
  • Two buses:
    • System bus: e.g. to notify about hardware connect/disconnect. Its service: systemctl status dbus.
    • Session bus: Specific to user sessions, e.g. communication between Gnome components. Its service: systemctl --user status dbus.
  • dbus-run-session <cmd>: Starts a new session bus and run cmd in that session (to have access to the session dbus for IPC):
    • e.g gnome-shell --nested: Start Gnome within an existing session (for dev. & testing) without affecting the primary UI.

Extensions

Create a new extension: gnome-extension create --interactive

Files

  • Two mandatory files: metadata.json, and extension.js
  • prefs.json: Preferences for extension.
    • Uses GTK4 and Adwaita.
    • Adwaita: Toolkit that offers widgets to build Gnome apps (extends GTK base widgets).
    • Runs in a separate process from Gnome-shell.
  • extension.js:
    • Uses Clutter and St toolkits (latter builds on Clutter to provide more Widgets & CSS).

Settings

  • GSettings: System for Gnome apps to manage their settings.
  • dconf: underlying backend database for GSettings, with parameters stored in key-value format.

GVariant

  • Variant type (like C's union and C++'s std::variant) that may contain:
    • Simple types: int, bool.
    • Complex types: array of dict.
  • Usage: data to be serialized:
    • Data sent over D-Bus.
    • Saved settings with GSettings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment