rofi-yubikey/README.md

67 lines
2.0 KiB
Markdown
Raw Normal View History

2025-01-01 16:33:34 +10:00
# Rofi-YubiKey
2025-01-01 16:14:23 +10:00
2025-01-01 16:33:34 +10:00
A no-bloat script for getting OATH codes from a YubiKey.
2025-01-01 16:41:54 +10:00
# Requirements
- ykman - interfacing with YubiKeys
(`sudo pacman -S yubikey-manager` on Arch Linux - see https://wiki.archlinux.org/title/YubiKey#Management_tools)
- xclip - copying the code to the clipboard
(`sudo pacman -S xclip` on Arch Linux)
- rofi - displaying a GUI for the codes
(`sudo pacman -S rofi` on Arch Linux - see https://wiki.archlinux.org/title/Rofi)
- awk - formatting command outputs
(you should already have this installed)
2025-01-01 16:33:34 +10:00
# 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`.
2025-01-01 16:35:27 +10:00
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 following commands:
2025-01-01 16:33:34 +10:00
- `sh ~/.local/bin/rofi-yubikey.sh`
- `bash ~/.local/bin/rofi-yubikey.sh`
- `~/.local/bin/rofi-yubikey.sh`
2025-01-01 16:35:27 +10:00
2025-01-01 16:33:34 +10:00
(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.**
2025-01-01 16:35:27 +10:00
If you are using XMonad, you likely already know how to set custom keybindings. Simply make a keybinding run the script.
2025-01-01 16:33:34 +10:00
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
2025-01-01 16:35:27 +10:00
2025-01-01 16:33:34 +10:00
Add `defaults` to `main = ...`
2025-01-01 16:35:27 +10:00
For example:
2025-01-01 16:33:34 +10:00
``` haskell
main :: IO()
2025-01-01 16:36:43 +10:00
main = xmonad . <your-config-here> $ defaults
2025-01-01 16:33:34 +10:00
```
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")
]
```