Skip to content

Commit 7cb8386

Browse files
committed
Refactor and update docs and add Makefile
1 parent 25fa30f commit 7cb8386

9 files changed

+701
-301
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2021 Scott Hansen <firecat four one five three at gmail dot com>
3+
Copyright (c) 2022 Scott Hansen <firecat four one five three at gmail dot com>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Makefile

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
VENV = venv
2+
PYTHON = $(VENV)/bin/python
3+
PIP = $(VENV)/bin/pip
4+
5+
all: venv
6+
7+
$(VENV)/bin/activate: requirements.txt
8+
python3 -m venv $(VENV)
9+
$(PIP) install -U pip wheel
10+
$(PIP) install .
11+
12+
venv: $(VENV)/bin/activate
13+
14+
run: venv
15+
$(VENV)/bin/bwm
16+
17+
clean:
18+
rm -rf __pycache__
19+
rm -rf $(VENV)
20+
21+
man: bwm.1.md
22+
pandoc bwm.1.md -s -t man -o bwm.1
23+
24+
test: venv
25+
$(PYTHON) tests/tests.py
26+
27+
.PHONY: all venv run clean

README.md

+58-128
Original file line numberDiff line numberDiff line change
@@ -1,166 +1,96 @@
11
# Bitwarden-menu
22

3-
Dmenu/Rofi frontend for managing Bitwarden vault using the [Bitwarden
4-
CLI](https://bitwarden.com/help/article/cli/) tool.
3+
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/bitwarden-menu)
4+
![PyPI](https://img.shields.io/pypi/v/bitwarden-menu)
5+
![GitHub contributors](https://img.shields.io/github/contributors/firecat53/bitwarden-menu)
6+
7+
Dmenu/Rofi frontend for managing Bitwarden vaults. Uses the [Bitwarden
8+
CLI](https://bitwarden.com/help/article/cli/) tool to interact with the
9+
Bitwarden database.
510

611
This project is not associated with the Bitwarden project nor 8bit Solutions
712
LLC.
813

14+
## Installation
15+
16+
`pip install --user bitwarden-menu`
17+
18+
Ensure `~/.local/bin` is in your `$PATH`. Run `bwm` and enter your database
19+
path, keyfile path, and password.
20+
21+
For full installation documention see the [installation docs][docs/install.md].
22+
23+
## Full Documentation
24+
25+
[Installation](docs/install.md) - [Configuration](docs/configure.md) - [Usage](docs/usage.md)
26+
27+
## Requirements
28+
29+
1. Python 3.7+
30+
2. [Bitwarden CLI][bwcli]. Ensure the `bw` command is in `$PATH`
31+
3. [Pynput][pynput]
32+
4. Dmenu, [Rofi][rofi] or [Bemenu][bemenu]
33+
5. (optional) Pinentry.
34+
6. (optional) xdotool or ydotool (for Wayland).
35+
936
## Features
1037

38+
- Supports [bitwarden.com](https://bitwarden.com) and self-hosted
39+
[Vaultwarden](https://github.com/dani-garcia/vaultwarden) accounts.
1140
- Auto-type username and/or password on selection. No clipboard copy/paste
1241
involved.
13-
- Login with 2FA code from Authenticator(TOTP), Email, or Yubikey (only these
14-
are supported by the Bitwarden CLI).
15-
- Select any single field and have it typed into the active window. Notes fields
16-
can be viewed line-by-line from within dmenu and the selected line will be
17-
typed when selected.
18-
- Open the URL in the default web browser from the View/Type menu.
19-
- Alternate keyboard languages and layouts supported via xdotool or ydotool (for
20-
Wayland)
21-
- Edit entry title, username, URL and password (manually typed or auto-generate)
22-
- Edit notes using terminal or gui editor (set in config.ini, or uses $EDITOR)
42+
- Supports login with 2FA code from Authenticator(TOTP), Email, or Yubikey.
43+
- Background process allows selectable time-out for locking the database.
44+
- Use a custom [Keepass 2.x style auto-type sequence][6].
45+
- Type, view or edit any field.
46+
- Open the URL in the default web browser.
47+
- Non U.S. English keyboard languages and layouts supported via xdotool or
48+
ydotool (for Wayland).
49+
- Edit notes using terminal or gui editor.
2350
- Add and Delete entries
2451
- Rename, move, delete and add folders and collections
25-
- Move any item to or from an organization, including support for multiple collections.
26-
- Prompts for and saves initial server URL and login email
27-
- Define multiple vault URLs in the config file.
52+
- Move any item to or from an organization, including support for multiple
53+
collections.
2854
- Hide selected folders from the default and 'View/Type Individual entries'
2955
views.
30-
- Configure session timeout
56+
- Define multiple vault URLs in the config file.
3157
- Configure the characters and groups of characters used during password
32-
generation in the config file (see config.ini.example for instructions).
33-
Multiple character sets can be selected on the fly when using Rofi if the
34-
`-multi-select` option is passed to Rofi via `dmenu_command`.
35-
- Use a custom Keepass 2.x style [auto-type sequence][autotype] if you have an
36-
'autotype' field defined in the entry (except for character repetition and the
37-
'special commands'). Set it per entry and/or set a default in the config file
38-
for all entries.
58+
generation.
59+
- Optional Pinentry support for secure passphrase entry.
3960

4061
## License
4162

4263
- MIT
4364

44-
## Requirements
45-
46-
1. Python 3.7+.
47-
2. [Bitwarden CLI][bwcli]. Ensure the `bw` command is in `$PATH`
48-
3. [Pynput][pynput]
49-
4. Dmenu or [Rofi][rofi]. Rofi configuration/theming should be done via Rofi
50-
theme files.
51-
5. (optional) Pinentry. Make sure to set which flavor of pinentry command to use
52-
in the config file.
53-
6. (optional) xdotool or ydotool (for Wayland). If you have a lot of Unicode
54-
characters or use a non-U.S. English keyboard layout, xdotool is necessary
55-
to handle typing those characters.
56-
57-
## Installation
58-
59-
- Installation
60-
61-
+ `pip install --user bitwarden-menu`. Add ~/.local/bin to $PATH
62-
+ In a virtualenv with pip. Link to the executable in
63-
<path/to/virtualenv/bin/bwm>
64-
65-
mkvirtualenv bwm
66-
pip install bitwarden-menu
67-
68-
+ From git. Just clone, install requirements and run
69-
+ Available in the [Archlinux AUR][aur].
70-
71-
- If you start bwm for the first time without a config file, it will prompt
72-
you for server name, login email, and 2FA type and save them in the config
73-
file.
74-
75-
- Copy config.ini.example to ~/.config/bwm/config.ini, or use it as a
76-
reference for additional options.
77-
78-
+ To use a command (e.g. gpg) to lookup db password, set `password_cmd_<n>`
79-
in config.ini.
80-
+ Adjust `session_timeout_min` if desired. Default is 6 hours (360 min).
81-
+ Set the dmenu_command to `rofi` if you are using that instead
82-
+ Adjust the autotype_default, if desired. Allowed codes are the
83-
`Keepass 2.x codes`_ except for repetitions and most command codes. `{DELAY
84-
x}` (in milliseconds) is supported. Individual autotype sequences can be
85-
edited or deleted using bwm. To disable autotype for an entry, set it to
86-
`False`.
87-
+ Set `type_library = xdotool` or `type_library = ydotool` (Wayland) if you
88-
need support for non-U.S. English keyboard layouts and/or characters.
89-
90-
* When using xdotool, call `setxkbmap` to set your keyboard type somewhere
91-
in your window manager or desktop environment initialization. For example:
92-
`exec setxkbmap de` in ~/.config/i3/config.
93-
94-
- If using Rofi, pass desired theme via `dmenu_command = rofi -theme <theme>.rasi`.
95-
Dmenu themeing options are also passed via `dmenu_command`
96-
- New sets of characters can be set in config.ini in the `[password_chars]`
97-
section. A new preset for each custom set will be listed in addition to the
98-
default presets. If you redefine one of the default sets (upper, lower,
99-
digits, punctuation), it will replace the default values.
100-
- New preset groups of character sets can be defined in config.ini in the
101-
`[password_char_presets]` section. You can set any combination of default and
102-
custom character sets. A minimum of one character from each distinct set will
103-
be used when generating a new password. If any custom presets are defined, the
104-
default presets will not be displayed unless they are uncommented.
105-
106-
<b>WARNING:</b> If you choose to store your vault password in config.ini, make
107-
sure to `chmod 600 config.ini`. This is not secure and I only added it as a
108-
convenience for testing.
109-
11065
## Usage
11166

112-
- Run script or bind to keystroke combination
113-
- Enter server URL (default `vault.bitwarden.com`), login email and 2FA type if
114-
not entered into config.ini already.
115-
- Start typing to match entries.
116-
- Hit Enter immediately after dmenu opens ("`View/Type individual entries`") to
117-
switch modes to view and/or type the individual fields for the entry. If
118-
selected, the URL will open in the default browser instead of being typed.
119-
- To view a password without typing it, use the 'Edit Entries' option, then
120-
select the entry, select 'Password' then select 'Manually enter password'.
121-
Type 'ESC' to exit without making changes.
122-
123-
### Wayland (wlroots - Sway)
67+
`bwm [-h] [-v VAULT] [-l LOGIN] [-a AUTOTYPE]`
12468

125-
- Dmenu or Rofi work under XWayland.
126-
- To enable ydotool to work without sudo
127-
- Pick a group that one or more users
128-
belong to (e.g. `users`) and:
129-
130-
$ echo "KERNEL==\"uinput\", GROUP=\"users\", MODE=\"0660\", \
131-
OPTIONS+=\"static_node=uinput\"" | sudo tee \
132-
/etc/udev/rules.d/80-uinput.rules > /dev/null
133-
# udevadm control --reload-rules && udevadm trigger
134-
135-
- Create a systemd user service for ydotoold:
136-
137-
~/.config/systemd/user/ydotoold.service
138-
[Unit]
139-
Description=ydotoold Service
140-
141-
[Service]
142-
ExecStart=/usr/bin/ydotoold
143-
144-
[Install]
145-
WantedBy=default.target
69+
- Run `bwm` or bind to keystroke combination.
70+
- Enter account URL on first run.
71+
- Start typing to match entries.
72+
- [Configure](docs/configure.md) ~/.config/bwm/config.ini as desired.
73+
- More detailed [usage information](docs/usage.md).
14674

147-
- Enable and start ydotoold.service:
75+
## Tests
14876

149-
$ systemctl --user daemon-reload
150-
$ systemctl --user enable --now ydotoold.service
77+
To run tests in a venv: `make test` (not implemented yet)
15178

152-
## Tests
79+
## Development
15380

154-
- To run tests: `python tests/tests.py` (not implemented yet)
81+
- To install bitwarden-menu in a venv: `make`
82+
- Build man page from Markdown source: `make man`
15583

15684
## Planned features
15785

15886
- Unit tests
15987
- TOTP support
16088
- Notifications for syncing status (e.g. when a sync is complete)
89+
- Clipboard support
16190

16291
[pynput]: https://github.com/moses-palmer/pynput "Pynput"
16392
[bwcli]: https://github.com/bitwarden/cli "Bitwarden CLI"
16493
[rofi]: https://davedavenport.github.io/rofi/ "Rofi"
165-
[aur]: https://aur.archlinux.org/packages/python-bitwarden-menu-git "Archlinux AUR"
94+
[aur]: https://aur.archlinux.org/packages/bitwarden-menu-git "Archlinux AUR"
16695
[autotype]: https://keepass.info/help/base/autotype.html#autoseq "Keepass 2.x Autotype codes"
96+
[bemenu]: https://github.com/Cloudef/bemenu "Bemenu"

0 commit comments

Comments
 (0)