From fb0ce82b670d211278f428b935a376c9bc5e57da Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sun, 27 Sep 2026 19:01:48 +0200 Subject: Add rofi-notes.sh, the rofi front end for notes Moved into the repo from a standalone script in ~/bin. It now exits quietly when the rofi menu is dismissed instead of launching a terminal with no note ID (which flashed a window open and shut), calls notes from PATH, and fixes the swapped kitty arguments on the add-note path. Document the symlink install in AGENTS.md and README. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 9 +++++++++ README.md | 2 ++ rofi-notes.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100755 rofi-notes.sh diff --git a/AGENTS.md b/AGENTS.md index cdd99cf..6a3caa7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -27,6 +27,15 @@ run `make`, and commit both the sources and the rebuilt `notes.sh` together. edit, list, remove, show) 5. `SOURCE/main.sh`: `getopt` parsing and dispatch +`rofi-notes.sh` is a hand-written rofi + kitty front end (show/add/edit/delete +menus), not part of the build. It calls `notes` from `PATH`. + +On the maintainer's machine both scripts are installed as symlinks into the +repo, so a `make` (or an edit to `rofi-notes.sh`) is live immediately: + + ~/bin/notes -> notes.sh + ~/bin/rofi-notes.sh -> rofi-notes.sh (bound to Super+F5..F8 in Hyprland) + Since it is plain concatenation, top-level code runs in that order. A function is callable from `main.sh` no matter which file defines it. diff --git a/README.md b/README.md index cd7bad9..086ec43 100644 --- a/README.md +++ b/README.md @@ -186,6 +186,8 @@ chmod 755 ~/bin/notes.sh Adapt to your needs as you see fit. +`rofi-notes.sh` is an optional [rofi](https://github.com/davatorium/rofi) front end: run it with no option to pick a note to show, or with `-a`, `-e`, `-d` to add, edit or delete one. It expects notes.sh installed as `notes` in your `$PATH` and opens notes in [kitty](https://sw.kovidgoyal.net/kitty/). Bind it to hotkeys in your window manager. + The first time you run the script it will take care of creating all the files and folders it needs in the standard directories. ### Debugging diff --git a/rofi-notes.sh b/rofi-notes.sh new file mode 100755 index 0000000..82f2e91 --- /dev/null +++ b/rofi-notes.sh @@ -0,0 +1,43 @@ +#! /bin/bash + +# bash-notes © 2023 by danix is licensed under CC BY-NC 4.0. +# To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/ + +# rofi front end for notes.sh. Bind it to hotkeys in your window manager: +# rofi-notes.sh show note +# rofi-notes.sh -a add note +# rofi-notes.sh -e edit note +# rofi-notes.sh -d delete note + +rofi_command="rofi -theme ~/.config/rofi/udt/menu.rasi" +notes_command=notes + +# list of existing notes passed to rofi +options=$($notes_command -pl) + +# how to run the script +PARAM="$1" +case $PARAM in + -a ) + # add note + kitty --session=none --class notes -T notes $notes_command -a + ;; + -e ) + # edit note_ID + selected=$(echo -e "$options" | $rofi_command -p "edit note" -dmenu -selected-row 0 | cut -d " " -f1) + [ -n "$selected" ] || exit 0 + kitty --session=none --class notes -T notes $notes_command -e ${selected} + ;; + -d ) + # delete note_ID + selected=$(echo -e "$options" | $rofi_command -p "delete note" -dmenu -selected-row 0 | cut -d " " -f1) + [ -n "$selected" ] || exit 0 + kitty --session=none --class notes -T notes $notes_command -d ${selected} + ;; + * ) + # list notes + selected=$(echo -e "$options" | $rofi_command -p "notes" -dmenu -selected-row 0 | cut -d " " -f1) + [ -n "$selected" ] || exit 0 + kitty --session=none --class notes -T notes $notes_command -s $selected + ;; +esac -- cgit v1.2.3