First commit
This commit is contained in:
parent
553fc353ea
commit
1f93e5f7c8
54
README.md
54
README.md
@ -1,3 +1,55 @@
|
||||
# rofi-yubikey
|
||||
# Rofi-YubiKey
|
||||
|
||||
A no-bloat script for getting OATH codes from a YubiKey.
|
||||
|
||||
# Usage
|
||||
Either only download `rofi-yubikey.sh`, or clone the entire repository (`git clone https://git.solomon.tech/solomon/rofi-yubikey.git`).
|
||||
|
||||
Once you have the script on your computer, move it to wherever you desire. I personally use, and recommend `~/.local/bin/rofi-yubikey.sh`.
|
||||
|
||||
After that, simply execute the script. For example, if you placed the script in `~/.local/bin/rofi-yubikey.sh`, you could run any of the below commands:
|
||||
- `sh ~/.local/bin/rofi-yubikey.sh`
|
||||
- `bash ~/.local/bin/rofi-yubikey.sh`
|
||||
- `~/.local/bin/rofi-yubikey.sh`
|
||||
(only pick one!)
|
||||
|
||||
# Integration with Window Managers
|
||||
**Note: I will only be documenting XMonad, because I cannot guarantee the validity of my advice regarding different window managers.**
|
||||
|
||||
If you are using XMonad, you likely already know how to set custom keybinds. Simply make a keybind run the script.
|
||||
However, if you are unfamiliar, this is how I do it:
|
||||
|
||||
1. Import `EZConfig`:
|
||||
Import the following:
|
||||
``` haskell
|
||||
import XMonad.Util.EZConfig
|
||||
```
|
||||
|
||||
2. Add `additionalKeysP` to your defaults variable.
|
||||
``` haskell
|
||||
defaults = def {
|
||||
-- REST OF CONFIG HERE
|
||||
} `additionalKeysP` myAddKeys
|
||||
```
|
||||
|
||||
2.a. Make sure `defaults` is being used
|
||||
Add `defaults` to `main = ...`
|
||||
For example:
|
||||
|
||||
``` haskell
|
||||
main :: IO()
|
||||
main = xmonad . <your-confif-here> $ defaults
|
||||
```
|
||||
|
||||
3. Define `myAddKeys`
|
||||
|
||||
``` haskell
|
||||
-- Add custom keys
|
||||
myAddKeys =
|
||||
-- This firefox keybinding is here to show you how to add multiple keybindings
|
||||
[ ("M-b", spawn "firefox")
|
||||
, ("M-<Backspace>", spawn "/home/USERNAME/.local/bin/rofi-yubikey.sh")
|
||||
]
|
||||
```
|
||||
|
||||
*PR requests are open if anyone would like to add documentation for other window managers, etc*
|
||||
|
20
rofi-yubikey.sh
Executable file
20
rofi-yubikey.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Get full list of account codes
|
||||
output=$(/usr/bin/ykman oath accounts code)
|
||||
|
||||
# Get account names
|
||||
accounts=$(echo "$output" | awk 'BEGIN{FS=OFS=" "}{$NF=""; NF--; print}')
|
||||
|
||||
# Get selected
|
||||
selected=$(echo "$accounts"| \
|
||||
rofi -no-show-icons -dmenu -i -p "YubiKey OATH Codes");
|
||||
|
||||
# If the user selects an entry
|
||||
if [[ ! -z $selected ]]; then
|
||||
# Copy code to the user's clipboard
|
||||
echo "$output" | grep "$selected" | awk '{print $NF}' | xclip -selection clipboard;
|
||||
fi
|
||||
|
||||
# Exit Rofi
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user