npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

desktop-entry-parser

v1.0.0

Published

A TypeScript library for parsing .desktop files according to the Desktop Entry Specification

Readme

Desktop Entry Parser

A TypeScript library for parsing .desktop files according to the Desktop Entry Specification.

Installation

npm install desktop-entry-parser

Usage

Basic Usage

import { parseDesktopFile, parseDesktopString } from 'desktop-entry-parser';

// Parse from file
const entry = parseDesktopFile('/usr/share/applications/firefox.desktop');

// Parse from string
const content = `[Desktop Entry]
Name=Firefox
Exec=firefox %u
Type=Application`;

const entry = parseDesktopString(content);

// Get basic properties
console.log(entry.getName());        // "Firefox"
console.log(entry.getExec());        // "firefox %u"
console.log(entry.isApplication());  // true

Localization Support

// Get localized values
const entry = parseDesktopFile('/path/to/app.desktop');

console.log(entry.getName('zh_CN'));     // Returns Chinese name if available
console.log(entry.getComment('de'));     // Returns German comment if available

Working with Actions

const entry = parseDesktopFile('/path/to/app.desktop');

// Get available actions
const actions = entry.getActions();  // ['new-window', 'new-private-window']

// Get action details
for (const action of actions) {
    console.log(entry.getActionName(action));
    console.log(entry.getActionExec(action));
    console.log(entry.getActionIcon(action));
}

Desktop Environment Visibility

const entry = parseDesktopFile('/path/to/app.desktop');

// Check if should show in specific desktop environment
console.log(entry.shouldShowIn('GNOME'));  // true/false
console.log(entry.shouldShowIn('KDE'));    // true/false

Advanced API

import { DesktopEntryParser, DesktopEntryWrapper } from 'desktop-entry-parser';

// Create parser with options
const parser = new DesktopEntryParser({
    encoding: 'utf8',
    strictMode: true,       // Throw on invalid format
    preserveComments: false
});

// Parse and create wrapper
const entry = parser.parseFile('/path/to/app.desktop');
const wrapper = new DesktopEntryWrapper(entry, parser);

// Get complete metadata
const metadata = wrapper.getMetadata();
console.log(metadata.type);
console.log(metadata.categories);
console.log(metadata.mimeType);

// Get raw entry data
const rawEntry = wrapper.getEntry();
const desktopGroup = rawEntry.groups.get('Desktop Entry');

// Serialize back to string
const serialized = wrapper.serialize();

// Save to file
wrapper.saveToFile('/path/to/new.desktop');

Async Operations

import { parseDesktopFileAsync } from 'desktop-entry-parser';

// Async file parsing
const entry = await parseDesktopFileAsync('/path/to/app.desktop');

// Async save
await entry.saveToFileAsync('/path/to/new.desktop');

API Reference

Main Functions

  • parseDesktopFile(filePath: string) - Parse a desktop file synchronously
  • parseDesktopFileAsync(filePath: string) - Parse a desktop file asynchronously
  • parseDesktopString(content: string) - Parse desktop content from string

DesktopEntryWrapper Methods

Basic Properties

  • getName(locale?: string) - Get application name
  • getComment(locale?: string) - Get comment/description
  • getExec() - Get executable command
  • getIcon() - Get icon name/path
  • getType() - Get entry type (Application/Link/Directory)
  • getUrl() - Get URL (for Link type)

Lists

  • getCategories() - Get category list
  • getMimeTypes() - Get supported MIME types
  • getActions() - Get available actions

Boolean Properties

  • isHidden() - Check if entry is hidden
  • isTerminal() - Check if runs in terminal
  • isApplication() - Check if type is Application
  • isLink() - Check if type is Link
  • isDirectory() - Check if type is Directory

Actions

  • getActionName(action: string, locale?: string) - Get action name
  • getActionExec(action: string) - Get action command
  • getActionIcon(action: string) - Get action icon

Desktop Environment

  • shouldShowIn(desktop: string) - Check if should display in desktop

Metadata

  • getMetadata(locale?: string) - Get all metadata as object

Serialization

  • serialize() - Convert to desktop file string
  • saveToFile(filePath: string) - Save to file
  • saveToFileAsync(filePath: string) - Save to file async

License

ISC