From 524bf102a6b7c514a87bfda28037049352a251a6 Mon Sep 17 00:00:00 2001 From: Lee Watson Date: Mon, 1 Oct 2018 14:20:52 +0100 Subject: [PATCH 1/4] Add support for setting dmenu path. Allows users to configure the path to dmenu with the `DMENU_PATH` env variable to allow support for drop-in alternatives like rofi. --- src/exec-dmenu.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/exec-dmenu.js b/src/exec-dmenu.js index 18e669c..8089cea 100644 --- a/src/exec-dmenu.js +++ b/src/exec-dmenu.js @@ -3,9 +3,12 @@ const { exec } = require('child_process') module.exports = (...args) => choices => new Promise((resolve, reject) => { let choice = '' + let dmenu_path = process.env.DMENU_PATH const error = [] - const execCommand = `dmenu ${args}` + // Use a default of 'dmenu' if not specified in process.env + const dmenu_binary = (typeof dmenu_path === 'undefined') ? 'dmenu' : dmenu_path; + const execCommand = `${dmenu_binary} ${args}` console.debug('$', execCommand) const dmenu = exec(execCommand) dmenu.stdin.write(choices) From 1cfed42cac9fef58d48c83ca0aafe14c577570bb Mon Sep 17 00:00:00 2001 From: Lee Watson Date: Tue, 2 Oct 2018 13:28:08 +0100 Subject: [PATCH 2/4] Move dmenuPath outside the function declaration and use camelCase like the rest of the project. --- src/exec-dmenu.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/exec-dmenu.js b/src/exec-dmenu.js index 8089cea..c820851 100644 --- a/src/exec-dmenu.js +++ b/src/exec-dmenu.js @@ -1,5 +1,7 @@ const { exec } = require('child_process') +const dmenuPath = process.env.DMENU_PATH || 'dmenu' + module.exports = (...args) => choices => new Promise((resolve, reject) => { let choice = '' @@ -7,8 +9,7 @@ module.exports = (...args) => choices => const error = [] // Use a default of 'dmenu' if not specified in process.env - const dmenu_binary = (typeof dmenu_path === 'undefined') ? 'dmenu' : dmenu_path; - const execCommand = `${dmenu_binary} ${args}` + const execCommand = `${dmenuPath} ${args}` console.debug('$', execCommand) const dmenu = exec(execCommand) dmenu.stdin.write(choices) From 5dd7ff5b34624bc573e3ccf509e777c036d934dc Mon Sep 17 00:00:00 2001 From: Lee Watson Date: Tue, 2 Oct 2018 13:32:39 +0100 Subject: [PATCH 3/4] Document DMENU_PATH --- README.md | 2 ++ bin/cli.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index 3041316..a477bb1 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ clipboard. $ bitwarden-dmenu --help Usage: bitwarden-dmenu [options] +The DMENU_PATH environment variable can be used to point to an alternative dmenu implementation. Defaults to 'dmenu'. + Options: --clear-clipboard Number of seconds to keep selected field in the clipboard. Defaults to 15s. diff --git a/bin/cli.js b/bin/cli.js index 5e37a20..a9851da 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -15,6 +15,8 @@ if (args.help) { console.log( `Usage: bitwarden-dmenu [options] +The DMENU_PATH environment variable can be used to point to an alternative dmenu implementation. Defaults to 'dmenu'. + Options: --clear-clipboard Number of seconds to keep selected field in the clipboard. Defaults to ${cachePasswordDefault}s. From ee3e7cf458ad3cc1035fd2e566f0681b12893455 Mon Sep 17 00:00:00 2001 From: Lee Watson Date: Tue, 2 Oct 2018 15:57:00 +0100 Subject: [PATCH 4/4] Remove unused dmenu_path --- src/exec-dmenu.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/exec-dmenu.js b/src/exec-dmenu.js index c820851..c1faa7e 100644 --- a/src/exec-dmenu.js +++ b/src/exec-dmenu.js @@ -5,7 +5,6 @@ const dmenuPath = process.env.DMENU_PATH || 'dmenu' module.exports = (...args) => choices => new Promise((resolve, reject) => { let choice = '' - let dmenu_path = process.env.DMENU_PATH const error = [] // Use a default of 'dmenu' if not specified in process.env