Browse Source

ensure error command is executed, detail readme

master
Andrew Kaiser 6 years ago
parent
commit
d9a0a899c2
3 changed files with 48 additions and 21 deletions
  1. +29
    -12
      README.md
  2. +14
    -8
      bin/cli.js
  3. +5
    -1
      package.json

+ 29
- 12
README.md View File

@ -1,18 +1,12 @@
# bitwarden-dmenu
[bitwarden](https://bitwarden.com/) client using dmenu
[![node](https://img.shields.io/node/v/bitwarden-dmenu.svg)](http://npmjs.com/package/bitwarden-dmenu)
[![GitHub](https://img.shields.io/github/license/andykais/bitwarden-dmenu.svg)](https://github.com/andykais/bitwarden-dmenu/blob/master/LICENSE)
## Depends on
- [dmenu](https://tools.suckless.org/dmenu/)
- [bitwarden-cli](https://help.bitwarden.com/article/cli/)
## Installation
```bash
# login with bitwarden-cli once before using bitwarden-dmenu
bw login
# install the cli
npm i -g bitwarden-dmenu
```
dmenu for [bitwarden](https://bitwarden.com/) which can copy usernames, passwords, and various fields to your
clipboard.
## Usage
```
@ -26,6 +20,29 @@ Options:
without providing a password again. Defaults to 0s.
--sync-vault-after Number of seconds allowable between last bitwarden sync and
current time. Defaults to 0s.
--on-error Arbitrary command to run if the program fails. Defaults to none.
--on-error Arbitrary command to run if the program fails. The thrown error
is piped to the given command. Defaults to none.
```
By default, this program runs at its most secure. No session is stored for any time period, the vault is updated
every time it is used, and the clipboard is cleared every 15 seconds. In reality, you may want something a
little more lenient. Here is the command I use in my personal i3wm config.
```bash
bitwarden-dmenu --clear-clipboard 30 --session-timeout 100 --sync-vault-after 3600 --on-error 'xargs notify-send --urgency=low'
```
## Installation
```bash
# login with bitwarden-cli once before using bitwarden-dmenu
bw login
# install the cli
npm i -g bitwarden-dmenu
```
## Depends on
- [dmenu](https://tools.suckless.org/dmenu/)
- [bitwarden-cli](https://help.bitwarden.com/article/cli/)
## Credits
Inspired by the no longer maintained [keepass-dmenu](https://github.com/gustavnikolaj/keepass-dmenu)

+ 14
- 8
bin/cli.js View File

@ -22,7 +22,8 @@ Options:
without providing a password again. Defaults to ${sessionTimeoutDefault}s.
--sync-vault-after Number of seconds allowable between last bitwarden sync and
current time. Defaults to ${syncVaultAfterDefault}s.
--on-error Arbitrary command to run if the program fails. Defaults to none.
--on-error Arbitrary command to run if the program fails. The thrown error
is piped to the given command. Defaults to none.
`
)
process.exit()
@ -46,18 +47,23 @@ menu({ saveSession, sessionFile, oldestAllowedVaultSync })
})
)
.catch(e => {
console.log(e)
console.error(e)
// if something goes wrong, immediately clear the clipboard & lock bitwarden,
// then run error command
scheduleCleanup({
lockBitwardenAfter: 0,
clearClipboardAfter: 0,
sessionFile
}).then(() => {
if (onErrorCommand) {
const errorCommand = exec(onErrorCommand)
errorCommand.stdin.write(`'${e.toString()}'`)
errorCommand.stdin.end()
}
})
.catch(e => {
// simply log a secondary error
console.error(e)
})
.then(() => {
if (onErrorCommand) {
const errorCommand = exec(onErrorCommand)
errorCommand.stdin.write(`'${e.toString()}'`)
errorCommand.stdin.end()
}
})
})

+ 5
- 1
package.json View File

@ -1,12 +1,16 @@
{
"name": "bitwarden-dmenu",
"version": "1.0.0",
"version": "1.0.1",
"description": "",
"keywords": [
"bitwarden",
"cli",
"dmenu"
],
"repository": {
"type": "git",
"url": "https://github.com/andykais/bitwarden-dmenu.git"
},
"license": "MIT",
"author": "Andrew Kaiser",
"main": "index.js",


Loading…
Cancel
Save