New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@jcbhmr/getdesktopenv

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@jcbhmr/getdesktopenv

🖼️ Which desktop environment is available, if any?

unpublished
latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

getDesktopEnv() for Node.js

🖼️ Which desktop environment is available, if any?
💡 Inspired by t1st3/desktop-env

🎨 Lets you know if the user can open a GUI or not
🐧 Supports Linux, macOS, and Windows
📦 Works in Node.js, Deno, and Bun
🚫 Has a sham for the browser (returns null)
👩‍💻 Includes a basic CLI

🙌 I need your help! What does your development environment return? What desktop environment are you using? Open an Issue and let me know! 😊 I want to make this package more robust and accurate! 🎉

Installation

npm Yarn pnpm

You can install this package using npm, Yarn, or pnpm.

npm install @jcbhmr/getdesktopenv

If you're using this in the browser, don't worry! There's a stub implementation just for you that always returns null. 😊

Usage

Node.js Deno Bun

This package exports a single function, getDesktopEnv(), which returns a Promise<string | null>. The string that it resolves to is the name of the desktop environment that was detected. If no desktop environment was detected, it will resolve to null.

import getDesktopEnv from "@jcbhmr/getdesktopenv";

console.log(getDesktopEnv());
//=> 'Windows shell'

You can also use the CLI directly if you just want to check your desktop env in CI or something. I don't judge. 😜

npx @jcbhmr/getdesktopenv
#=> 'Windows shell'

When using a headless Linux OS (like you might in, say GitHub Actions or GitHub Codespaces), this function will return null. If no desktop environment was matched (an unknown desktop environment) this function will return null. If you're in the browser, this function will also return null.

🐛 If you are using a desktop environment that's not in the list, open an Issue! We want to support as many desktop environments as possible. 😊

Development

JavaScript

This project uses plain JavaScript. It's so simple that we can get away with this! 😄 We also don't have any tests, because this is a very simple package. You are expected to manually make sure that this package works before doing anything major. 😉 Testing is also a bit unfeasible, because there's not a lot of CI providers that support desktop environments. 😅

Here's how you might manually test this package in Node.js:

$ node
Welcome to Node.js v19.9.0.
Type ".help" for more information.
> let m; m = await import("@jcbhmr/getdesktopenv")
[Module: null prototype] { default: [AsyncFunction: getDesktopEnv] }
> await m.default()
'Windows shell'

ℹ There's currently a quirk with JSDoc and TypeScript. TypeScript still wants to look for a @types/* package even though we provide JSDoc types. 🤷‍♂️ #1

Keywords

nodejs

FAQs

Package last updated on 13 Jun 2023

Related posts