1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2026-01-04 09:33:30 +00:00

Updated to support wallpaper changes with gsettings

This commit is contained in:
Bryan Roe
2019-11-14 11:28:02 -08:00
parent cc59f186ca
commit 0333f124ae
2 changed files with 47 additions and 2 deletions

View File

@@ -30,9 +30,54 @@ function gnome_getProxySettings(uid)
}
}
function gnome_getDesktopWallpaper(uid)
{
var child = require('child_process').execFile('/bin/sh', ['sh'], { env: { HOME: require('user-sessions').getHomeFolder(uid) } });
child.stderr.str = ''; child.stderr.on('data', function (c) { });
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdin.write('gsettings get org.gnome.desktop.background picture-uri\nexit\n');
child.waitExit();
child.stdout.str = child.stdout.str.trim().split('file://').pop();
if (child.stdout.str.endsWith('"') || child.stdout.str.endsWith("'"))
{
return (child.stdout.str.substring(0, child.stdout.str.length - 1));
}
else
{
return (child.stdout.str);
}
}
function gnome_setDesktopWallpaper(uid, filePath)
{
if (!filePath) { filePath = '/dev/null'; }
var child = require('child_process').execFile('/bin/sh', ['sh'], { env: { HOME: require('user-sessions').getHomeFolder(uid) } });
child.stderr.str = ''; child.stderr.on('data', function (c) { });
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdin.write('gsettings set org.gnome.desktop.background picture-uri file://' + filePath + '\nexit\n');
child.waitExit();
}
switch(process.platform)
{
case 'linux':
module.exports = { getProxySettings: gnome_getProxySettings }
module.exports =
{
getProxySettings: gnome_getProxySettings,
getDesktopWallpaper: gnome_getDesktopWallpaper,
setDesktopWallpaper: gnome_setDesktopWallpaper
};
Object.defineProperty(module.exports, '_location', {
value: (function ()
{
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = '';
child.stdout.on('data', function (chunk) { this.str += chunk.toString(); });
child.stdin.write("whereis gsettings | awk '{ print $2 }'\nexit\n");
child.waitExit();
return (child.stdout.str.trim());
})()
});
Object.defineProperty(module.exports, 'available', { get: function () { return (this._location!='' ? true : false); } });
break;
}