Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for nitrogen on linux #17

Merged
merged 11 commits into from
Jun 8, 2017
34 changes: 22 additions & 12 deletions lib/linux.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ const pify = require('pify');
const cp = pify(childProcess);

const appsList = [
{
cmd: 'gsettings',
set: ['set',
'org.cinnamon.desktop.background',
'picture-uri',
'file://%s'
],
get: ['get',
'org.cinnamon.desktop.background',
'picture-uri'
]
},
{
cmd: 'gsettings',
set: ['set',
Expand All @@ -31,6 +43,12 @@ const appsList = [
cmd: 'feh',
set: ['--bg-scale', '%s']
},
{
cmd: 'nitrogen',
set: ['--set-zoom-fill', '--save', '%s'],
get: ['-n', 's/^file=//p', `${process.env.HOME}/.config/nitrogen/bg-saved.cfg`],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a long flag for -n? If yes, use that instead.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use require('os').homedir() instead of the environment variable. Should also use path.join.

transform: imagePath => imagePath.trim().split('\n').slice(-1)[0]
},
{
cmd: 'xfconf-query',
set: ['-c xfce4-desktop',
Expand Down Expand Up @@ -63,18 +81,6 @@ const appsList = [
'/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'
]
}
];

Expand Down Expand Up @@ -124,6 +130,10 @@ exports.get = function get() {

const app = availableApps.find(app => app.get);

if (/nitrogen/.test(app.cmd)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (app.cmd === 'nitrogen') {

app.cmd = '/bin/sed';
}

return cp.execFile(app.cmd, app.get).then(stdout => {
stdout = stdout.trim();

Expand Down