Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.4.0 to 2.5.0

99

lib/linux.js
'use strict';
const path = require('path');
const homeDir = require('os').homedir();
const childProcess = require('child_process');
const fileSystem = require('fs');
const pify = require('pify');
const cp = pify(childProcess);
const fs = pify(fileSystem);

@@ -11,3 +14,4 @@ const appsList = [

cmd: 'gsettings',
set: ['set',
set: [
'set',
'org.gnome.desktop.background',

@@ -17,3 +21,4 @@ 'picture-uri',

],
get: ['get',
get: [
'get',
'org.gnome.desktop.background',

@@ -37,2 +42,8 @@ 'picture-uri'

{
cmd: 'nitrogen',
set: ['--set-zoom-fill', '--save', '%s'],
get: [],
transform: imagePath => imagePath.trim().split('\n').slice(-1)[0]
},
{
cmd: 'xfconf-query',

@@ -64,3 +75,4 @@ set: ['-c xfce4-desktop',

'/org/mate/desktop/background/picture-filename',
'"%s"'],
'"%s"'
],
get: ['read',

@@ -70,14 +82,2 @@ '/org/mate/desktop/background/picture-filename'

transform: imagePath => imagePath.slice(1, -1)
},
{
cmd: 'gsettings',
set: ['set',
'org.cinnamon.desktop.background',
'picture-uri',
'file://%s'
],
get: ['get',
'org.cinnamon.desktop.background',
'picture-uri'
]
}

@@ -108,3 +108,3 @@ ];

// it may return aliases so we only want the real path
// It may return aliases so we only want the real path
// and only the executable name. i.e. 'foo' from /bin/foo

@@ -114,3 +114,3 @@ stdout = stdout.split('\n');

stdout.forEach(el => {
// it's an alias
// It's an alias
if (el[0] !== path.sep) {

@@ -127,2 +127,18 @@ return;

function isCinnamon() {
const args = ['writable', 'org.cinnamon.desktop.background', 'picture-uri'];
return cp.execFile('gsettings', args)
.then(out => out.trim() === 'true')
.catch(() => {});
}
function isMATE() {
const args = ['writable', 'org.mate.background', 'picture-filename'];
return cp.execFile('gsettings', args)
.then(out => out.trim() === 'true')
.catch(() => {});
}
exports.get = function get() {

@@ -135,2 +151,35 @@ if (!availableApps) {

if (app.cmd === 'nitrogen') {
const configFile = path.join(homeDir, '.config/nitrogen/bg-saved.cfg');
return fs.readFile(configFile, 'utf8').then(config =>
config.trim().split('\n').find(line => line.startsWith('file=')).replace('file=', '')
);
}
if (app.cmd === 'gsettings') {
const getArgs = app.get.slice();
return isCinnamon()
.then(cinnamon => {
if (cinnamon) {
getArgs[1] = 'org.cinnamon.desktop.background';
}
})
.then(() => isMATE())
.then(mate => {
if (mate) {
getArgs.splice(1, 2, 'org.mate.background', 'picture-filename');
}
})
.then(() => cp.execFile(app.cmd, getArgs))
.then(stdout => {
stdout = stdout.trim();
if (typeof app.transform === 'function') {
return app.transform(stdout);
}
return stdout;
});
}
return cp.execFile(app.cmd, app.get).then(stdout => {

@@ -161,3 +210,19 @@ stdout = stdout.trim();

if (app.cmd === 'gsettings') {
return isCinnamon()
.then(cinnamon => {
if (cinnamon) {
params[1] = 'org.cinnamon.desktop.background';
}
})
.then(() => isMATE())
.then(mate => {
if (mate) {
params.splice(1, 3, 'org.mate.background', 'picture-filename', params[3].replace(/^file:\/\//, ''));
}
})
.then(() => cp.execFile(app.cmd, params));
}
return cp.execFile(app.cmd, params);
};

2

package.json
{
"name": "wallpaper",
"version": "2.4.0",
"version": "2.5.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