Skip to content

Instantly share code, notes, and snippets.

@harish2704
Created April 7, 2016 13:45
Show Gist options
  • Save harish2704/5bcf6c33ba3713ffef3a92a0d6131edc to your computer and use it in GitHub Desktop.
Save harish2704/5bcf6c33ba3713ffef3a92a0d6131edc to your computer and use it in GitHub Desktop.
var HOME = process.env.HOME;
var CONFIG_DIR = `${HOME}/.config/chromium/`;
var fs = require('fs');
function listProfileDirs( ){
return fs.readdirSync( CONFIG_DIR ).filter( ( dirName) => {
return dirName.match( 'Profile ' );
})
}
function getProfileName( dirName ){
var prefs = fs.readFileSync( `${CONFIG_DIR}/${dirName}/Preferences` );
prefs = JSON.parse( prefs );
return prefs.profile.name;
}
function getNamePathMap( ){
return listProfileDirs().map( (v) =>{
return {
name: getProfileName( v ),
path: v,
}});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment