Simply select text, press the key combination, and it's added to your file! Without cluttering your clipboard buffer with one-time-use text.
All using Haka, a low level global keyboard event listener for Wayland.
This project aims to solve a problem I face when making notes: efficiently creating and organizing notes when you have a large volume of resources and limited time.
-
Highlightingimportant points across different sources (web pages, PDFs, ebooks) makes it hard to search for a specific point in a centralized way. -
Manual Copy Pastais extremely slow with many steps involved,- Select the point with your mouse
- Hit the
<C-c> - Switch to the editor
- Hit the
<C-v> - Switch back to the resource
What if life was as simple as:
- Select the point with your mouse (unfortunately)
- Hit a
<Key-Combo>
Haka allows you to capture key points
without breaking your concentration and also allows you to fuzzy find notes later.
Dependencies
build.sh includes the installation of all the dependencies, but only for arch and debian based distros. For any other distribution, kindly install the aforementioned dependencies. Or simply use the based Makefile
From your favourite terminal, execute the build.sh script for installation
chmod +x build.sh
./build.shTo access the input group and access the event devices using libevdev, one needs root privileges. Although running haka as the root user has many issues, the most critiacl being the current user session, including the primary clipboard, is not available when running as root.
To resolve this issue, we use the capabilities(7) to grant haka the permission to change its group ID to input. Now haka can run as a user process and still be able to access the evdev. Credit for this workaround goes to this blog.
Note
build.sh handles this implicitly. If you used build.sh to build haka, this has been performed already.
sudo setcap "cap_setgid=eip" ./haka.out
./haka.out # no sudo required while runningIf you want to use haka as a new-style systemd daemon to run in the background, use daemon.sh to generate the unit file for systemd.
daemon.sh creates the unit file required to run as a --user daemon and it creates a symlink of the unit file to ~/.config/systemd/user/
Note
Make sure to execute daemon.sh from the directory containing haka.out. If you renamed the executable, edit the HAKA variable in daemon.sh
chmod +x daemon.sh
./daemon.shCheck logs:
journalctl --user -u haka.service -fConfig file for haka must be named haka.cfg which must be present in the same directory as the haka executable. The haka config parser allows you to use command substitution for configuration values. For example, you can specify the editor dynamically using:
editor=$(which emacs)| Option | Value | Description |
|---|---|---|
| editor | /path/to/editor/bin | Specify the editor to open files in |
| terminal | /path/to/terminal/bin | Specify the terminal to open editor in |
| notes-dir | /path/to/notes/dir | Custom path to notes dir |
| tofi-cfg | /path/to/tofi/cfg | Custom path for tofi.cfg file |
- The files displayed in the selection menu is the
notes/directory and can be found in the directory containing haka executable - The file is opened by default in
neovim hakacurrently supports the first 249KEY_NAMEdefined inlinux/input-event-codes.h
- The defualt
ActivationComboisCtr+Alt - The default keybinds and activation combo are set in the
src/bindings.c. - To make custom keybinds, create a function with this prototype:
void func(struct hakaStatus *haka). Add its declaration ininclude/hakaEventHandler.hand implement it insrc/hakaEventHandler.c. Now bind your action to a key insrc/bindings.cusing theBind(function, KEY_TOBIND...)macro. Referlinux/input-event-codes.hforKEY_NAMEmacros.
Important
Do not use open or close on haka->fdNotesFile, since state is internally managed by eventHandlerEpilogue, use wrappers around it like openNotesFile and closeNotesFile.
| Key Combination | Binded Task |
|---|---|
Ctrl+Alt + C |
Paste the current selection to the current file |
Ctrl+Alt + . |
Paste the current selection as an unordered list item to the current file |
Ctrl+Alt + N |
Send a Blank Line to the current file |
Ctrl+Alt + M |
Opens the file selection menu |
Ctrl+Alt + O |
Opens the file in neovim |
- Switch to gtk(?): to reduce dependencies.
- Add a config file option for vars.
- Ignore newlines in selection(?)
- Improve bindings implementation