Skip to content

Commit

Permalink
Update main.js
Browse files Browse the repository at this point in the history
Adds support for XDG spec
  • Loading branch information
ProfessorManhattan authored and hackjutsu committed Jun 21, 2023
1 parent 9fac0fe commit ce1d8fb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ initGlobalLogger()

logger.info(`\n\n----- ${appInfo.name} v${appInfo.version} ${os.platform()}-----\n`)

logger.info(`[conf] Looking for .leptonrc at ${ path.join(app.getPath('home'), '.leptonrc') }`)
logger.info(`[conf] Looking for .leptonrc at ${getConfigPath()}`)
logger.info('[conf] The resolved configuration is ...')
for (const key of Object.getOwnPropertyNames(defaultConfig)) {
logger.info(`"${key}": ${JSON.stringify(nconf.get(key))}`)
Expand All @@ -42,6 +42,14 @@ let operationType = 0;

const shortcuts = nconf.get('shortcuts')

function getConfigPath() {
if (process && process.env && process.env.XDG_CONFIG_HOME) {
return path.join(process.env.XDG_CONFIG_HOME, '.leptonrc'
} else {
return path.join(app.getPath('home'), '.leptonrc')
}
}

function createWindowAndAutoLogin () {
createWindow(true)
}
Expand Down Expand Up @@ -343,7 +351,7 @@ function setUpTouchBar() {
}

function initGlobalConfigs () {
const configFilePath = path.join(app.getPath('home'), '.leptonrc')
const configFilePath = getConfigPath()
logger.info(`[conf] Looking for .leptonrc at ${configFilePath}`)
nconf.argv().env()
try {
Expand Down

0 comments on commit ce1d8fb

Please sign in to comment.