Browse Source

Merge pull request #6 from TheReverend403/dmenu_from_env

Add support for setting dmenu path.
master
Andrew Kaiser 6 years ago
committed by GitHub
parent
commit
8e337cbeb9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions
  1. +2
    -0
      README.md
  2. +2
    -0
      bin/cli.js
  3. +4
    -1
      src/exec-dmenu.js

+ 2
- 0
README.md View File

@ -13,6 +13,8 @@ clipboard.
$ bitwarden-dmenu --help $ bitwarden-dmenu --help
Usage: bitwarden-dmenu [options] Usage: bitwarden-dmenu [options]
The DMENU_PATH environment variable can be used to point to an alternative dmenu implementation. Defaults to 'dmenu'.
Options: Options:
--clear-clipboard Number of seconds to keep selected field in the clipboard. --clear-clipboard Number of seconds to keep selected field in the clipboard.
Defaults to 15s. Defaults to 15s.


+ 2
- 0
bin/cli.js View File

@ -15,6 +15,8 @@ if (args.help) {
console.log( console.log(
`Usage: bitwarden-dmenu [options] `Usage: bitwarden-dmenu [options]
The DMENU_PATH environment variable can be used to point to an alternative dmenu implementation. Defaults to 'dmenu'.
Options: Options:
--clear-clipboard Number of seconds to keep selected field in the clipboard. --clear-clipboard Number of seconds to keep selected field in the clipboard.
Defaults to ${cachePasswordDefault}s. Defaults to ${cachePasswordDefault}s.


+ 4
- 1
src/exec-dmenu.js View File

@ -1,11 +1,14 @@
const { exec } = require('child_process') const { exec } = require('child_process')
const dmenuPath = process.env.DMENU_PATH || 'dmenu'
module.exports = (...args) => choices => module.exports = (...args) => choices =>
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
let choice = '' let choice = ''
const error = [] const error = []
const execCommand = `dmenu ${args}`
// Use a default of 'dmenu' if not specified in process.env
const execCommand = `${dmenuPath} ${args}`
console.debug('$', execCommand) console.debug('$', execCommand)
const dmenu = exec(execCommand) const dmenu = exec(execCommand)
dmenu.stdin.write(choices) dmenu.stdin.write(choices)


Loading…
Cancel
Save