Gnome

From j4flmao/agent-skills · View interactive version

Gnome is an AI agent skill from the GitHub repository j4flmao/agent-skills. Use when the user asks about GNOME apps, libadwaita, GNOME Shell extensions, GLib/GIO, GSettings schemas, GNOME Builder, Flatpak packaging or the GNOME HIG. Produces GNOME-integrated apps and extensions. Not for general GTK widget programming (use desktop-gtk) or Qt/KDE (use desktop-qt).

How to use this skill

Skill file

GNOME

Purpose

Build applications and extensions for the GNOME desktop environment using GNOME platform libraries — GLib, GIO, GSettings, libadwaita, and GNOME Shell extensions. GNOME emphasizes simplicity, accessibility, and adherence to the GNOME Human Interface Guidelines (HIG).

Agent Protocol

Trigger

Exact user phrases: "GNOME app", "GNOME Shell extension", "libadwaita", "GSettings", "GIO", "GNOME Builder", "GNOME HIG", "GNOME Circle", "GNOME platform", "adwaita", "GNOME design".

Input Context

Output Artifact

GNOME application architecture with widget hierarchy, data flow, settings storage, and Flatpak distribution.

Response Format

App: {app ID}, language {C|Python|Vala|Rust}, GTK4 + libadwaita
UI: {AdwApplicationWindow/NavigationView/Breakpoints tree}
State: {GObject properties, GSettings schema keys}
Distribution: Flatpak manifest {runtime, finish-args}
Code: {files}

Completion Criteria

Max Response Length

250 lines.

Framework/Methodology

GNOME App Decision Tree

What type of GNOME project?
├── Standard GTK application → GtkApplication + libadwaita
│   → AdwApplication, AdwWindow, AdwNavigationView
│   → GSettings for preferences, .gresource for assets
├── GNOME Shell extension → GJS (JavaScript) + GNOME Shell APIs
│   → Extension class, ExtensionState, PanelMenu.Button
│   → GObject-based, prefs.ui for settings
├── Background service → GApplication without GUI
│   → GApplication with flags: IS_SERVICE
│   → D-Bus interface for IPC
└── GNOME Builder plugin → GObject + template
    → IdePlugin, IdeObject, GObject signals + properties

GNOME Platform Stack

Application (libadwaita widgets)
    ↕
libadwaita (AdwApplication, AdwWindow, AdwNavigationView)
    ↕
GTK4 (widgets, CSS styling, rendering)
    ↕
GDK (windowing system, Wayland/X11 abstraction)
    ↕
GLib (main loop, GObject system, GIO async I/O, GSettings)
    ↕
Linux Kernel (Wayland, udev, systemd)

Workflow

Step 1: Set Up GApplication + libadwaita

// Rust with gtk4-rs and libadwaita-rs
use adw::prelude::*;
use gtk::prelude::*;

fn main() {
    glib::set_application_name("My App");

    let app = adw::Application::builder()
        .application_id("com.example.MyApp")
        .resource_base_path("/com/example/MyApp")
        .build();

    app.connect_activate(build_ui);
    app.run();
}

fn build_ui(app: &adw::Application) {
    // Create main window
    let window = adw::ApplicationWindow::new(app);
    window.set_default_size(800, 600);
    window.set_title(Some("My App"));

    // Build content with libadwaita widgets
    let main_content = create_main_content();
    window.set_content(Some(&main_content));
    window.present();
}
# Python with PyGObject
import gi
gi.require_version('Gtk', '4.0')
gi.require_version('Adw', '1')
from gi.repository import Gtk, Adw, GLib, Gio

class MyApp(Adw.Application):
    def __init__(self):
        super().__init__(application_id='com.example.MyApp')
        self.connect('activate', self.on_activate)

    def on_activate(self, app):
        window = Adw.ApplicationWindow(application=app)
        window.set_default_size(800, 600)
        # ... build UI
        window.present()

app = MyApp()
app.run(None)

Step 2: Build UI with libadwaita Widgets

<!-- UI file (myapp.ui) - libadwaita responsive layout -->
<interface>
  <template class="MyAppWindow" parent="AdwApplicationWindow">
    <property name="content">
      <object class="AdwToolbarView">
        <child type="top">
          <object class="AdwHeaderBar">
            <property name="title-widget">
              <object class="AdwWindowTitle"/>
            </property>
            <child type="end">
              <object class="GtkMenuButton">
                <property name="icon-name">open-menu-symbolic</property>
                <property name="menu-model">primary_menu</property>
              </object>
            </child>
          </object>
        </child>
        <child>
          <object class="AdwNavigationView">
            <!-- Pages managed programmatically -->
          </object>
        </child>
      </object>
    </property>
  </template>
</interface>

Key libadwaita Widgets:

Step 3: Adaptive Layout with Breakpoints

// AdwBreakpointBin for responsive layouts
let breakpoint_bin = adw::BreakpointBin::new();

// Wide layout
let wide_bp = adw::Breakpoint::builder(800)
    .condition(adw::BreakpointCondition::new_width(
        adw::LengthUnit::Px,
        adw::BreakpointConditionType::Minimum,
    ))
    .build();

let wide_child = create_wide_layout();  // Sidebar + content
breakpoint_bin.add_child(&breakpoint_bin, &wide_child, glib::PRIORITY_DEFAULT);

// Narrow layout
let narrow_bp = adw::Breakpoint::builder(799)
    .condition(adw::BreakpointCondition::new_width(
        adw::LengthUnit::Px,
        adw::BreakpointConditionType::Maximum,
    ))
    .build();

let narrow_child = create_narrow_layout();  // Stacked
breakpoint_bin.add_child(&breakpoint_bin, &narrow_child, glib::PRIORITY_DEFAULT);

Step 4: Data Model with GObject Properties

use glib::ObjectExt;
use glib::subclass::prelude::*;
use std::cell::RefCell;

// GObject subclass in Rust
mod imp {
    use super::*;

    pub struct MyModel {
        pub name: RefCell<String>,
        pub count: RefCell<u32>,
    }

    #[glib::object_subclass]
    impl ObjectSubclass for MyModel {
        const NAME: &'static str = "MyModel";
        type Type = super::MyModel;
        type ParentType = glib::Object;
    }

    impl ObjectImpl for MyModel {
        fn properties() -> &'static [glib::ParamSpec] {
            use once_cell::sync::Lazy;
            static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
                vec![
                    glib::ParamSpecString::builder("name").build(),
                    glib::ParamSpecUInt::builder("count")
                        .minimum(0).maximum(1000).default_value(0).build(),
                ]
            });
            PROPERTIES.as_ref()
        }

        fn set_property(&self, obj: &Self::Type, id: usize, value: &glib::Value, pspec: &glib::ParamSpec) {
            match pspec.name() {
                "name" => self.name.replace(value.get().unwrap()),
                "count" => self.count.replace(value.get().unwrap()),
                _ => unimplemented!(),
            }
        }

        fn get_property(&self, obj: &Self::Type, id: usize, pspec: &glib::ParamSpec) -> glib::Value {
            match pspec.name() {
                "name" => self.name.borrow().to_value(),
                "count" => self.count.borrow().to_value(),
                _ => unimplemented!(),
            }
        }
    }
}

glib::wrapper! {
    pub struct MyModel(ObjectSubclass<imp::MyModel>);
}

Step 5: Settings with GSettings

<!-- gschema.xml -->
<schemalist>
  <schema id="com.example.MyApp" path="/com/example/MyApp/">
    <key name="window-width" type="i">
      <default>800</default>
      <summary>Window width</summary>
    </key>
    <key name="window-height" type="i">
      <default>600</default>
      <summary>Window height</summary>
    </key>
    <key name="theme" type="s">
      <default>'default'</default>
      <summary>UI theme preference</summary>
    </key>
    <key name="show-sidebar" type="b">
      <default>true</default>
      <summary>Show sidebar</summary>
    </key>
  </schema>
</schemalist>
// Access GSettings
let settings = glib::Settings::new("com.example.MyApp");
settings.connect_changed(Some("theme"), |settings, _key| {
    let theme = settings.string("theme");
    // Apply theme change
});
let width = settings.int("window-width");

Step 6: Flatpak Distribution

# myapp.yml - Flatpak manifest
app-id: com.example.MyApp
runtime: org.gnome.Platform
runtime-version: '47'
sdk: org.gnome.Sdk
command: myapp
finish-args:
  - --share=network
  - --share=ipc
  - --socket=fallback-x11
  - --socket=wayland
  - --device=dri
  - --filesystem=home:ro
modules:
  - name: myapp
    buildsystem: meson
    sources:
      - type: dir
        path: .

Step 7: GNOME Shell Extensions

// extension.js - GNOME Shell extension
const { St, Shell, PanelMenu, Clutter } = imports.gi;
const Main = imports.ui.main;
const ExtensionUtils = imports.misc.extensionUtils;

class MyExtension {
    constructor() {
        this._indicator = null;
    }

    enable() {
        log('Enabling MyExtension');

        // Create panel button
        this._indicator = new PanelMenu.Button(0.0, 'MyExtension', false);

        // Add icon
        const icon = new St.Icon({
            icon_name: 'my-extension-icon',
            style_class: 'system-status-icon'
        });
        this._indicator.add_child(icon);

        // Add to panel
        Main.panel.addToStatusArea('MyExtension', this._indicator, 1);
    }

    disable() {
        log('Disabling MyExtension');
        this._indicator?.destroy();
        this._indicator = null;
    }
}

function init() {
    return new MyExtension();
}

Common Pitfalls

| Pitfall | Description | Prevention |

|---------|-------------|------------|

| Ignoring HIG | Custom widgets that break GNOME design patterns | Follow GNOME HIG, use libadwaita widgets |

| Direct GtkWindow | Missing CSD, header bar | Use AdwApplicationWindow with AdwHeaderBar |

| No adaptive layout | App works only at one window size | Use AdwBreakpointBin, test at mobile width |

| Blocking main loop | Synchronous I/O freezes UI | Use GIO async, async/await, or threads |

| Missing GSchema | Settings don't persist | Always define GSettings schema XML |

| Flatpak permissions too broad | --filesystem=home balloon | Minimal file system access, portals |

| Hardcoded strings | No gettext translation support | Use _() macro everywhere |

| Improper GObject memory | Reference cycles, leaks | Use weak references, bind properly |

Best Practices

| Practice | Rationale |

|----------|-----------|

| Use libadwaita, not pure GTK | Following GNOME HIG, adaptive by default |

| Flatpak as primary distribution | Sandboxed, runtime-managed, automatic updates |

| GSettings for preferences | Native integration, no custom config parser |

| .gresource for bundling | Compiled into binary, no file-system dependencies at runtime |

| GObject signals for events | Standard GNOME pattern, integration with Builder |

| Async I/O with GIO | Non-blocking, cancellable, progress reporting |

| Test on Wayland and X11 | Both display servers are common on Linux |

| Enable accessibility by default | AT-SPI, screen readers, Orca |

| Minimize permissions | Better user trust, Flathub review requirements |

| Internationalize early | Adding _() later is tedious, .pot regeneration |

Architecture Patterns

NavigationView Stack

let nav = adw::NavigationView::new();
let page1 = adw::NavigationPage::new();
page1.set_title("Main");
let page2 = adw::NavigationPage::new();
page2.set_title("Detail");

nav.push(page1);
// Navigate:
nav.push(page2);    // Push detail
nav.pop();           // Back to main

Toast Notifications

let toast = adw::Toast::new("Changes saved");
toast.set_timeout(3);
toast.set_button_label("Undo");
toast.connect_button_clicked(|toast| {
    // Handle undo
});
nav.add_toast(&toast);

Status Page (Empty State)

let status_page = adw::StatusPage::new();
status_page.set_icon_name(Some("emblem-important-symbolic"));
status_page.set_title("No items yet");
status_page.set_description("Add your first item to get started");

References

Handoff

Hand off to desktop-gtk for pure GTK details.

Architecture Decision Trees

GTK4 Widgets vs GTK3 Compatibility

| Decision | GTK4 (Native) | GTK3 (Fallback) |

|---|---|---|

| Widget API | GtkWidget, GtkListView | GtkWidget, GtkTreeView |

| CSS styling | Full CSS + transitions | Limited CSS |

| Performance | Improved rendering | Slower for complex UIs |

| Accessibility | Better AT-SPI2 support | Partial |

| Libadwaita | Recommended platform library for GNOME apps (GTK4 only) | Not available (libhandy was the GTK3 equivalent) |

| Best for | New GNOME apps | Legacy app maintenance |

Libadwaita vs Plain GTK4

| Aspect | Libadwaita (libadwaita) | Plain GTK4 |

|---|---|---|

| HIG compliance | Automatic | Manual |

| Adaptive UI | Built-in breakpoints | Custom code needed |

| Dark mode | Auto-switch | Manual implementation |

| Animation | Built-in transitions | CSS animations |

| Dependency | Heavier | Lighter |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.