New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

freedesktop-icons

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

freedesktop-icons

Find freedesktop icon paths

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

freedesktop-icons

Find icon paths according to the freedesktop icon theme specification.

  • minimal dependencies
  • fast
  • asynchronous

Install

Requires at least NodeJS 10.

# via yarn
yarn add freedesktop-icons
# or via npm
npm install --save-prod freedesktop-icons

API

interface IconDescription {
	// required
	name: string;

	// optional, filters each theme's icon directories, case-insensitive
	type?: "fixed" | "scalable" | "threshold";
	context?: string;
	size?: number;
	scale?: number;
}

module.exports = function freedesktopIcons(
	// The icon query.
	// Can either be a simple string, matching only icon names,
	// or an icon description, including its name, type, context, size or scale.
	// More specific queries result in faster lookups, since theme directories will be filtered.
	// When searching for multiple icons, all queries will be applied to the current theme first
	// before moving on to the next theme.
	icons: ( IconDescription[] | IconDescription | string[] | string ),

	// The themes to use for looking up icons.
	// These have to be internal theme names, as opposed to theme display names.
	// Always adds "hicolor" as the last theme, as defined in the icon theme specification.
	// Looks up icons in the theme's parent themes first before continuing with the next one.
	themes?: ( string[] | string ) = [ "hicolor" ],

	// List of specific icon formats.
	// Searches for png and svg icons by default.
	fileExtensions?: ( string[] | string ) = [ "png", "svg" ],

	// List of non-theme fallback paths.
	// Icons are only being matched by name in fallback paths.
	// Always adds /usr/share/pixmaps as the last fallback path.
	fallbackPaths?: ( string[] | string ) = [ "/usr/share/pixmaps" ]

): ( string | null );

module.exports.clearCache = function clearCache(): void;

Examples

const freedesktopIcons = require( "freedesktop-icons" );

async () => {
	await freedesktopIcons( "some-icon" );
	await freedesktopIcons({ name: "my-app", context: "applications", size: 64 });
	await freedesktopIcons(
		[
			{ name: "my-primary-icon", context: "applications", size: 64 },
			{ name: "my-secondary-icon", context: "applications", size: 64 }
		],
		[
			"Papirus",
			"Paper",
			"Adwaita"
		],
		"png",
		"/path/to/my/app/icons"
	);
	freedesktopIcons.clearCache();
}

Todo

  • Implement theme directory caching, as mentioned in the freedesktop icon theme specification

FAQs

Package last updated on 07 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts