Skip to main content

Module icon

Module icon 

Source
Expand description

File-manager icon registration for .devprune.json.

The target here is the OS file manager, not the editor. What is actually achievable differs per platform, and this module is deliberate about saying so rather than implying more than it does:

  • Linux — a real, complete registration. A shared-mime-info package declares the glob *.devprune.json as application/x-devprune, and matching icons go into the hicolor theme. Nautilus, Dolphin, Thunar, Nemo and PCManFM all honour this.
  • Windows — Explorer resolves a file’s icon from the last extension only, so *.devprune.json is indistinguishable from any other .json to it. Claiming the icon would mean claiming every JSON file on the machine, which is not ours to take. The config folder gets its own icon via desktop.ini; individual files keep the system JSON icon.
  • macOS — a UTI has to be exported by an application bundle’s Info.plist, and a single CLI binary is not a bundle. Not supported.

Editors are handled by printing a snippet the user can paste; nothing here edits an editor’s settings file.

Everything written lands in either dev-prune’s own config directory or the user’s XDG data directory. PATH, shell startup files and the binary are untouched.

Constants§

EMBEDDED_ICO_BYTES
EMBEDDED_MIME_ICONS
Mimetype icons, one per hicolor size directory. Downscaled from assets/icon.png and shipped under the same Apache-2.0 licence as the rest of the repository — see assets/README.md.
EMBEDDED_PNG_BYTES
The 256px icon doubles as the config-folder icon on Linux.
EMBEDDED_SCHEMA_BYTES
MIME_ICON_NAME
Icon name derived from the MIME type, as the icon-naming spec requires: the type with its / replaced by -. A file manager looks up exactly this name and no other.
MIME_TYPE
The MIME type *.devprune.json is registered as.

Functions§

is_registered
Whether everything sync_app_directory writes is already on disk.
mime_package_xml
The XDG MIME package describing the glob.
run_install
Register custom file icon associations for *.devprune.json.
sync_app_directory
Write the icon assets and JSON Schema into the config directory, then register the file type with the OS file manager as far as the platform allows.
unregister_file_type
Undo register_file_type. Called by devp uninstall; a no-op off Linux.