wallpaper
Advanced tools
Comparing version 5.0.1 to 6.0.0
154
index.d.ts
@@ -1,116 +0,96 @@ | ||
declare namespace wallpaper { | ||
interface GetOptions { | ||
/** | ||
__macOS only.__ | ||
export interface GetOptions { | ||
/** | ||
__macOS only.__ | ||
The screen to get the wallpaper from. | ||
The screen to get the wallpaper from. | ||
Values: `all`, `main`, or the index of a screen from `.screens()`. | ||
Values: `all`, `main`, or the index of a screen from `.screens()`. | ||
@default 'main' | ||
*/ | ||
readonly screen?: 'all' | 'main' | number; | ||
} | ||
@default 'main' | ||
*/ | ||
readonly screen?: 'all' | 'main' | number; | ||
} | ||
interface SetOptions { | ||
/** | ||
__macOS only.__ | ||
export interface SetOptions { | ||
/** | ||
__macOS only.__ | ||
The screen to set the wallpaper on. | ||
The screen to set the wallpaper on. | ||
Values: `all`, `main`, or the index of a screen from `.screens()`. | ||
Values: `all`, `main`, or the index of a screen from `.screens()`. | ||
*On Linux and Windows it's hard-coded to `main`.* | ||
*On Linux and Windows it's hard-coded to `main`.* | ||
@default 'all' | ||
*/ | ||
readonly screen?: 'all' | 'main' | number; | ||
@default 'all' | ||
*/ | ||
readonly screen?: 'all' | 'main' | number; | ||
/** | ||
__macOS only.__ | ||
/** | ||
__macOS only.__ | ||
Scaling method. Values: `auto` `fill` `fit` `stretch` `center`. | ||
Scaling method. Values: `auto` `fill` `fit` `stretch` `center`. | ||
@default 'auto' | ||
*/ | ||
readonly scale?: 'auto' | 'fill' | 'fit' | 'stretch' | 'center'; | ||
} | ||
@default 'auto' | ||
*/ | ||
readonly scale?: 'auto' | 'fill' | 'fit' | 'stretch' | 'center'; | ||
} | ||
// eslint-disable-next-line no-redeclare | ||
declare const wallpaper: { | ||
// TODO: remove this in the next major version | ||
// when removed, each of the methods in this interface can be refactored to an explicit function export | ||
// and `wallpaper` namespace may be removed completely along with the `export = wallpaper` export. | ||
default: typeof wallpaper; | ||
/** | ||
Get the path to the wallpaper image currently set. | ||
/** | ||
Get the path to the wallpaper image currently set. | ||
@returns The path of the current desktop wallpaper. | ||
@returns The path of the current desktop wallpaper. | ||
@example | ||
``` | ||
import {getWallpaper} from 'wallpaper'; | ||
@example | ||
``` | ||
import wallpaper = require('wallpaper'); | ||
await getWallpaper(); | ||
//=> '/Users/sindresorhus/unicorn.jpg' | ||
``` | ||
*/ | ||
export function getWallpaper(options?: GetOptions): Promise<string>; | ||
(async () => { | ||
await wallpaper.get(); | ||
//=> '/Users/sindresorhus/unicorn.jpg' | ||
})(); | ||
``` | ||
*/ | ||
get(options?: wallpaper.GetOptions): Promise<string>; | ||
/** | ||
Set a new wallpaper. | ||
/** | ||
Set a new wallpaper. | ||
@param imagePath - The path to the image to set as the desktop wallpaper. | ||
@param imagePath - The path to the image to set as the desktop wallpaper. | ||
@example | ||
``` | ||
import {setWallpaper} from 'wallpaper'; | ||
@example | ||
``` | ||
import wallpaper = require('wallpaper'); | ||
await setWallpaper('unicorn.jpg'); | ||
``` | ||
*/ | ||
export function setWallpaper(imagePath: string, options?: SetOptions): Promise<void>; | ||
(async () => { | ||
await wallpaper.set('unicorn.jpg'); | ||
})(); | ||
``` | ||
*/ | ||
set(imagePath: string, options?: wallpaper.SetOptions): Promise<void>; | ||
/** | ||
__macOS only.__ | ||
/** | ||
__macOS only.__ | ||
@returns The available screens. | ||
@returns The available screens. | ||
@example | ||
``` | ||
import {screens} from 'wallpaper'; | ||
@example | ||
``` | ||
import wallpaper from 'wallpaper'; | ||
await screens(); | ||
//=> ['Color LCD'] | ||
``` | ||
*/ | ||
export function screens(): Promise<string[]>; | ||
(async () => { | ||
await wallpaper.screens(); | ||
//=> ['Color LCD'] | ||
})(); | ||
``` | ||
*/ | ||
screens?(): Promise<string[]>; | ||
/** | ||
__macOS only.__ | ||
/** | ||
__macOS only.__ | ||
Set a solid color. | ||
Set a solid color. | ||
@param color - The color to set as a RGB Hex value. For example, `000000` for black. | ||
@param color - The color to set as a RGB Hex value. For example, `000000` for black. | ||
@example | ||
``` | ||
import {setSolidColorWallpaper} from 'wallpaper'; | ||
@example | ||
``` | ||
import wallpaper from 'wallpaper'; | ||
(async () => { | ||
await wallpaper.setSolidColor('000000'); | ||
})(); | ||
``` | ||
*/ | ||
setSolidColor?(rgbHexColor: string, options?: wallpaper.SetOptions): Promise<void>; | ||
}; | ||
export = wallpaper; | ||
await setSolidColorWallpaper('000000'); | ||
``` | ||
*/ | ||
export function setSolidColorWallpaper(rgbHexColor: string, options?: SetOptions): Promise<void>; |
15
index.js
@@ -1,14 +0,15 @@ | ||
'use strict'; | ||
import process from 'node:process'; | ||
import * as macos from './source/macos.js'; | ||
import * as linux from './source/linux/index.js'; | ||
import * as windows from './source/windows.js'; | ||
let wallpaper; | ||
if (process.platform === 'darwin') { | ||
wallpaper = require('./source/macos.js'); | ||
wallpaper = macos; | ||
} else if (process.platform === 'win32') { | ||
wallpaper = require('./source/windows.js'); | ||
wallpaper = windows; | ||
} else { | ||
wallpaper = require('./source/linux/index.js'); | ||
wallpaper = linux; | ||
} | ||
module.exports = wallpaper; | ||
// TODO: remove this in the next major version | ||
module.exports.default = wallpaper; | ||
export const {getWallpaper, setWallpaper, setSolidColorWallpaper, screens} = wallpaper; |
{ | ||
"name": "wallpaper", | ||
"version": "5.0.1", | ||
"version": "6.0.0", | ||
"description": "Manage the desktop wallpaper", | ||
@@ -12,4 +12,6 @@ "license": "MIT", | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=12" | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
}, | ||
@@ -36,5 +38,5 @@ "scripts": { | ||
"devDependencies": { | ||
"ava": "^2.1.0", | ||
"tsd": "^0.15.1", | ||
"xo": "^0.39.0" | ||
"ava": "^3.15.0", | ||
"tsd": "^0.19.0", | ||
"xo": "^0.46.4" | ||
}, | ||
@@ -41,0 +43,0 @@ "ava": { |
@@ -11,5 +11,5 @@ # wallpaper | ||
```sh | ||
npm install wallpaper | ||
``` | ||
$ npm install wallpaper | ||
``` | ||
@@ -19,10 +19,8 @@ ## Usage | ||
```js | ||
const wallpaper = require('wallpaper'); | ||
import {getWallpaper, setWallpaper} from 'wallpaper'; | ||
(async () => { | ||
await wallpaper.set('unicorn.jpg'); | ||
await setWallpaper('unicorn.jpg'); | ||
await wallpaper.get(); | ||
//=> '/Users/sindresorhus/unicorn.jpg' | ||
})(); | ||
await getWallpaper(); | ||
//=> '/Users/sindresorhus/unicorn.jpg' | ||
``` | ||
@@ -32,3 +30,3 @@ | ||
### .get(options?) | ||
### getWallpaper(options?) | ||
@@ -49,5 +47,5 @@ Returns a `Promise<string>` with the path of the current desktop wallpaper. | ||
If you set `'all'` then `.get()` will return a `Promise<string[]>`. | ||
If you set `'all'` then `getWallpaper()` will return a `Promise<string[]>`. | ||
### .set(imagePath, options?) | ||
### setWallpaper(imagePath, options?) | ||
@@ -84,15 +82,4 @@ Returns a `Promise`. | ||
### .screens() *(macOS only)* | ||
### setSolidColorWallpaper(color, options?) *(macOS only)* | ||
Returns a `Promise<string[]>` with the available screens. | ||
```js | ||
(async () => { | ||
await wallpaper.screens(); | ||
//=> ['Color LCD'] | ||
})(); | ||
``` | ||
### .setSolidColor(color, options?) *(macOS only)* | ||
Returns a `Promise`. | ||
@@ -119,7 +106,18 @@ | ||
```js | ||
(async () => { | ||
await wallpaper.setSolidColor('000000'); | ||
})(); | ||
import {setSolidColorWallpaper} from 'wallpaper'; | ||
await setSolidColorWallpaper('000000'); | ||
``` | ||
### screens() *(macOS only)* | ||
Returns a `Promise<string[]>` with the available screens. | ||
```js | ||
import {screens} from 'wallpaper'; | ||
await screens(); | ||
//=> ['Color LCD'] | ||
``` | ||
## FAQ | ||
@@ -126,0 +124,0 @@ |
@@ -1,5 +0,4 @@ | ||
'use strict'; | ||
const {commandExists, execFile, hasLine} = require('../util.js'); | ||
import {commandExists, execFile, hasLine} from '../util.js'; | ||
exports.isAvailable = async () => { | ||
export async function isAvailable() { | ||
if (!await commandExists('gsettings')) { | ||
@@ -15,21 +14,21 @@ return false; | ||
} | ||
}; | ||
} | ||
exports.set = async imagePath => { | ||
await execFile('gsettings', [ | ||
'set', | ||
export async function get() { | ||
const {stdout} = await execFile('gsettings', [ | ||
'get', | ||
'org.cinnamon.desktop.background', | ||
'picture-uri', | ||
`file://${imagePath}` | ||
]); | ||
}; | ||
exports.get = async () => { | ||
const {stdout} = await execFile('gsettings', [ | ||
'get', | ||
return stdout.trim().slice(8, -1); | ||
} | ||
export async function set(imagePath) { | ||
await execFile('gsettings', [ | ||
'set', | ||
'org.cinnamon.desktop.background', | ||
'picture-uri' | ||
'picture-uri', | ||
`file://${imagePath}`, | ||
]); | ||
return stdout.trim().slice(8, -1); | ||
}; | ||
} |
@@ -1,21 +0,22 @@ | ||
'use strict'; | ||
const {commandExists, execFile} = require('../util.js'); | ||
import {commandExists, execFile} from '../util.js'; | ||
exports.isAvailable = () => commandExists('dconf'); | ||
export async function isAvailable() { | ||
return commandExists('dconf'); | ||
} | ||
exports.set = async imagePath => { | ||
await execFile('dconf', [ | ||
'write', | ||
'/org/mate/desktop/background/picture-filename', | ||
`"${imagePath}"` | ||
]); | ||
}; | ||
exports.get = async () => { | ||
export async function get() { | ||
const {stdout} = await execFile('dconf', [ | ||
'read', | ||
'/org/mate/desktop/background/picture-filename' | ||
'/org/mate/desktop/background/picture-filename', | ||
]); | ||
return stdout.trim().slice(1, -1); | ||
}; | ||
} | ||
export async function set(imagePath) { | ||
await execFile('dconf', [ | ||
'write', | ||
'/org/mate/desktop/background/picture-filename', | ||
`"${imagePath}"`, | ||
]); | ||
} |
@@ -1,7 +0,8 @@ | ||
'use strict'; | ||
const {commandExists, execFile} = require('../util.js'); | ||
import {commandExists, execFile} from '../util.js'; | ||
exports.isAvailable = () => commandExists('dcop'); | ||
export async function isAvailable() { | ||
return commandExists('dcop'); | ||
} | ||
exports.set = async imagePath => { | ||
export async function set(imagePath) { | ||
await execFile('dcop', [ | ||
@@ -11,4 +12,4 @@ 'kdesktop', | ||
'setWallpaper', | ||
`${imagePath} 1` | ||
`${imagePath} 1`, | ||
]); | ||
}; | ||
} |
@@ -1,8 +0,9 @@ | ||
'use strict'; | ||
const {commandExists, execFile} = require('../util.js'); | ||
import {commandExists, execFile} from '../util.js'; | ||
exports.isAvailable = () => commandExists('feh'); | ||
export async function isAvailable() { | ||
return commandExists('feh'); | ||
} | ||
exports.set = async imagePath => { | ||
export async function set(imagePath) { | ||
await execFile('feh', ['--bg-fill', imagePath]); | ||
}; | ||
} |
@@ -1,7 +0,8 @@ | ||
'use strict'; | ||
const {commandExists, execFile} = require('../util.js'); | ||
import {commandExists, execFile} from '../util.js'; | ||
exports.isAvailable = () => commandExists('gconftool-2'); | ||
export async function isAvailable() { | ||
return commandExists('gconftool-2'); | ||
} | ||
exports.set = async imagePath => { | ||
export async function set(imagePath) { | ||
await execFile('gconftool-2', [ | ||
@@ -12,4 +13,4 @@ '--set', | ||
'string', | ||
imagePath | ||
imagePath, | ||
]); | ||
}; | ||
} |
@@ -1,23 +0,24 @@ | ||
'use strict'; | ||
const {commandExists, execFile} = require('../util.js'); | ||
import {commandExists, execFile} from '../util.js'; | ||
exports.isAvailable = () => commandExists('gsettings'); | ||
export async function isAvailable() { | ||
return commandExists('gsettings'); | ||
} | ||
exports.set = async imagePath => { | ||
await execFile('gsettings', [ | ||
'set', | ||
export async function get() { | ||
const {stdout} = await execFile('gsettings', [ | ||
'get', | ||
'org.gnome.desktop.background', | ||
'picture-uri', | ||
`file://${imagePath}` | ||
]); | ||
}; | ||
exports.get = async () => { | ||
const {stdout} = await execFile('gsettings', [ | ||
'get', | ||
return stdout.trim().slice(8, -1); | ||
} | ||
export async function set(imagePath) { | ||
await execFile('gsettings', [ | ||
'set', | ||
'org.gnome.desktop.background', | ||
'picture-uri' | ||
'picture-uri', | ||
`file://${imagePath}`, | ||
]); | ||
return stdout.trim().slice(8, -1); | ||
}; | ||
} |
@@ -1,16 +0,12 @@ | ||
'use strict'; | ||
module.exports = { | ||
cinnamon: require('./cinnamon.js'), | ||
dconf: require('./dconf.js'), | ||
dcop: require('./dcop.js'), | ||
feh: require('./feh.js'), | ||
gconftool2: require('./gconftool-2.js'), | ||
gnome: require('./gnome.js'), | ||
mate: require('./mate.js'), | ||
nitrogen: require('./nitrogen.js'), | ||
pcmanfm: require('./pcmanfm.js'), | ||
qdbus: require('./qdbus.js'), | ||
setroot: require('./setroot.js'), | ||
xfconfquery: require('./xfconf-query.js') | ||
}; | ||
export * as cinnamon from './cinnamon.js'; | ||
export * as dconf from './dconf.js'; | ||
export * as dcop from './dcop.js'; | ||
export * as feh from './feh.js'; | ||
export * as gconftool2 from './gconftool-2.js'; | ||
export * as gnome from './gnome.js'; | ||
export * as mate from './mate.js'; | ||
export * as nitrogen from './nitrogen.js'; | ||
export * as pcmanfm from './pcmanfm.js'; | ||
export * as qdbus from './qdbus.js'; | ||
export * as setroot from './setroot.js'; | ||
export * as xfconfquery from './xfconf-query.js'; |
@@ -1,5 +0,4 @@ | ||
'use strict'; | ||
const {commandExists, execFile, hasLine} = require('../util.js'); | ||
import {commandExists, execFile, hasLine} from '../util.js'; | ||
exports.isAvailable = async () => { | ||
export async function isAvailable() { | ||
if (!await commandExists('gsettings')) { | ||
@@ -15,21 +14,21 @@ return false; | ||
} | ||
}; | ||
} | ||
exports.set = async imagePath => { | ||
await execFile('gsettings', [ | ||
'set', | ||
export async function get() { | ||
const {stdout} = await execFile('gsettings', [ | ||
'get', | ||
'org.mate.background', | ||
'picture-filename', | ||
imagePath | ||
]); | ||
}; | ||
exports.get = async () => { | ||
const {stdout} = await execFile('gsettings', [ | ||
'get', | ||
return stdout.trim().slice(1, -1); | ||
} | ||
export async function set(imagePath) { | ||
await execFile('gsettings', [ | ||
'set', | ||
'org.mate.background', | ||
'picture-filename' | ||
'picture-filename', | ||
imagePath, | ||
]); | ||
return stdout.trim().slice(1, -1); | ||
}; | ||
} |
@@ -1,23 +0,23 @@ | ||
'use strict'; | ||
const path = require('path'); | ||
const os = require('os'); | ||
const {commandExists, execFile, readFile} = require('../util.js'); | ||
import path from 'node:path'; | ||
import os from 'node:os'; | ||
import {commandExists, execFile, readFile} from '../util.js'; | ||
const homeDir = os.homedir(); | ||
const homeDirectory = os.homedir(); | ||
exports.isAvailable = () => commandExists('nitrogen'); | ||
export async function isAvailable() { | ||
return commandExists('nitrogen'); | ||
} | ||
exports.set = async imagePath => { | ||
export async function get() { | ||
const configFile = path.join(homeDirectory, '.config/nitrogen/bg-saved.cfg'); | ||
const config = await readFile(configFile, 'utf8'); | ||
return config.trim().split('\n').find(line => line.startsWith('file=')).replace('file=', ''); | ||
} | ||
export async function set(imagePath) { | ||
await execFile('nitrogen', [ | ||
'--set-zoom-fill', | ||
'--save', | ||
imagePath | ||
imagePath, | ||
]); | ||
}; | ||
exports.get = async () => { | ||
const configFile = path.join(homeDir, '.config/nitrogen/bg-saved.cfg'); | ||
const config = await readFile(configFile, 'utf8'); | ||
return config.trim().split('\n').find(line => line.startsWith('file=')).replace('file=', ''); | ||
}; | ||
} |
@@ -1,8 +0,9 @@ | ||
'use strict'; | ||
const {commandExists, execFile} = require('../util.js'); | ||
import {commandExists, execFile} from '../util.js'; | ||
exports.isAvailable = () => commandExists('pcmanfm'); | ||
export async function isAvailable() { | ||
return commandExists('pcmanfm'); | ||
} | ||
exports.set = async imagePath => { | ||
export async function set(imagePath) { | ||
await execFile('pcmanfm', ['--set-wallpaper', imagePath]); | ||
}; | ||
} |
@@ -1,7 +0,8 @@ | ||
'use strict'; | ||
const {commandExists, execFile} = require('../util.js'); | ||
import {commandExists, execFile} from '../util.js'; | ||
exports.isAvailable = () => commandExists('qdbus'); | ||
export async function isAvailable() { | ||
return commandExists('qdbus'); | ||
} | ||
exports.set = async imagePath => { | ||
export async function set(imagePath) { | ||
await execFile('qdbus', [ | ||
@@ -19,4 +20,4 @@ 'org.kde.plasmashell', | ||
} | ||
` | ||
`, | ||
]); | ||
}; | ||
} |
@@ -1,8 +0,9 @@ | ||
'use strict'; | ||
const {commandExists, execFile} = require('../util.js'); | ||
import {commandExists, execFile} from '../util.js'; | ||
exports.isAvailable = () => commandExists('setroot'); | ||
export async function isAvailable() { | ||
return commandExists('setroot'); | ||
} | ||
exports.set = async imagePath => { | ||
export async function set(imagePath) { | ||
await execFile('setroot', [imagePath]); | ||
}; | ||
} |
@@ -1,7 +0,8 @@ | ||
'use strict'; | ||
const {commandExists, execFile} = require('../util.js'); | ||
import {commandExists, execFile} from '../util.js'; | ||
exports.isAvailable = () => commandExists('xfconf-query'); | ||
export async function isAvailable() { | ||
return commandExists('xfconf-query'); | ||
} | ||
exports.set = async imagePath => { | ||
export async function set(imagePath) { | ||
await execFile('xfconf-query', [ | ||
@@ -13,4 +14,4 @@ '--channel', | ||
'--set', | ||
`${imagePath}` | ||
`${imagePath}`, | ||
]); | ||
}; | ||
} |
@@ -1,4 +0,3 @@ | ||
'use strict'; | ||
const path = require('path'); | ||
const managers = require('./background-managers/index.js'); | ||
import path from 'node:path'; | ||
import * as managers from './background-managers/index.js'; | ||
@@ -19,6 +18,6 @@ let availableApps; | ||
exports.get = async () => { | ||
export async function getWallpaper() { | ||
if (!availableApps) { | ||
await setAvailableApps(); | ||
return exports.get(); | ||
return getWallpaper(); | ||
} | ||
@@ -56,5 +55,5 @@ | ||
return wallpaperMostVoted; | ||
}; | ||
} | ||
exports.set = async imagePath => { | ||
export async function setWallpaper(imagePath) { | ||
if (typeof imagePath !== 'string') { | ||
@@ -66,3 +65,3 @@ throw new TypeError('Expected a string'); | ||
await setAvailableApps(); | ||
await exports.set(imagePath); | ||
await setWallpaper(imagePath); | ||
return; | ||
@@ -77,3 +76,3 @@ } | ||
await Promise.all(promises.map(promise => promise.catch(() => {}))); | ||
}; | ||
await Promise.allSettled(promises); | ||
} |
@@ -1,12 +0,12 @@ | ||
'use strict'; | ||
const {promisify} = require('util'); | ||
const childProcess = require('child_process'); | ||
const fs = require('fs'); | ||
import {promisify} from 'node:util'; | ||
import childProcess from 'node:child_process'; | ||
import {promises as fsPromises} from 'node:fs'; | ||
const execFile = promisify(childProcess.execFile); | ||
export const execFile = promisify(childProcess.execFile); | ||
export const exec = promisify(childProcess.exec); | ||
exports.commandExists = async cmd => { | ||
export async function commandExists(command) { | ||
// `which` all commands and expect stdout to return a positive | ||
try { | ||
let {stdout} = await execFile('which', ['-a', cmd]); | ||
let {stdout} = await execFile('which', ['-a', command]); | ||
stdout = stdout.trim(); | ||
@@ -22,8 +22,8 @@ | ||
} | ||
}; | ||
} | ||
exports.hasLine = (string, lineToFind) => string.split('\n').find(line => line.trim() === lineToFind); | ||
export function hasLine(string, lineToFind) { | ||
return string.split('\n').find(line => line.trim() === lineToFind); | ||
} | ||
exports.execFile = execFile; | ||
exports.exec = promisify(childProcess.exec); | ||
exports.readFile = promisify(fs.readFile); | ||
export const {readFile} = fsPromises; |
@@ -1,6 +0,7 @@ | ||
'use strict'; | ||
const {promisify} = require('util'); | ||
const path = require('path'); | ||
const childProcess = require('child_process'); | ||
import {promisify} from 'node:util'; | ||
import childProcess from 'node:child_process'; | ||
import path from 'node:path'; | ||
import {fileURLToPath} from 'node:url'; | ||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
const execFile = promisify(childProcess.execFile); | ||
@@ -11,3 +12,3 @@ | ||
exports.get = async ({screen = 'main'} = {}) => { | ||
export async function getWallpaper({screen = 'main'} = {}) { | ||
let {stdout} = await execFile(binary, ['get', '--screen', screen]); | ||
@@ -21,5 +22,5 @@ stdout = stdout.trim(); | ||
return stdout; | ||
}; | ||
} | ||
exports.set = async (imagePath, {screen = 'all', scale = 'auto'} = {}) => { | ||
export async function setWallpaper(imagePath, {screen = 'all', scale = 'auto'} = {}) { | ||
if (typeof imagePath !== 'string') { | ||
@@ -35,9 +36,9 @@ throw new TypeError('Expected a string'); | ||
'--scale', | ||
scale | ||
scale, | ||
]; | ||
await execFile(binary, arguments_); | ||
}; | ||
} | ||
exports.setSolidColor = async (color, {screen = 'all'} = {}) => { | ||
export async function setSolidColorWallpaper(color, {screen = 'all'} = {}) { | ||
if (typeof color !== 'string') { | ||
@@ -51,11 +52,11 @@ throw new TypeError('Expected a string'); | ||
'--screen', | ||
screen | ||
screen, | ||
]; | ||
await execFile(binary, arguments_); | ||
}; | ||
} | ||
exports.screens = async () => { | ||
export async function screens() { | ||
const {stdout} = await execFile(binary, ['screens']); | ||
return stdout.trim().split('\n').map(line => line.replace(/^\d+ - /, '')); | ||
}; | ||
} |
@@ -1,6 +0,7 @@ | ||
'use strict'; | ||
const {promisify} = require('util'); | ||
const path = require('path'); | ||
const childProcess = require('child_process'); | ||
import {promisify} from 'node:util'; | ||
import childProcess from 'node:child_process'; | ||
import path from 'node:path'; | ||
import {fileURLToPath} from 'node:url'; | ||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
const execFile = promisify(childProcess.execFile); | ||
@@ -11,8 +12,8 @@ | ||
exports.get = async () => { | ||
export async function getWallpaper() { | ||
const {stdout} = await execFile(binary); | ||
return stdout.trim(); | ||
}; | ||
} | ||
exports.set = async imagePath => { | ||
export async function setWallpaper(imagePath) { | ||
if (typeof imagePath !== 'string') { | ||
@@ -23,2 +24,2 @@ throw new TypeError('Expected a string'); | ||
await execFile(binary, [path.resolve(imagePath)]); | ||
}; | ||
} |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
0
Yes
2106959
429
139