Skip to content

CLI

The gnim command line tool ships with the gnim npm package as a prebuilt binary, so it is available as npx gnim or through node_modules/.bin in package.json scripts.

NOTE

Currently only Linux x86_64 binaries are published.

Global flags:

FlagDescription
-k, --keep-tmpKeep temporary and runtime files on exit

gnim run

sh
gnim run <SCRIPT> [ARGS]...

Bundles a script into a temporary file and executes it with gjs -m, forwarding any additional arguments.

FlagDescription
-d, --define <KEY=VALUE>Replace global identifiers with constant expressions
sh
gnim run src/main.ts
gnim run -d DEBUG=true -d ENV="DEV" src/main.ts -- --some-flag-for-the-script

gnim types

sh
gnim types

Generates TypeScript annotations from installed .gir files.

FlagDescription
-o, --outdir <PATH>Target directory to generate to
-d, --dirs <PATHS>Look in these directories for .gir files
-i, --ignore <NAMESPACE>Skip rendering by name and version, e.g. Gtk-4.0
--aliasGenerate non-versioned import aliases
-v, --verboseLog debugging statements
sh
# skip Gtk3 to avoid conflicts with Gtk4
gnim types --alias -i Gtk-3.0 -i Gdk-3.0

# include gir files shipped by @gnim-js/gnome-shell
gnim types -d node_modules/@gnim-js/gnome-shell/gir-1.0/gnome50 --alias

gnim schemas

sh
gnim schemas <DIRECTORY>

Compiles *.gschema.ts and *.gschema.js files found in the directory into GSettings XML files. Each file's default export is expected to be a schema list created with defineSchemaList.

FlagDescription
-c, --compileCompile into a gschemas.compiled binary
-o, --outdir <PATH>Where to store generated xml and compiled files
-d, --define <KEY=VALUE>Replace global identifiers with constant expressions
sh
gnim schemas ./src -o ./data --compile

gnim dev

sh
gnim dev <ENTRY>

Starts the development server: bundles the entry file, runs it with gjs -m and watches the project for changes, hot-reloading components over a Unix socket. See the Dev server article for how hot reloading works and its limitations.

FlagDescription
-i, --id <ID>Application ID in reverse DNS format
-d, --define <KEY=VALUE>Replace global identifiers with constant expressions
-v, --verboseVerbose logging

gnim bundle

sh
gnim bundle <ENTRY>

Bundles the entry file and every asset it references (?file imports, CSS) into a gresource bundle.

FlagDescription
-o, --outfile <PATH>Output target (default: gresource)
--id <ID>Application ID in reverse DNS format; used as the resource prefix
-i, --include <PATH>Extra directories to include in the bundle recursively
-d, --define <KEY=VALUE>Replace global identifiers with constant expressions
sh
gnim bundle --id com.example.MyApp -i data/icons src/main.tsx

gnim exe

sh
gnim exe <GRESOURCE>

Generates an executable launcher script for a gresource bundle produced by gnim bundle. The script registers the gresource, sets up gettext and library paths based on the installation layout, and imports the bundled entry point. It is meant to be installed into bindir; see the Packaging tutorial for a complete example.

IMPORTANT

The script generated by this command is not relocatable or portable.

FlagDescription
-o, --outfile <PATH>Output target, if omitted stdout is used
-i, --id <ID>Application ID in reverse DNS format
-p, --prefix <PATH>Installation prefix (default: /usr/local)
-d, --datadir <PATH>Data directory (default: share)
-l, --libdir <PATH>Library directory (default: lib)
sh
gnim bundle --id com.example.MyApp -o build/gresource src/main.tsx
gnim exe build/gresource --id com.example.MyApp -o build/my-app