Compare commits

..

8 Commits

11 changed files with 99 additions and 82 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
fzf-vcal fzf-vcal
fzf-vcal.debug

View File

@@ -34,8 +34,8 @@ function fn(path, n, a) {
# @return: colorized single-line title string # @return: colorized single-line title string
function title(start, summary) { function title(start, summary) {
summary = getcontent(summary) summary = getcontent(summary)
gsub("\n", " ", summary) # This will be put on a single line gsub("\n", " ", summary) # This will be put on a single line
gsub("\\t", " ", summary) # we use "\t" as delimiter gsub("\t", " ", summary) # we use "\t" as delimiter
depth = split(FILENAME, path, "/") depth = split(FILENAME, path, "/")
collection = depth > 1 ? path[depth-1] : "" collection = depth > 1 ? path[depth-1] : ""
collection = collection in collection2label ? collection2label[collection] : collection collection = collection in collection2label ? collection2label[collection] : collection
@@ -57,8 +57,8 @@ BEGIN {
} }
BEGINFILE { inside = 0; rs = 0; dur = 0; summary = ""; start = "ERROR"; end = "ERROR" } BEGINFILE { inside = 0; rs = 0; dur = 0; summary = ""; start = "ERROR"; end = "ERROR" }
/^END:VEVENT/ { print "~", start, dur ? start " " end : end, title(start, summary), fn(FILENAME); nextfile } /^END:VEVENT/ { print "~", start, dur ? start " " end : end, title(start, summary), fn(FILENAME); nextfile }
/^DTSTART/ && inside { start = parse() } /^DTSTART/ && inside { start = parse_dt(getparam($0), getcontent($0)) }
/^DTEND/ && inside { end = parse() } /^DTEND/ && inside { end = parse_dt(getparam($0), getcontent($0)) }
/^DURATION/ && inside { end = parse_duration($NF); dur = 1 } /^DURATION/ && inside { end = parse_duration($NF); dur = 1 }
/^[^ ]/ && rs { rs = 0 } /^[^ ]/ && rs { rs = 0 }
/^ / && rs { summary = summary substr($0, 2) } /^ / && rs { summary = summary substr($0, 2) }

View File

@@ -48,8 +48,8 @@ BEGIN {
} }
} }
/^END:VEVENT/ && inside { print_data(start, dur, end, summary); exit } /^END:VEVENT/ && inside { print_data(start, dur, end, summary); exit }
/^DTSTART/ && inside { start = parse() } /^DTSTART/ && inside { start = parse_dt(getparam($0), getcontent($0)) }
/^DTEND/ && inside { end = parse() } /^DTEND/ && inside { end = parse_dt(getparam($0), getcontent($0)) }
/^DURATION/ && inside { end = parse_duration($NF); dur = 1 } /^DURATION/ && inside { end = parse_duration($NF); dur = 1 }
/^STATUS/ && inside { status = $NF } /^STATUS/ && inside { status = $NF }
/^[^ ]/ && rs { rs = 0 } /^[^ ]/ && rs { rs = 0 }

View File

@@ -5,6 +5,7 @@
function escape(str) function escape(str)
{ {
gsub("\\\\", "\\\\", str) gsub("\\\\", "\\\\", str)
gsub("\\n", "\\n", str)
gsub(";", "\\;", str) gsub(";", "\\;", str)
gsub(",", "\\,", str) gsub(",", "\\,", str)
return str return str
@@ -37,7 +38,7 @@ function print_fold(nameparam, content, i, s)
# @input str: String # @input str: String
# @return: Unescaped string # @return: Unescaped string
function unescape(str, i, c, c2, res) { function unescape(str, i, c, c2, res) {
for(i=1; i<=length(str);i++) { for(i = 1; i <= length(str); i++) {
c = substr(str, i, 1) c = substr(str, i, 1)
if (c != "\\") { if (c != "\\") {
res = res c res = res c
@@ -57,6 +58,17 @@ function unescape(str, i, c, c2, res) {
return res return res
} }
# Isolate parameter part of an iCalendar line.
#
# @input str: String
# @return: Parameter part
function getparam(str, i) {
i = index(str, ";")
if (!i)
return ""
return substr(str, i + 1, index(str, ":") - i)
}
# Isolate content part of an iCalendar line, and unescape. # Isolate content part of an iCalendar line, and unescape.
# #
# @input str: String # @input str: String
@@ -65,22 +77,27 @@ function getcontent(str) {
return unescape(substr(str, index(str, ":") + 1)) return unescape(substr(str, index(str, ":") + 1))
} }
# Time-zone aware parsing of the date/date-time entry at the current record. # Time-zone aware parsing of DTSTART or DTEND entries.
# #
# @local variables: dt # @local variables: tz
# @input dt_param: iCalendar DTSTART or DTEND parameter string
# @input dt_content: iCalendar DTSTART or DTEND content string
# @return: date or date-time string that can be used in date (1) # @return: date or date-time string that can be used in date (1)
function parse( dt) { function parse_dt(dt_param, dt_content, tz, a, i, k) {
# Get timezone information if (dt_param) {
for (i=2; i<NF-1; i+=2) { split(dt_param, a, ";")
if ($i == "TZID") { for (i in a) {
dt = "TZ=\"" $(i+1) "\" " k = index(a[i], "=")
break if (substr(a[i], 1, k-1) == "TZID") {
tz = "TZ=\"" substr(a[i], k + 1) "\" "
break
}
} }
} }
# Get date/date-time # Get date/date-time
return length($NF) == 8 ? return length(dt_content) == 8 ?
dt $NF : dt dt_content :
dt gensub(/^([0-9]{8})T([0-9]{2})([0-9]{2})([0-9]{2})(Z)?$/, "\\1 \\2:\\3:\\4\\5", "g", $NF) dt gensub(/^([0-9]{8})T([0-9]{2})([0-9]{2})([0-9]{2})(Z)?$/, "\\1 \\2:\\3:\\4\\5", "g", dt_content)
} }
# Map iCalendar duration specification into the format to be used in date (1). # Map iCalendar duration specification into the format to be used in date (1).

View File

@@ -163,30 +163,34 @@ while true; do
--accept-nth='1,2,3,4,5' \ --accept-nth='1,2,3,4,5' \
--preview="$0 --preview-event {}" \ --preview="$0 --preview-event {}" \
--expect="ctrl-n,ctrl-t,ctrl-g,ctrl-alt-d,esc,backspace,q,alt-v,x,c,a" \ --expect="ctrl-n,ctrl-t,ctrl-g,ctrl-alt-d,esc,backspace,q,alt-v,x,c,a" \
--bind="load:pos(1)+transform( --bind='load:pos(1)+transform(
echo change-border-label:🗓️ \$(date -d {1} +\"%A %e %B %Y\") echo change-border-label:🗓️ $(date -d {1} +"%A %e %B %Y")
)+transform( )+transform(
[ -n \"\${TZ:-}\" ] && echo \"change-list-label:\$WHITE\$ITALIC(\$TZ)\$OFF\" [ -n "${TZ:-}" ] && echo "change-list-label:$STYLE_DV_TZ($TZ)$OFF"
)+transform( )+transform(
[ -n \"\$(echo {} | cut -f 5)\" ] && echo show-preview [ -n {5} ] && echo show-preview
)" \ )' \
--bind="start:hide-preview" \ --bind="start:hide-preview" \
--bind="j:down+hide-preview+transform([ -n \"\$(echo {} | cut -f 5)\" ] && echo show-preview)" \ --bind="j:down" \
--bind="k:up+hide-preview+transform([ -n \"\$(echo {} | cut -f 5)\" ] && echo show-preview)" \ --bind="k:up" \
--bind="ctrl-j:down+hide-preview+transform([ -n \"\$(echo {} | cut -f 5)\" ] && echo show-preview)" \ --bind="l:reload:$0 --reload-day {1} '+1 day'" \
--bind="ctrl-k:up+hide-preview+transform([ -n \"\$(echo {} | cut -f 5)\" ] && echo show-preview)" \ --bind="h:reload:$0 --reload-day {1} '-1 day'" \
--bind="down:down+hide-preview+transform([ -n \"\$(echo {} | cut -f 5)\" ] && echo show-preview)" \ --bind="right:reload:$0 --reload-day {1} '+1 day'" \
--bind="up:up+hide-preview+transform([ -n \"\$(echo {} | cut -f 5)\" ] && echo show-preview)" \ --bind="left:reload:$0 --reload-day {1} '-1 day'" \
--bind="l:hide-preview+reload:$0 --reload-day {1} '+1 day'" \ --bind="ctrl-l:reload:$0 --reload-day {1} '+1 week'" \
--bind="h:hide-preview+reload:$0 --reload-day {1} '-1 day'" \ --bind="ctrl-h:reload:$0 --reload-day {1} '-1 week'" \
--bind="right:hide-preview+reload:$0 --reload-day {1} '+1 day'" \ --bind="alt-l:reload:$0 --reload-day {1} '+1 month'" \
--bind="left:hide-preview+reload:$0 --reload-day {1} '-1 day'" \ --bind="alt-h:reload:$0 --reload-day {1} '-1 month'" \
--bind="ctrl-l:hide-preview+reload:$0 --reload-day {1} '+1 week'" \ --bind="ctrl-r:reload:$0 --reload-day today" \
--bind="ctrl-h:hide-preview+reload:$0 --reload-day {1} '-1 week'" \
--bind="alt-l:hide-preview+reload:$0 --reload-day {1} '+1 month'" \
--bind="alt-h:hide-preview+reload:$0 --reload-day {1} '-1 month'" \
--bind="ctrl-r:hide-preview+reload:$0 --reload-day today" \
--bind="ctrl-s:execute($SYNC_CMD ; printf 'Press <enter> to continue.'; read -r tmp)" \ --bind="ctrl-s:execute($SYNC_CMD ; printf 'Press <enter> to continue.'; read -r tmp)" \
--bind='tab:down' \
--bind='shift-tab:up' \
--bind='focus:hide-preview+transform(
[ "$FZF_KEY" = "tab" ] && [ -z {5} ] && [ "$FZF_POS" -lt "$FZF_TOTAL_COUNT" ] && echo down
[ "$FZF_KEY" = "shift-tab" ] && [ -z {5} ] && [ "$FZF_POS" -gt "1" ] && echo up
)+transform(
[ -n {5} ] && echo show-preview
)' \
--bind="w:toggle-preview-wrap" \ --bind="w:toggle-preview-wrap" \
--bind="ctrl-d:preview-down" \ --bind="ctrl-d:preview-down" \
--bind="ctrl-u:preview-up" --bind="ctrl-u:preview-up"
@@ -239,7 +243,7 @@ while true; do
--print-query \ --print-query \
--bind="start:hide-input" \ --bind="start:hide-input" \
--bind="ctrl-alt-d:show-input+change-query(ctrl-alt-d)+accept" \ --bind="ctrl-alt-d:show-input+change-query(ctrl-alt-d)+accept" \
--bind="load:transform:[ \"\$FZF_TOTAL_COUNT\" -eq 0 ] && echo 'unbind(enter)+unbind(ctrl-alt-d)'" \ --bind='load:transform:[ "$FZF_TOTAL_COUNT" -eq 0 ] && echo "unbind(enter)+unbind(ctrl-alt-d)"' \
--bind="w:toggle-wrap" \ --bind="w:toggle-wrap" \
--bind="j:down" \ --bind="j:down" \
--bind="k:up" || --bind="k:up" ||
@@ -363,21 +367,21 @@ while true; do
--info=right \ --info=right \
--margin="1" \ --margin="1" \
--info-command="printf \"$(date +"%R %Z")\"; [ -n \"\${TZ:-}\" ] && printf \" (\$TZ)\"" \ --info-command="printf \"$(date +"%R %Z")\"; [ -n \"\${TZ:-}\" ] && printf \" (\$TZ)\"" \
--preview-window=up,7,border-bottom \ --preview-window=up,8,border-bottom \
--preview="$0 --preview-week {}" \ --preview="$0 --preview-week {}" \
--bind="load:pos($DISPLAY_POS)" \ --bind="load:pos($DISPLAY_POS)+unbind(load)" \
--expect="ctrl-n,ctrl-g,ctrl-t" \ --expect="ctrl-n,ctrl-g,ctrl-t" \
--bind="q:abort" \ --bind="q:abort" \
--bind="j:down" \ --bind="j:down" \
--bind="k:up" \ --bind="k:up" \
--bind="l:unbind(load)+reload:$0 --reload-week {2} '+1 week'" \ --bind="l:reload:$0 --reload-week {2} '+1 week'" \
--bind="h:unbind(load)+reload:$0 --reload-week {2} '-1 week'" \ --bind="h:reload:$0 --reload-week {2} '-1 week'" \
--bind="right:unbind(load)+reload:$0 --reload-week {2} '+1 week'" \ --bind="right:reload:$0 --reload-week {2} '+1 week'" \
--bind="left:unbind(load)+reload:$0 --reload-week {2} '-1 week'" \ --bind="left:reload:$0 --reload-week {2} '-1 week'" \
--bind="ctrl-l:unbind(load)+reload:$0 --reload-week {2} '+1 month'" \ --bind="ctrl-l:reload:$0 --reload-week {2} '+1 month'" \
--bind="ctrl-h:unbind(load)+reload:$0 --reload-week {2} '-1 month'" \ --bind="ctrl-h:reload:$0 --reload-week {2} '-1 month'" \
--bind="alt-l:unbind(load)+reload:$0 --reload-week {2} '+1 year'" \ --bind="alt-l:reload:$0 --reload-week {2} '+1 year'" \
--bind="alt-h:unbind(load)+reload:$0 --reload-week {2} '-1 year'" \ --bind="alt-h:reload:$0 --reload-week {2} '-1 year'" \
--bind="ctrl-r:rebind(load)+reload($0 --reload-week today)+show-preview" \ --bind="ctrl-r:rebind(load)+reload($0 --reload-week today)+show-preview" \
--bind="ctrl-s:execute($SYNC_CMD ; printf 'Press <enter> to continue.'; read -r tmp)" \ --bind="ctrl-s:execute($SYNC_CMD ; printf 'Press <enter> to continue.'; read -r tmp)" \
--bind="/:show-input+unbind(q)+unbind(j)+unbind(k)+unbind(l)+unbind(h)+unbind(ctrl-l)+unbind(ctrl-h)+unbind(alt-l)+unbind(alt-h)+unbind(load)+hide-preview+reload:$0 --reload-all" \ --bind="/:show-input+unbind(q)+unbind(j)+unbind(k)+unbind(l)+unbind(h)+unbind(ctrl-l)+unbind(ctrl-h)+unbind(alt-l)+unbind(alt-h)+unbind(load)+hide-preview+reload:$0 --reload-all" \

View File

@@ -94,7 +94,7 @@ if [ "${1:-}" = "--preview-week" ]; then
cal "$month_nex" "$year_nex" | awk "$AWK_CALSHIFT" | awk -v cur="${var_nex:-}" -v style_month="$STYLE_CALENDAR_MONTH" -v style_weekdays="$STYLE_CALENDAR_WEEKDAYS" -v style_cur="$STYLE_CALENDAR_CURRENT_DAY" -v style_highlight="$STYLE_CALENDAR_HL_DAY" "$AWK_CALANNOT" cal "$month_nex" "$year_nex" | awk "$AWK_CALSHIFT" | awk -v cur="${var_nex:-}" -v style_month="$STYLE_CALENDAR_MONTH" -v style_weekdays="$STYLE_CALENDAR_WEEKDAYS" -v style_cur="$STYLE_CALENDAR_CURRENT_DAY" -v style_highlight="$STYLE_CALENDAR_HL_DAY" "$AWK_CALANNOT"
cal "$month_nex2" "$year_nex2" | awk "$AWK_CALSHIFT" | awk -v cur="${var_nex2:-}" -v style_month="$STYLE_CALENDAR_MONTH" -v style_weekdays="$STYLE_CALENDAR_WEEKDAYS" -v style_cur="$STYLE_CALENDAR_CURRENT_DAY" -v style_highlight="$STYLE_CALENDAR_HL_DAY" "$AWK_CALANNOT" cal "$month_nex2" "$year_nex2" | awk "$AWK_CALSHIFT" | awk -v cur="${var_nex2:-}" -v style_month="$STYLE_CALENDAR_MONTH" -v style_weekdays="$STYLE_CALENDAR_WEEKDAYS" -v style_cur="$STYLE_CALENDAR_CURRENT_DAY" -v style_highlight="$STYLE_CALENDAR_HL_DAY" "$AWK_CALANNOT"
cal "$month_nex3" "$year_nex3" | awk "$AWK_CALSHIFT" | awk -v cur="${var_nex3:-}" -v style_month="$STYLE_CALENDAR_MONTH" -v style_weekdays="$STYLE_CALENDAR_WEEKDAYS" -v style_cur="$STYLE_CALENDAR_CURRENT_DAY" -v style_highlight="$STYLE_CALENDAR_HL_DAY" "$AWK_CALANNOT" cal "$month_nex3" "$year_nex3" | awk "$AWK_CALSHIFT" | awk -v cur="${var_nex3:-}" -v style_month="$STYLE_CALENDAR_MONTH" -v style_weekdays="$STYLE_CALENDAR_WEEKDAYS" -v style_cur="$STYLE_CALENDAR_CURRENT_DAY" -v style_highlight="$STYLE_CALENDAR_HL_DAY" "$AWK_CALANNOT"
) | awk '{ l[NR%8] = l[NR%8] " " $0 } END {for (i in l) if (i>0) print l[i] }' ) | awk '{ l[(NR-1)%8] = l[(NR-1)%8] " " $0 } END {for (i in l) print l[i] }'
fi fi
exit exit
fi fi

View File

@@ -12,15 +12,12 @@
# @input $1: Start date/date-time # @input $1: Start date/date-time
# @input $2: End date/date-time # @input $2: End date/date-time
# @input $3: Path to iCalendar file (relative to `$ROOT`) # @input $3: Path to iCalendar file (relative to `$ROOT`)
# @req $AWK_GET: Awk script to extract fields from iCalendar file
# @req $AWK_UPDATE: Awk script to update iCalendar file
# @req $EDITOR: Environment variable of your favorite editor
__edit() { __edit() {
start=$(__datetime_human_machine "$1") start=$(__datetime_human_machine "$1")
end=$(__datetime_human_machine "$2") end=$(__datetime_human_machine "$2")
fpath="$ROOT/$3" fpath="$ROOT/$3"
location=$(awk -v field="LOCATION" "$AWK_GET" "$fpath") location=$(awk -v field="LOCATION" "$AWK_GET" "$fpath" | tr -d "\n")
summary=$(awk -v field="SUMMARY" "$AWK_GET" "$fpath") summary=$(awk -v field="SUMMARY" "$AWK_GET" "$fpath" | tr -d "\n")
description=$(awk -v field="DESCRIPTION" "$AWK_GET" "$fpath") description=$(awk -v field="DESCRIPTION" "$AWK_GET" "$fpath")
filetmp=$(mktemp --suffix='.md') filetmp=$(mktemp --suffix='.md')
printf "::: |> %s\n::: <| %s\n" "$start" "$end" >"$filetmp" printf "::: |> %s\n::: <| %s\n" "$start" "$end" >"$filetmp"
@@ -61,12 +58,6 @@ __edit() {
# If the user specified a malformed date/date-time, we fail. # If the user specified a malformed date/date-time, we fail.
# #
# @input $1 (optional): Date or datetime, defaults to today. # @input $1 (optional): Date or datetime, defaults to today.
# @req $COLLECTION_LABELS: Mapping between collections and lables (see configuration)
# @req $UUIDGEN: `uuidgen` command
# @req $ROOT: Path that contains the collections (see configuration)
# @req $EDITOR: Environment variable of your favorite editor
# @req $AWK_GET: Awk script to extract fields from iCalendar file
# @req $AWK_new: Awk script to generate iCalendar file
__new() { __new() {
collection=$(echo "$COLLECTION_LABELS" | tr ';' '\n' | awk '/./ {print}' | $FZF --margin="30%" --no-info --delimiter='=' --with-nth=2 --accept-nth=1) collection=$(echo "$COLLECTION_LABELS" | tr ';' '\n' | awk '/./ {print}' | $FZF --margin="30%" --no-info --delimiter='=' --with-nth=2 --accept-nth=1)
fpath="" fpath=""
@@ -119,8 +110,6 @@ __new() {
# Delete iCalendar file # Delete iCalendar file
# #
# @input $1: Path to iCalendar file, relative to `$ROOT` # @input $1: Path to iCalendar file, relative to `$ROOT`
# @req $ROOT: Path that contains the collections (see configuration)
# @req $AWK_GET: Awk script to extract fields from iCalendar file
__delete() { __delete() {
fpath="$ROOT/$1" fpath="$ROOT/$1"
summary=$(awk -v field="SUMMARY" "$AWK_GET" "$fpath") summary=$(awk -v field="SUMMARY" "$AWK_GET" "$fpath")
@@ -152,9 +141,6 @@ __delete() {
# #
# @input $1: path to iCalendar file # @input $1: path to iCalendar file
# @input $2: collection name # @input $2: collection name
# @req $ROOT: Path that contains the collections (see configuration)
# @req $UUIDGEN: `uuidgen` command
# @req $AWK_SET: Awk script to set field value
__import_to_collection() { __import_to_collection() {
file="$1" file="$1"
collection="$2" collection="$2"
@@ -175,9 +161,6 @@ __import_to_collection() {
# Set status of appointment to CANCELLED or CONFIRMED (toggle) # Set status of appointment to CANCELLED or CONFIRMED (toggle)
# #
# @input $1: path to iCalendar file # @input $1: path to iCalendar file
# @req $ROOT: Path that contains the collections (see configuration)
# @req $AWK_SET: Awk script to set field value
# @req $AWK_GET: Awk script to extract fields from iCalendar file
__cancel_toggle() { __cancel_toggle() {
fpath="$ROOT/$1" fpath="$ROOT/$1"
status=$(awk -v field="STATUS" "$AWK_GET" "$fpath") status=$(awk -v field="STATUS" "$AWK_GET" "$fpath")
@@ -197,9 +180,6 @@ __cancel_toggle() {
# Toggle status flag: CONFIRMED <-> TENTATIVE # Toggle status flag: CONFIRMED <-> TENTATIVE
# #
# @input $1: path to iCalendar file # @input $1: path to iCalendar file
# @req $ROOT: Path that contains the collections (see configuration)
# @req $AWK_SET: Awk script to set field value
# @req $AWK_GET: Awk script to extract fields from iCalendar file
__tentative_toggle() { __tentative_toggle() {
fpath="$ROOT/$1" fpath="$ROOT/$1"
status=$(awk -v field="STATUS" "$AWK_GET" "$fpath") status=$(awk -v field="STATUS" "$AWK_GET" "$fpath")
@@ -219,9 +199,6 @@ __tentative_toggle() {
# Prepend attachment to iCalendar file # Prepend attachment to iCalendar file
# #
# @input $1: path to iCalendar file # @input $1: path to iCalendar file
# @req $ROOT: Path that contains the collections (see configuration)
# @req $FZF: Fuzzy finder
# @req $AWK_ATTACH: Awk script to add attachment
__add_attachment() { __add_attachment() {
fpath="$ROOT/$1" fpath="$ROOT/$1"
sel=$( sel=$(

View File

@@ -36,6 +36,10 @@ __refresh_data() {
WEEKLY_DATA_FILE=$(mktemp) WEEKLY_DATA_FILE=$(mktemp)
trap 'rm -f "$WEEKLY_DATA_FILE"' EXIT INT trap 'rm -f "$WEEKLY_DATA_FILE"' EXIT INT
fi fi
debug "__refresh_data(): going to load approx data"
__load_approx_data >"$APPROX_DATA_FILE" __load_approx_data >"$APPROX_DATA_FILE"
debug "__refresh_data(): approx data loaded"
debug "__refresh_data(): going to load weeks"
__load_weeks >"$WEEKLY_DATA_FILE" __load_weeks >"$WEEKLY_DATA_FILE"
debug "__refresh_data(): weeks loaded"
} }

View File

@@ -6,6 +6,14 @@ err() {
echo "$1" >/dev/tty echo "$1" >/dev/tty
} }
# debug()
# Pring debug message to fzf-vcal.debug
#
# @input $1: Debug message
debug() {
echo "$(date +"%D %T.%N"): $1" >>"/tmp/fzf-vcal.debug"
}
# Print date or datetime in a human and machine readable form. # Print date or datetime in a human and machine readable form.
# #
# @input $1: Seconds since epoch # @input $1: Seconds since epoch

View File

@@ -10,7 +10,8 @@ ITALIC="\033[3m"
FAINT="\033[2m" FAINT="\033[2m"
BOLD="\033[1m" BOLD="\033[1m"
BG="\033[41m" BG="\033[41m"
OFF="\033[m"
export OFF="\033[m"
# Style # Style
# Calendar # Calendar
@@ -36,6 +37,7 @@ export STYLE_DV_TENTATIVE="${STYLE_DV_TENTATIVE:-$FAINT$CYAN}"
export STYLE_DV_CANCELLED="${STYLE_DV_CANCELLED:-$STRIKE$CYAN}" export STYLE_DV_CANCELLED="${STYLE_DV_CANCELLED:-$STRIKE$CYAN}"
export STYLE_DV_HOUR="${STYLE_DV_HOUR:-$FAINT}" export STYLE_DV_HOUR="${STYLE_DV_HOUR:-$FAINT}"
export STYLE_DV_EMPTYHOUR="${STYLE_DV_EMPTYHOUR:-$FAINT----------------------$OFF}" export STYLE_DV_EMPTYHOUR="${STYLE_DV_EMPTYHOUR:-$FAINT----------------------$OFF}"
export STYLE_DV_TZ="$WHITE$ITALIC"
# Event preview # Event preview
export STYLE_EPV_DATETIME="${STYLE_EPV_DATETIME:-$CYAN}" export STYLE_EPV_DATETIME="${STYLE_EPV_DATETIME:-$CYAN}"

View File

@@ -77,21 +77,22 @@ __view_day() {
# This function prints the view for the week that contains the day specified in `$DISPLAY_DATE`. # This function prints the view for the week that contains the day specified in `$DISPLAY_DATE`.
__view_week() { __view_week() {
debug "__view_week(): Enter"
weeknr=$(date -d "$DISPLAY_DATE" +"%G:%V:") weeknr=$(date -d "$DISPLAY_DATE" +"%G:%V:")
files=$(grep "^$weeknr" "$WEEKLY_DATA_FILE" | cut -f 2) files=$(grep "^$weeknr" "$WEEKLY_DATA_FILE" | cut -f 2)
dayofweek=$(date -d "$DISPLAY_DATE" +"%u") dayofweek=$(date -d "$DISPLAY_DATE" +"%u")
delta=$((1 - dayofweek)) delta=$((1 - dayofweek))
startofweek=$(date -d "$DISPLAY_DATE -$delta days" +"%D") startofweek=$(date -d "$DISPLAY_DATE -$delta days" +"%D")
# loop over files # loop over files
debug "__view_week(): loop over files"
sef=$({ sef=$({
set -- $files printf "%s" "$files" | xargs -d " " -I {} -P0 \
for file in "$@"; do
file="$ROOT/$file"
awk \ awk \
-v collection_labels="$COLLECTION_LABELS" \ -v collection_labels="$COLLECTION_LABELS" \
"$AWK_PARSE" "$file" "$AWK_PARSE" "$ROOT/{}"
done
}) })
debug "__view_week(): loop over files ended"
debug "__view_week(): prepare week view"
if [ -n "$sef" ]; then if [ -n "$sef" ]; then
sef=$(echo "$sef" | while IFS= read -r line; do sef=$(echo "$sef" | while IFS= read -r line; do
set -- $line set -- $line
@@ -134,6 +135,8 @@ __view_week() {
done done
done) done)
fi fi
debug "__view_week(): prepare week view ended"
debug "__view_week(): generate week view"
sef=$({ sef=$({
echo "$sef" echo "$sef"
seq 0 7 seq 0 7
@@ -145,6 +148,7 @@ __view_week() {
-v style_summary="$STYLE_WV_SUMMARY" \ -v style_summary="$STYLE_WV_SUMMARY" \
-v style_time="$STYLE_WV_TIME" \ -v style_time="$STYLE_WV_TIME" \
"$AWK_WEEKVIEW" "$AWK_WEEKVIEW"
debug "__view_week(): generate week view ended"
} }
# This function prints all entries. # This function prints all entries.