feat: theme

This commit is contained in:
2025-07-03 12:25:15 +02:00
parent e954569d5d
commit c8642343e7
8 changed files with 80 additions and 32 deletions

View File

@@ -70,6 +70,8 @@ item_types = ["VJOURNAL", "VTODO"]
... ...
``` ```
You may also specify the location of the configuration file with the environment `CONFIGFILE`.
Usage Usage
----- -----
Use the default `fzf` keys to navigate your notes, e.g., `ctrl-j` and `ctrl-k` for going down/up in the list. 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`. 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 Limitations
----------- -----------
Here is a list of some currently present limitations. Here is a list of some currently present limitations.

View File

@@ -49,6 +49,12 @@ BEGIN {
# flag_completed: symbol for completed to-dos # flag_completed: symbol for completed to-dos
# flag_journal: symbol for journal entries # flag_journal: symbol for journal entries
# flag_note: symbol for note entries # flag_note: symbol for note entries
# flag_priority symbol for prior. task
# style_collection
# style_date
# style_summary
# style_expired
# style_category
FS = "[:;]"; FS = "[:;]";
# Collections # Collections
@@ -59,10 +65,6 @@ BEGIN {
collection2label[m[1]] = m[2]; collection2label[m[1]] = m[2];
} }
# Colors # Colors
GREEN = "\033[1;32m";
RED = "\033[1;31m";
WHITE = "\033[1;97m";
CYAN = "\033[1;36m";
OFF = "\033[m"; OFF = "\033[m";
# For date comparision # For date comparision
@@ -112,7 +114,7 @@ ENDFILE {
"-", "-",
type, type,
"-", "-",
RED "ERROR: file '" fpath "' contains whitespaces!" OFF style_expired "ERROR: file '" fpath "' contains whitespaces!" OFF
exit exit
} }
# Collection name # Collection name
@@ -145,7 +147,7 @@ ENDFILE {
priotext = "" priotext = ""
if (pri > 0) if (pri > 0)
{ {
priotext = "(" pri ") " priotext = flag_priority "(" pri ") "
psort = 10 - pri psort = 10 - pri
} }
@@ -158,8 +160,8 @@ ENDFILE {
# Date field. For VTODO entries, we show the due date, for journal entries, # Date field. For VTODO entries, we show the due date, for journal entries,
# the associated date. # the associated date.
datecolor = CYAN; datecolor = style_date
summarycolor = GREEN; summarycolor = style_summary
if (type == "VTODO") if (type == "VTODO")
{ {
@@ -167,8 +169,8 @@ ENDFILE {
d = due ? due : (dur ? dts " for " dur : ""); d = due ? due : (dur ? dts " for " dur : "");
if (d && d <= today && sta != "COMPLETED") if (d && d <= today && sta != "COMPLETED")
{ {
datecolor = RED; datecolor = style_expired;
summarycolor = RED; summarycolor = style_expired;
} }
} else { } else {
d = dts d = dts
@@ -202,5 +204,5 @@ ENDFILE {
datecolor d OFF, datecolor d OFF,
flag, flag,
priotext summarycolor summary OFF, priotext summarycolor summary OFF,
WHITE categories OFF; style_category categories OFF;
} }

View File

@@ -5,6 +5,9 @@ set -eu
# Helper functions # Helper functions
. "sh/helper.sh" . "sh/helper.sh"
# Read theme
. "sh/theme.sh"
# Read configuration # Read configuration
. "sh/config.sh" . "sh/config.sh"
@@ -15,10 +18,16 @@ __lines() {
find "$ROOT" -type f -name '*.ics' -print0 | xargs -0 -P 0 \ find "$ROOT" -type f -name '*.ics' -print0 | xargs -0 -P 0 \
awk \ awk \
-v collection_labels="$COLLECTION_LABELS" \ -v collection_labels="$COLLECTION_LABELS" \
-v flag_open="🔲" \ -v flag_open="$FLAG_OPEN" \
-v flag_completed="" \ -v flag_completed="$FLAG_COMPLETED" \
-v flag_journal="📘" \ -v flag_journal="$FLAG_JOURNAL" \
-v flag_note="🗒️" \ -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" | "$AWK_LIST" |
sort -g -r sort -g -r
} }

View File

@@ -36,43 +36,43 @@ while [ -n "${1:-}" ]; do
case "${1:-}" in case "${1:-}" in
"--completed") "--completed")
shift shift
cliquery="${cliquery:-} " cliquery="${cliquery:-} $FLAG_COMPLETED"
;; ;;
"--no-completed") "--no-completed")
shift shift
cliquery="${cliquery:-} !" cliquery="${cliquery:-} !$FLAG_COMPLETED"
;; ;;
"--open") "--open")
shift shift
cliquery="${cliquery:-} 🔲" cliquery="${cliquery:-} $FLAG_OPEN"
;; ;;
"--no-open") "--no-open")
shift shift
cliquery="${cliquery:-} !🔲" cliquery="${cliquery:-} !$FLAG_OPEN"
;; ;;
"--tasks") "--tasks")
shift shift
cliquery="${cliquery:-} ✅ | 🔲" cliquery="${cliquery:-} $FLAG_OPEN | $FLAG_COMPLETED"
;; ;;
"--no-tasks") "--no-tasks")
shift shift
cliquery="${cliquery:-} !✅ !🔲" cliquery="${cliquery:-} !$FLAG_COMPLETED !$FLAG_OPEN"
;; ;;
"--notes") "--notes")
shift shift
cliquery="${cliquery:-} 🗒️" cliquery="${cliquery:-} $FLAG_NOTE"
;; ;;
"--no-notes") "--no-notes")
shift shift
cliquery="${cliquery:-} !🗒️" cliquery="${cliquery:-} !$FLAG_NOTE"
;; ;;
"--journal") "--journal")
shift shift
cliquery="${cliquery:-} 📘" cliquery="${cliquery:-} $FLAG_JOURNAL"
;; ;;
"--no-journal") "--no-journal")
shift shift
cliquery="${cliquery:-} !📘" cliquery="${cliquery:-} !$FLAG_JOURNAL"
;; ;;
"--filter") "--filter")
shift shift
@@ -90,5 +90,5 @@ while [ -n "${1:-}" ]; do
;; ;;
esac esac
done done
query=${cliquery:-!} query=${cliquery:-!$FLAG_COMPLETED}
export query export query

View File

@@ -27,7 +27,7 @@ if [ "${1:-}" = "--reload" ]; then
shift shift
fname="$1" fname="$1"
shift shift
__change_priority "$delta" "$fname" >>/tmp/foo __change_priority "$delta" "$fname" >/dev/null
;; ;;
esac esac
__lines __lines

View File

@@ -1,4 +1,4 @@
CONFIGFILE="$HOME/.config/fzf-vjour/config" CONFIGFILE="${CONFIGFILE:-$HOME/.config/fzf-vjour/config}"
if [ ! -f "$CONFIGFILE" ]; then if [ ! -f "$CONFIGFILE" ]; then
err "Configuration '$CONFIGFILE' not found." err "Configuration '$CONFIGFILE' not found."
exit 1 exit 1
@@ -41,5 +41,5 @@ export CAT
if command -v "git" >/dev/null && [ -d "$ROOT/.git" ]; then if command -v "git" >/dev/null && [ -d "$ROOT/.git" ]; then
GIT="git -C $ROOT" GIT="git -C $ROOT"
fi
export GIT export GIT
fi

View File

@@ -25,12 +25,9 @@ __change_priority() {
shift shift
fname="$1" fname="$1"
shift shift
echo "call to __change_priority with delta=$delta and fname=$fname" >>/tmp/foo
file="$ROOT/$fname" file="$ROOT/$fname"
tmpfile=$(mktemp) tmpfile=$(mktemp)
echo " tmpfile=$tmpfile" >>/tmp/foo
awk -v delta="$delta" "$AWK_ALTERTODO" "$file" >"$tmpfile" awk -v delta="$delta" "$AWK_ALTERTODO" "$file" >"$tmpfile"
echo " lines=$(wc -l tmpfile)" >>/tmp/foo
mv "$tmpfile" "$file" mv "$tmpfile" "$file"
if [ -n "${GIT:-}" ]; then if [ -n "${GIT:-}" ]; then
$GIT add "$file" $GIT add "$file"

20
src/sh/theme.sh Normal file
View File

@@ -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}"