Last active
January 9, 2021 17:53
-
-
Save stefanocudini/0a7c06c202e6a61ddd8e67430717c023 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
set windows border width to Linux Unbuntu as window manager: metacity,marco | |
usage(run by root): | |
$ npm i cheerio | |
$ sudo wget -O- https://gist.githubusercontent.com/stefanocudini/0a7c06c202e6a61ddd8e67430717c023/raw/df8d9d8da9d9dce5a4af7c45e18b3e2280e9c184/ubuntu-windows-border-width.js | nodejs | |
*/ | |
const cp = require('child_process'); | |
const fs = require('fs'); | |
const cheerio = require('cheerio'); | |
//const FIN='./metacity-theme-1.xml'; | |
const FIN = process.argv[2] || '/usr/share/themes/Ambiant-MATE/metacity-1/metacity-theme-1.xml'; | |
const W = process.argv[3] || 10; | |
var out = cp.execSync('gsettings get org.gnome.desktop.interface gtk-theme'), | |
themeName = out.toString().trim().replace(/'/g,''); | |
console.log('current theme',themeName); | |
if(!fs.existsSync(FIN)) { | |
fs.copyFile(FIN, FIN+'.save', (err) => { | |
if (err) throw err; | |
console.log('backup:',FIN); | |
}); | |
} | |
const $ = cheerio.load(fs.readFileSync(FIN), { | |
//normalizeWhitespace: false, | |
xmlMode: true | |
}); | |
var tags = $("metacity_theme frame_geometry[name='frame_geometry_normal'] > distance"); | |
const names = [ | |
"left_width", | |
"right_width", | |
"bottom_height" | |
]; | |
tags.each(function() { | |
var name = $(this).attr('name'), | |
val = $(this).attr('value'); | |
if(names.indexOf(name)>-1) { | |
console.log('replace', name, val, 'with value', W); | |
$(this).attr('value', W); | |
} | |
}); | |
fs.writeFile(FIN, $.xml(), (err)=> { | |
if(err) { | |
throw err | |
console.log('ERROR to apply changes') | |
} | |
else { | |
var child = cp.spawn('marco', ['--replace','--no-composite'], { | |
detached: true | |
}); | |
child.unref(); | |
process.exit(0) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment