From c8642343e752407b66598bd2ed073d53714bbfd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=84min=20Baumeler?= Date: Thu, 3 Jul 2025 12:25:15 +0200 Subject: [PATCH] feat: theme --- README.md | 20 ++++++++++++++++++++ src/awk/list.awk | 24 +++++++++++++----------- src/main.sh | 17 +++++++++++++---- src/sh/cli.sh | 22 +++++++++++----------- src/sh/cliinternal.sh | 2 +- src/sh/config.sh | 4 ++-- src/sh/icalendar.sh | 3 --- src/sh/theme.sh | 20 ++++++++++++++++++++ 8 files changed, 80 insertions(+), 32 deletions(-) create mode 100644 src/sh/theme.sh diff --git a/README.md b/README.md index 4b85e52..0725823 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,8 @@ item_types = ["VJOURNAL", "VTODO"] ... ``` +You may also specify the location of the configuration file with the environment `CONFIGFILE`. + Usage ----- Use the default `fzf` keys to navigate your notes, e.g., `ctrl-j` and `ctrl-k` for going down/up in the list. @@ -96,6 +98,24 @@ Git support ----------- You can track your entries with `git` by simply running `fzf-vjour --git-init`. +Extended configuration / Theming +-------------------------------- +You may override any of the following parameters (shown with default values) in +the configuration file: +```sh +FLAG_OPEN=🔲 +FLAG_COMPLETED=✅ +FLAG_JOURNAL=📘 +FLAG_NOTE=🗒️ +FLAG_PRIORITY=❗ + +STYLE_COLLECTION="$FAINT$WHITE" +STYLE_DATE="$CYAN" +STYLE_SUMMARY="$GREEN" +STYLE_EXPIRED="$RED" +STYLE_CATEGORY="$WHITE" +``` + Limitations ----------- Here is a list of some currently present limitations. diff --git a/src/awk/list.awk b/src/awk/list.awk index 0e82ad1..1f770d1 100644 --- a/src/awk/list.awk +++ b/src/awk/list.awk @@ -49,6 +49,12 @@ BEGIN { # flag_completed: symbol for completed to-dos # flag_journal: symbol for journal entries # flag_note: symbol for note entries + # flag_priority symbol for prior. task + # style_collection + # style_date + # style_summary + # style_expired + # style_category FS = "[:;]"; # Collections @@ -59,10 +65,6 @@ BEGIN { collection2label[m[1]] = m[2]; } # Colors - GREEN = "\033[1;32m"; - RED = "\033[1;31m"; - WHITE = "\033[1;97m"; - CYAN = "\033[1;36m"; OFF = "\033[m"; # For date comparision @@ -112,7 +114,7 @@ ENDFILE { "-", type, "-", - RED "ERROR: file '" fpath "' contains whitespaces!" OFF + style_expired "ERROR: file '" fpath "' contains whitespaces!" OFF exit } # Collection name @@ -145,7 +147,7 @@ ENDFILE { priotext = "" if (pri > 0) { - priotext = "❗(" pri ") " + priotext = flag_priority "(" pri ") " psort = 10 - pri } @@ -158,8 +160,8 @@ ENDFILE { # Date field. For VTODO entries, we show the due date, for journal entries, # the associated date. - datecolor = CYAN; - summarycolor = GREEN; + datecolor = style_date + summarycolor = style_summary if (type == "VTODO") { @@ -167,8 +169,8 @@ ENDFILE { d = due ? due : (dur ? dts " for " dur : ""); if (d && d <= today && sta != "COMPLETED") { - datecolor = RED; - summarycolor = RED; + datecolor = style_expired; + summarycolor = style_expired; } } else { d = dts @@ -202,5 +204,5 @@ ENDFILE { datecolor d OFF, flag, priotext summarycolor summary OFF, - WHITE categories OFF; + style_category categories OFF; } diff --git a/src/main.sh b/src/main.sh index c77a95b..35ab168 100644 --- a/src/main.sh +++ b/src/main.sh @@ -5,6 +5,9 @@ set -eu # Helper functions . "sh/helper.sh" +# Read theme +. "sh/theme.sh" + # Read configuration . "sh/config.sh" @@ -15,10 +18,16 @@ __lines() { find "$ROOT" -type f -name '*.ics' -print0 | xargs -0 -P 0 \ awk \ -v collection_labels="$COLLECTION_LABELS" \ - -v flag_open="🔲" \ - -v flag_completed="✅" \ - -v flag_journal="📘" \ - -v flag_note="🗒️" \ + -v flag_open="$FLAG_OPEN" \ + -v flag_completed="$FLAG_COMPLETED" \ + -v flag_journal="$FLAG_JOURNAL" \ + -v flag_note="$FLAG_NOTE" \ + -v flag_priority="$FLAG_PRIORITY" \ + -v style_collection="$STYLE_COLLECTION" \ + -v style_date="$STYLE_DATE" \ + -v style_summary="$STYLE_SUMMARY" \ + -v style_expired="$STYLE_EXPIRED" \ + -v style_category="$STYLE_CATEGORY" \ "$AWK_LIST" | sort -g -r } diff --git a/src/sh/cli.sh b/src/sh/cli.sh index 0b1caf6..6fa313e 100644 --- a/src/sh/cli.sh +++ b/src/sh/cli.sh @@ -36,43 +36,43 @@ while [ -n "${1:-}" ]; do case "${1:-}" in "--completed") shift - cliquery="${cliquery:-} ✅" + cliquery="${cliquery:-} $FLAG_COMPLETED" ;; "--no-completed") shift - cliquery="${cliquery:-} !✅" + cliquery="${cliquery:-} !$FLAG_COMPLETED" ;; "--open") shift - cliquery="${cliquery:-} 🔲" + cliquery="${cliquery:-} $FLAG_OPEN" ;; "--no-open") shift - cliquery="${cliquery:-} !🔲" + cliquery="${cliquery:-} !$FLAG_OPEN" ;; "--tasks") shift - cliquery="${cliquery:-} ✅ | 🔲" + cliquery="${cliquery:-} $FLAG_OPEN | $FLAG_COMPLETED" ;; "--no-tasks") shift - cliquery="${cliquery:-} !✅ !🔲" + cliquery="${cliquery:-} !$FLAG_COMPLETED !$FLAG_OPEN" ;; "--notes") shift - cliquery="${cliquery:-} 🗒️" + cliquery="${cliquery:-} $FLAG_NOTE" ;; "--no-notes") shift - cliquery="${cliquery:-} !🗒️" + cliquery="${cliquery:-} !$FLAG_NOTE" ;; "--journal") shift - cliquery="${cliquery:-} 📘" + cliquery="${cliquery:-} $FLAG_JOURNAL" ;; "--no-journal") shift - cliquery="${cliquery:-} !📘" + cliquery="${cliquery:-} !$FLAG_JOURNAL" ;; "--filter") shift @@ -90,5 +90,5 @@ while [ -n "${1:-}" ]; do ;; esac done -query=${cliquery:-!✅} +query=${cliquery:-!$FLAG_COMPLETED} export query diff --git a/src/sh/cliinternal.sh b/src/sh/cliinternal.sh index 8ea9d80..8651c4a 100644 --- a/src/sh/cliinternal.sh +++ b/src/sh/cliinternal.sh @@ -27,7 +27,7 @@ if [ "${1:-}" = "--reload" ]; then shift fname="$1" shift - __change_priority "$delta" "$fname" >>/tmp/foo + __change_priority "$delta" "$fname" >/dev/null ;; esac __lines diff --git a/src/sh/config.sh b/src/sh/config.sh index 16c401c..704d33f 100644 --- a/src/sh/config.sh +++ b/src/sh/config.sh @@ -1,4 +1,4 @@ -CONFIGFILE="$HOME/.config/fzf-vjour/config" +CONFIGFILE="${CONFIGFILE:-$HOME/.config/fzf-vjour/config}" if [ ! -f "$CONFIGFILE" ]; then err "Configuration '$CONFIGFILE' not found." exit 1 @@ -41,5 +41,5 @@ export CAT if command -v "git" >/dev/null && [ -d "$ROOT/.git" ]; then GIT="git -C $ROOT" + export GIT fi -export GIT diff --git a/src/sh/icalendar.sh b/src/sh/icalendar.sh index 6b1d23e..ecd6c5f 100644 --- a/src/sh/icalendar.sh +++ b/src/sh/icalendar.sh @@ -25,12 +25,9 @@ __change_priority() { shift fname="$1" shift - echo "call to __change_priority with delta=$delta and fname=$fname" >>/tmp/foo file="$ROOT/$fname" tmpfile=$(mktemp) - echo " tmpfile=$tmpfile" >>/tmp/foo awk -v delta="$delta" "$AWK_ALTERTODO" "$file" >"$tmpfile" - echo " lines=$(wc -l tmpfile)" >>/tmp/foo mv "$tmpfile" "$file" if [ -n "${GIT:-}" ]; then $GIT add "$file" diff --git a/src/sh/theme.sh b/src/sh/theme.sh new file mode 100644 index 0000000..8fc7ece --- /dev/null +++ b/src/sh/theme.sh @@ -0,0 +1,20 @@ +# Colors +GREEN="\033[1;32m" +RED="\033[1;31m" +WHITE="\033[1;97m" +CYAN="\033[1;36m" +FAINT="\033[2m" + +# Flags +export FLAG_OPEN="${FLAG_OPEN:-🔲}" +export FLAG_COMPLETED="${FLAG_COMPLETED:-✅}" +export FLAG_JOURNAL="${FLAG_JOURNAL:-📘}" +export FLAG_NOTE="${FLAG_NOTE:-🗒️}" +export FLAG_PRIORITY="${FLAG_PRIORITY:-❗}" + +# Style +export STYLE_COLLECTION="${STYLE_COLLECTION:-$FAINT$WHITE}" +export STYLE_DATE="${STYLE_DATE:-$CYAN}" +export STYLE_SUMMARY="${STYLE_SUMMARY:-$GREEN}" +export STYLE_EXPIRED="${STYLE_EXPIRED:-$RED}" +export STYLE_CATEGORY="${STYLE_CATEGORY:-$WHITE}"