Socket
Socket
Sign inDemoInstall

wallpaper

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wallpaper - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

2

index.js

@@ -8,3 +8,3 @@ 'use strict';

} else {
module.exports = require('pify').all(require('./lib/linux'));
module.exports = require('./lib/linux');
}
'use strict';
const path = require('path');
const childProcess = require('child_process');
const pify = require('pify');
const cp = pify.all(childProcess);

@@ -17,18 +19,15 @@ const appsList = [

],
transform: imagePath => imagePath.trim().slice(8, -1)
transform: imagePath => imagePath.slice(8, -1)
},
{
cmd: 'setroot',
set: ['%s'],
get: null
set: ['%s']
},
{
cmd: 'pcmanfm',
set: ['-w %s'],
get: null
set: ['-w %s']
},
{
cmd: 'feh',
set: ['--bg-scale', '%s'],
get: null
set: ['--bg-scale', '%s']
},

@@ -40,4 +39,3 @@ {

'-s %s'
],
get: null
]
},

@@ -50,4 +48,3 @@ {

'%s'
],
get: null
]
},

@@ -60,4 +57,3 @@ {

'%s 1'
],
get: null
]
},

@@ -72,3 +68,3 @@ {

],
transform: imagePath => imagePath.trim().slice(1, -1)
transform: imagePath => imagePath.slice(1, -1)
}

@@ -79,4 +75,5 @@ ];

function setAvailableApps(cb) {
function setAvailableApps() {
const availableAppsDict = {};
availableApps = [];

@@ -92,3 +89,5 @@

childProcess.exec(whichCmd, (err, stdout) => {
return cp.exec(whichCmd).then(stdout => {
stdout = stdout.trim();
if (!stdout) {

@@ -100,3 +99,3 @@ throw new Error('None of the apps were found');

// and only the executable name. i.e. 'foo' from /bin/foo
stdout = stdout.trim().split('\n');
stdout = stdout.split('\n');

@@ -113,62 +112,38 @@ stdout.forEach(el => {

});
cb(availableApps);
});
}
exports.get = function get(cb) {
exports.get = function get() {
if (!availableApps) {
return setAvailableApps(() => {
get(cb);
});
return setAvailableApps().then(get);
}
cb = cb || function () {};
const app = availableApps.find(app => app.get);
let found = false;
return cp.execFile(app.cmd, app.get).then(stdout => {
stdout = stdout.trim();
availableApps.forEach(app => {
if (!app.get || found) {
return;
if (typeof app.transform === 'function') {
return app.transform(stdout);
}
childProcess.execFile(app.cmd, app.get, (err, stdout) => {
if (err || !stdout || found) {
return;
}
found = true;
if (typeof app.transform === 'function') {
stdout = app.transform(stdout);
}
cb(null, stdout);
});
return stdout;
});
};
exports.set = function set(imagePath, cb) {
exports.set = function set(imagePath) {
if (typeof imagePath !== 'string') {
throw new TypeError('Expected a string');
return Promise.reject(new TypeError('Expected a string'));
}
if (!availableApps) {
return setAvailableApps(() => set(imagePath, cb));
return setAvailableApps().then(() => set(imagePath));
}
cb = cb || function () {};
const app = availableApps.find(app => app.set);
const params = app.set.slice();
imagePath = path.resolve(imagePath);
params[params.length - 1] = params[params.length - 1].replace('%s', path.resolve(imagePath));
availableApps.forEach(app => {
if (!app.set) {
return;
}
const params = JSON.parse(JSON.stringify(app.set));
params[params.length - 1] = params[params.length - 1].replace('%s', imagePath);
childProcess.execFile(app.cmd, params, err => cb(err));
});
return cp.execFile(app.cmd, params);
};
{
"name": "wallpaper",
"version": "2.0.0",
"version": "2.1.0",
"description": "Get or set the desktop wallpaper",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc