Desktop Integration
onelf can ship a .desktop entry and icon inside the package and install them into XDG directories so the app shows up in the desktop menu.
The rules this page encodes:
- ✅ Put integration input under
.onelf/: icons in.onelf/icons/, desktop files in.onelf/desktop/. That is what the extraction and desktop integration commands read. - ✅ Reference the packed binary in the desktop file (
Exec=myapp,Icon=myapp).onelf integraterewritesExec=andTryExec=to the binary's absolute path and setsIcon=to the installed icon's theme name. - ✅ Give each entrypoint that belongs in the menu a desktop file of its own,
.onelf/desktop/{entrypoint}.desktop. Integrating the package then installs all of them in one step. - ✅ Integrate a single entrypoint through its symlink. Its
{entrypoint}-named files win over thedefault.*fallbacks. - ✅ Name a multi-entrypoint
Exec=after the entrypoint's argv[0] and ship the matching symlink (myapp-daemon -> myapp.onelf). - ☑️ No bundled desktop file:
integrategenerates a minimal one with the package name.
Bundling icons and desktop files
Place them under .onelf/ in your AppDir:
myapp/
├── bin/
│ └── myapp
├── lib/
│ └── ...
└── .onelf/
├── icons/
│ ├── myapp.svg # or myapp.png, default.svg, default.png
│ └── default.png # fallback when no entrypoint-specific icon
└── desktop/
├── myapp.desktop # matched by entrypoint name
└── default.desktop # fallbackResolution order for icons (first match wins):
.onelf/icons/{entrypoint}.svg.onelf/icons/{entrypoint}.png.onelf/icons/default.svg.onelf/icons/default.png
Resolution order for desktop files:
.onelf/desktop/{entrypoint}.desktop.onelf/desktop/default.desktop
☑️ Copies under share/ serve the running app itself (e.g. GTK icon theme lookups). ✅ For the menu entry, put the desktop file under .onelf/ instead: that is the location the extraction and desktop integration commands read. Integration also installs the app's theme icons at every size it ships, as described below.
Integrate with the desktop
The fastest way to add the app to your menu:
# Using the onelf CLI tool:
onelf integrate ./myapp.onelf
# Or using the binary itself (no CLI tool needed):
./myapp.onelf --onelf-integrateThis installs:
Every icon size the package carries into
$XDG_DATA_HOME/icons/hicolor/, each namedonelf-myapp:- each
icons/hicolor/<size>/apps/<icon>.pngor.svgthe package ships anywhere in its tree, at that<size>.<icon>is the bundled desktop file'sIcon=name, or failing that the entrypoint or package name. - the
.onelf/iconsicon, an SVG toscalable/and a PNG at the<W>x<H>its header gives. It replaces a theme icon of that size.
An icon that is neither SVG nor a readable PNG is not installed.
- each
A
.desktopfile to$XDG_DATA_HOME/applications/onelf-myapp.desktop
$XDG_DATA_HOME defaults to ~/.local/share. myapp here is the package name, with any character other than a letter, digit, - or _ replaced by -. update-desktop-database is run afterwards when it is installed.
The Exec=, TryExec= and Icon= fields are automatically patched to point to the binary's absolute path and installed icon name.
☑️ A package with no bundled .desktop file still integrates: a minimal one is generated with the package name.
Remove desktop integration
onelf unintegrate ./myapp.onelf
# Or:
./myapp.onelf --onelf-unintegrateThis removes the desktop file and the icon at every size.
Packages with several menu entries
Integrating through the default entrypoint, by running the package itself or onelf integrate on it, integrates the whole package. That is the default entrypoint and every other entrypoint that carries a desktop file of its own, each installed as if integrated separately:
.onelf/desktop/myapp.desktop -> onelf-myapp.desktop
.onelf/desktop/myapp-settings.desktop -> onelf-myapp-myapp-settings.desktopAn entrypoint served only by default.desktop, such as a command line tool, gets no menu entry. Unintegrating through the default entrypoint removes the files of every entrypoint.
Selecting an entrypoint
✅ To integrate one entrypoint alone, integrate through the entrypoint's symlink:
ln -s myapp.onelf myapp-daemon
onelf integrate ./myapp-daemonThe symlink's name selects the entrypoint, as it does at launch, so that entrypoint's icon and desktop file resolve. Exec= keeps the symlink, so the menu entry launches that entrypoint. An entrypoint other than the default installs onelf-myapp-myapp-daemon.desktop and its icon beside the default's files rather than over them, and onelf unintegrate ./myapp-daemon removes only those.
✅ Without a symlink, name the entrypoint:
onelf integrate ./myapp.onelf --entrypoint myapp-daemonmyapp.onelf on its own starts the default entrypoint, so Exec= names the one you chose in the launch:
Exec=env ONELF_ENTRYPOINT=myapp-daemon /path/to/myapp.onelf %UTryExec= stays the package path. ./myapp-daemon --onelf-integrate writes the same line, since the runtime integrates from the package file it resolved the symlink to.
Extract without installing
To extract the raw icon or desktop file without installing them:
# Icon to stdout or file
onelf icon myapp.onelf
onelf icon myapp.onelf -o myapp.png
# Desktop file to stdout or file
onelf desktop myapp.onelf
onelf desktop myapp.onelf -o myapp.desktopRuntime-side equivalents:
./myapp.onelf --onelf-icon > myapp.png
./myapp.onelf --onelf-desktop > myapp.desktopDesktop file tips
✅ Reference the packed binary in the .desktop file:
[Desktop Entry]
Name=MyApp
Exec=myapp %f
Icon=myapp
Type=Application
Categories=Utility;When you run onelf integrate, the Exec= line is rewritten to the binary's absolute path automatically, keeping any arguments and field codes after it. The Icon= field is set to the installed icon's theme name.
✅ Actions work the same way. The Exec= of every [Desktop Action ...] group is rewritten to launch the package the same way as the entry's, and the action's own arguments are kept:
[Desktop Action new-window]
Name=New Window
Exec=myapp --new-windowbecomes Exec=/path/to/myapp.onelf --new-window.
✅ Multiple entrypoints: use their argv[0] names:
Exec=myapp-daemoncombined with the matching symlink myapp-daemon -> myapp.onelf.