agendafs

A filesystem for your calendar.

git clone git://mccd.space/agendafs
commit 3422aee823ad263b78f8c443f18be21e35152d60
parent 762bf678883e738c313ba35bd89143287c5c3c86
Author: Marc Coquand <marc@coquand.email>
Date:   Fri, 11 Jul 2025 10:26:07 +0200

README

Diffstat:
MREADME.md | 34+++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
@@ -80,9 +80,11 @@ list](https://lists.sr.ht/~marcc/agendafs)
 
 ## Appendix
 
+Below are some various scripts and notes.
+
 ### VJOURNAL support in Caldav
 
-To have vjournal support on Nextcloud, I needed to create the calendar manually...
+To have vjournal support on Nextcloud, I needed to create the calendar manually. This is probably also required in Fastmail.
 
 ```
 curl -X MKCALENDAR \
@@ -107,6 +109,9 @@ curl -X MKCALENDAR \
 
 ### Categories
 
+Categories requires xattributes to be installed. See the man pages of
+xattr(7), setfattr(1), getfattr(1) for basic usage.
+
 #### Find all files with categories, and their categories
 
 ```sh
@@ -119,6 +124,33 @@ $ find . -type f -exec getfattr -n user.categories {} + 2>/dev/null
 $ find . -type f -exec getfattr -n user.categories {} + 2>/dev/null | grep -B1 "MY_CATEGORY" | grep '^# file' | awk '{ print substr($0, 9) }'
 ```
 
+### Find files by category with nnn
+
+The following function can be added to your profile to search for files
+that have the right category.
+
+```sh
+find_by_category() {
+	category=$1
+	if [ -z "$category" ]; then
+    		echo "Usage: find_by_category <category>" >&2
+    		return 1
+	fi
+
+	find . -type f | while IFS= read -r file; do
+    		fullpath=$(realpath "$file")
+    		value=$(getfattr --only-values -n user.categories -- "$file" 2>/dev/null)
+    		case $value in
+        		*"$category"*)
+            			printf '%s\0' "$fullpath"
+            			;;
+    		esac
+    	done 
+}
+```
+
+Usage: `$ find_by_category MY_CATEGORY | nnn`
+
 ### lf
 
 Updates might not be reflected with dircache set to true. This is probably because inodes are not updated correctly yet.