summary refs log tree commit diff
path: root/.config
diff options
context:
space:
mode:
Diffstat (limited to '.config')
-rw-r--r--.config/waybar/config2
-rw-r--r--.config/waybar/modules/todo.go42
2 files changed, 23 insertions, 21 deletions
diff --git a/.config/waybar/config b/.config/waybar/config
index 3bdf3b3..544661d 100644
--- a/.config/waybar/config
+++ b/.config/waybar/config
@@ -157,7 +157,7 @@
             "off": "󰒲",
             "on": "󰈻"
         },
-        "exec": "$HOME/.config/waybar/modules/waybar-todo",
+        "exec": "env WAYBAR_TODO_FILE=$HOME/.zk/todo.md $HOME/.config/waybar/modules/waybar-todo",
         "on-click": "pkill -x -USR1 waybar-todo",
         "on-click-right": "pkill -x -USR2 waybar-todo",
         "escape": true,
diff --git a/.config/waybar/modules/todo.go b/.config/waybar/modules/todo.go
index 4f403f5..97daaa4 100644
--- a/.config/waybar/modules/todo.go
+++ b/.config/waybar/modules/todo.go
@@ -1,6 +1,5 @@
 // # Documentation
-// we try to read a file pointed to by WAYBAR_TODO_FILE
-// or `nb show --path todo`.
+// we try to read a file pointed to by WAYBAR_TODO_FILE.
 // While no particular format is assumed, we recommend
 // Markdown.
 // We extract the todos from the top-level list items
@@ -15,7 +14,6 @@ import (
 	"encoding/json"
 	"log"
 	"os"
-	"os/exec"
 	"os/signal"
 	"regexp"
 	"strings"
@@ -26,7 +24,6 @@ import (
 )
 
 const (
-	TODO_LINE_CHAR       string = "* "
 	TODO_INACTIVE_STRING string = ""
 	TODO_LABEL_REGEX     string = `\[\[!(.*)\]\]`
 )
@@ -58,14 +55,20 @@ func readTodofile2(path string) ([]todoItem, error) {
 	if err != nil {
 		return nil, err
 	}
-	var (
-		todos []todoItem
-	)
+	var todos []todoItem
 	for lr := bufio.NewScanner(f); lr.Scan(); {
-		if !strings.HasPrefix(lr.Text(), TODO_LINE_CHAR) {
+		skip := 0
+		switch {
+		case strings.HasPrefix(lr.Text(), "*"):
+			skip = 2
+		case strings.HasPrefix(lr.Text(), "- [ ]"):
+			skip = 6
+		case strings.HasPrefix(lr.Text(), "- [x]"):
+			fallthrough
+		default:
 			continue
 		}
-		ti := todoItem{text: lr.Text()[2:]}
+		ti := todoItem{text: lr.Text()[skip:]}
 		matches := labelre.FindAllStringSubmatch(ti.text, -1)
 		if matches != nil && len(matches) > 0 {
 			ti.label = matches[0][1]
@@ -117,9 +120,7 @@ func update() error {
 	return printJson(text, strings.Join(tooltip, "\n"), []string{"on", extraClass}, "on", 1)
 }
 
-var (
-	labelre *regexp.Regexp
-)
+var labelre *regexp.Regexp
 
 func init() {
 	labelre = regexp.MustCompile(TODO_LABEL_REGEX)
@@ -141,14 +142,15 @@ func main() {
 	}
 
 	if todofile == "" {
-		// get from nb(1)
-		nb := exec.Command("sh", "-c", "nb show --no-color --path todo")
-		nb_output, err := nb.Output()
-		if err != nil {
-			e := err.(*exec.ExitError)
-			log.Fatalf("error: finding todofile via nb: %s", e.Stderr)
-		}
-		todofile = strings.TrimSpace(string(nb_output))
+		panic("missing TODO file")
+		// // get from nb(1)
+		// nb := exec.Command("sh", "-c", "nb show --no-color --path todo")
+		// nb_output, err := nb.Output()
+		// if err != nil {
+		// 	e := err.(*exec.ExitError)
+		// 	log.Fatalf("error: finding todofile via nb: %s", e.Stderr)
+		// }
+		// todofile = strings.TrimSpace(string(nb_output))
 	}
 
 	log.Printf("watching %q", todofile)