Compare commits
1 Commits
main
...
7822f27a4f
Author | SHA1 | Date | |
---|---|---|---|
7822f27a4f |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1 @@
|
|||||||
fzf-vcal
|
fzf-vcal
|
||||||
fzf-vcal.debug
|
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
## 5. filename (collection/name)
|
## 5. filename (collection/name)
|
||||||
##
|
##
|
||||||
## @assign collection_labels: See configuration of the current program.
|
## @assign collection_labels: See configuration of the current program.
|
||||||
## @assign style_line: Style for each line
|
|
||||||
|
|
||||||
@include "lib/awk/icalendar.awk"
|
@include "lib/awk/icalendar.awk"
|
||||||
|
|
||||||
@@ -35,11 +34,11 @@ function fn(path, n, a) {
|
|||||||
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
|
||||||
return style_line "~ " collection " " gensub(/^[^0-9]*([0-9]{4})([0-9]{2}).*$/, "\\1-\\2", "1", start) " " summary OFF
|
return FAINT "~ " collection " " gensub(/^[^0-9]*([0-9]{4})([0-9]{2}).*$/, "\\1-\\2", "1", start) " " summary OFF
|
||||||
}
|
}
|
||||||
|
|
||||||
# AWK program
|
# AWK program
|
||||||
@@ -53,12 +52,13 @@ BEGIN {
|
|||||||
collection2label[m[1]] = m[2]
|
collection2label[m[1]] = m[2]
|
||||||
}
|
}
|
||||||
# Colors
|
# Colors
|
||||||
|
FAINT = "\033[2m"
|
||||||
OFF = "\033[m"
|
OFF = "\033[m"
|
||||||
}
|
}
|
||||||
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_dt(getparam($0), getcontent($0)) }
|
/^DTSTART/ && inside { start = parse() }
|
||||||
/^DTEND/ && inside { end = parse_dt(getparam($0), getcontent($0)) }
|
/^DTEND/ && inside { end = parse() }
|
||||||
/^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) }
|
||||||
|
@@ -3,24 +3,22 @@
|
|||||||
##
|
##
|
||||||
## @assign cur: Day-of-month to mark as `today`
|
## @assign cur: Day-of-month to mark as `today`
|
||||||
## @assign day: Day-of-month to highlight
|
## @assign day: Day-of-month to highlight
|
||||||
## @assign style_month: Theme to use for month
|
|
||||||
## @assign style_weekdays: Theme to use for weekdays
|
|
||||||
## @assign style_cur: Theme to use for current day
|
|
||||||
## @assign style_highlight: Theme to use for highlighted day
|
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
|
BLACK = "\033[1;30m"
|
||||||
|
GREEN = "\033[1;32m"
|
||||||
|
RED = "\033[1;31m"
|
||||||
|
FAINT = "\033[2m"
|
||||||
|
BOLD = "\033[1m"
|
||||||
|
BG = "\033[41m"
|
||||||
OFF = "\033[m"
|
OFF = "\033[m"
|
||||||
day = day + 0
|
day = day + 0
|
||||||
cur = cur + 0
|
cur = cur + 0
|
||||||
}
|
}
|
||||||
NR == 1 { print style_month $0 OFF; next }
|
NR == 1 { print GREEN $0 OFF; next }
|
||||||
NR == 2 { print style_weekdays $0 OFF; next }
|
NR == 2 { print FAINT $0 OFF; next }
|
||||||
{
|
{
|
||||||
if (day == cur) {
|
sub("\\y"cur"\\y", BG BLACK BOLD cur OFF)
|
||||||
sub("\\y"cur"\\y", style_highlight style_cur cur OFF)
|
sub("\\y"day"\\y", RED BOLD day OFF)
|
||||||
} else {
|
|
||||||
sub("\\y"cur"\\y", style_cur cur OFF)
|
|
||||||
sub("\\y"day"\\y", style_highlight day OFF)
|
|
||||||
}
|
|
||||||
print
|
print
|
||||||
}
|
}
|
||||||
|
@@ -21,13 +21,6 @@
|
|||||||
## @assign today: Date of `today` in the format %D (%m/%d/%y)
|
## @assign today: Date of `today` in the format %D (%m/%d/%y)
|
||||||
## @assign daystart: Hour of start of the day
|
## @assign daystart: Hour of start of the day
|
||||||
## @assign dayend: Hour of end of the day
|
## @assign dayend: Hour of end of the day
|
||||||
## @assign style_allday
|
|
||||||
## @assign style_timerange
|
|
||||||
## @assign style_confirmed
|
|
||||||
## @assign style_tentative
|
|
||||||
## @assign style_cancelled
|
|
||||||
## @assign style_hour
|
|
||||||
## @assign style_emptyhour
|
|
||||||
|
|
||||||
# Functions
|
# Functions
|
||||||
|
|
||||||
@@ -36,7 +29,7 @@
|
|||||||
# @input status: Event status, one of TENTATIVE, CONFIRMED, CANCELLED
|
# @input status: Event status, one of TENTATIVE, CONFIRMED, CANCELLED
|
||||||
# @return: Color modifier
|
# @return: Color modifier
|
||||||
function color_from_status(status) {
|
function color_from_status(status) {
|
||||||
return status == "CANCELLED" ? style_cancelled : status == "TENTATIVE" ? style_tentative : style_confirmed
|
return status == "CANCELLED" ? STRIKE CYAN : status == "TENTATIVE" ? FAINT CYAN : CYAN
|
||||||
}
|
}
|
||||||
|
|
||||||
# Return line for all-day event.
|
# Return line for all-day event.
|
||||||
@@ -48,7 +41,7 @@ function color_from_status(status) {
|
|||||||
# @return: Single-line string
|
# @return: Single-line string
|
||||||
function allday(collection, desc, status, color) {
|
function allday(collection, desc, status, color) {
|
||||||
color = color_from_status(status)
|
color = color_from_status(status)
|
||||||
return collection " " style_allday color desc OFF
|
return collection " " LIGHT_CYAN ITALIC FAINT " (allday) " OFF color desc OFF
|
||||||
}
|
}
|
||||||
|
|
||||||
# Return line for multi-day event, or event that starts at midnight, which ends today.
|
# Return line for multi-day event, or event that starts at midnight, which ends today.
|
||||||
@@ -61,7 +54,7 @@ function allday(collection, desc, status, color) {
|
|||||||
# @return: Single-line string
|
# @return: Single-line string
|
||||||
function endstoday(stop, collection, desc, status) {
|
function endstoday(stop, collection, desc, status) {
|
||||||
color = color_from_status(status)
|
color = color_from_status(status)
|
||||||
return collection " " style_timerange " → " stop ": " OFF color desc OFF
|
return collection " " LIGHT_CYAN " → " stop ": " OFF color desc OFF
|
||||||
}
|
}
|
||||||
|
|
||||||
# Return line for event that starts sometime today.
|
# Return line for event that starts sometime today.
|
||||||
@@ -76,9 +69,9 @@ function endstoday(stop, collection, desc, status) {
|
|||||||
function slice(start, stop, collection, desc, status) {
|
function slice(start, stop, collection, desc, status) {
|
||||||
color = color_from_status(status)
|
color = color_from_status(status)
|
||||||
if (stop == "00:00")
|
if (stop == "00:00")
|
||||||
return collection " " style_timerange start " → " ": " OFF color desc OFF
|
return collection " " LIGHT_CYAN start " → " ": " OFF color desc OFF
|
||||||
else
|
else
|
||||||
return collection " " style_timerange start " – " stop ": " OFF color desc OFF
|
return collection " " LIGHT_CYAN start " – " stop ": " OFF color desc OFF
|
||||||
}
|
}
|
||||||
|
|
||||||
# Print line for a single hour entry.
|
# Print line for a single hour entry.
|
||||||
@@ -86,7 +79,7 @@ function slice(start, stop, collection, desc, status) {
|
|||||||
# @input hour: Hour of the entry
|
# @input hour: Hour of the entry
|
||||||
function hrline(hour) {
|
function hrline(hour) {
|
||||||
hour = hour < 10 ? "0"hour : hour
|
hour = hour < 10 ? "0"hour : hour
|
||||||
print today, hour, "", "", "", " " style_hou hour ":00" OFF " " style_emptyhour
|
print today, hour, "", "", "", " " FAINT hour ":00 ----------------------" OFF
|
||||||
}
|
}
|
||||||
|
|
||||||
# Print lines for hour entries before an event that starts at `start` and stops
|
# Print lines for hour entries before an event that starts at `start` and stops
|
||||||
@@ -114,6 +107,11 @@ function hrlines(start, stop, h, starth, stoph, tmp, i) {
|
|||||||
BEGIN {
|
BEGIN {
|
||||||
FS = "\t"
|
FS = "\t"
|
||||||
OFS = "\t"
|
OFS = "\t"
|
||||||
|
LIGHT_CYAN = "\033[1;36m"
|
||||||
|
CYAN = "\033[1;36m"
|
||||||
|
ITALIC = "\033[3m"
|
||||||
|
FAINT = "\033[2m"
|
||||||
|
STRIKE = "\033[9m"
|
||||||
OFF = "\033[m"
|
OFF = "\033[m"
|
||||||
}
|
}
|
||||||
$1 == "00:00" && $2 == "00:00" { print today, $1, $3, $4, $5, allday($6, $7, $8); next }
|
$1 == "00:00" && $2 == "00:00" { print today, $1, $3, $4, $5, allday($6, $7, $8); next }
|
||||||
|
@@ -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_dt(getparam($0), getcontent($0)) }
|
/^DTSTART/ && inside { start = parse() }
|
||||||
/^DTEND/ && inside { end = parse_dt(getparam($0), getcontent($0)) }
|
/^DTEND/ && inside { end = parse() }
|
||||||
/^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 }
|
||||||
|
@@ -4,10 +4,6 @@
|
|||||||
## printf "%s\t%s\t%s\t%s\n" "$i" "$s" "$e" "$description"
|
## printf "%s\t%s\t%s\t%s\n" "$i" "$s" "$e" "$description"
|
||||||
##
|
##
|
||||||
## @assign startofweek: Date of first day in the week
|
## @assign startofweek: Date of first day in the week
|
||||||
## @assign style_day: Style for dates
|
|
||||||
## @assign style_event_delim: Event delimiter
|
|
||||||
## @assign style_summary: Style for summary lines
|
|
||||||
## @assign style_time: Style for times
|
|
||||||
|
|
||||||
# Functions
|
# Functions
|
||||||
|
|
||||||
@@ -16,7 +12,7 @@
|
|||||||
# @input desc: String with a description of the event
|
# @input desc: String with a description of the event
|
||||||
# @return: Single-line string
|
# @return: Single-line string
|
||||||
function c(desc) {
|
function c(desc) {
|
||||||
return style_summary desc OFF " " style_event_delim
|
return CYAN desc OFF " " RED "/" OFF
|
||||||
}
|
}
|
||||||
|
|
||||||
# AWK program
|
# AWK program
|
||||||
@@ -24,16 +20,19 @@ function c(desc) {
|
|||||||
BEGIN {
|
BEGIN {
|
||||||
FS = "\t"
|
FS = "\t"
|
||||||
OFS = "\t"
|
OFS = "\t"
|
||||||
|
GREEN = "\033[1;32m"
|
||||||
|
RED = "\033[1;31m"
|
||||||
|
CYAN = "\033[1;36m"
|
||||||
OFF = "\033[m"
|
OFF = "\033[m"
|
||||||
}
|
}
|
||||||
$2 == "00:00" && $3 == "00:00" { dayline = dayline " " c($4); next }
|
$2 == "00:00" && $3 == "00:00" { dayline = dayline " " c($4); next }
|
||||||
$2 == "00:00" { dayline = dayline style_time " → " $3 OFF " " c($4); next }
|
$2 == "00:00" { dayline = dayline " → " $3 " " c($4); next }
|
||||||
$3 == "00:00" { dayline = dayline style_time " " $2 " → " OFF c($4); next }
|
$3 == "00:00" { dayline = dayline " " $2 " → " c($4); next }
|
||||||
NF == 4 { dayline = dayline style_time " " $2 " – " $3 OFF " " c($4); next }
|
NF == 4 { dayline = dayline " " $2 " – " $3 " " c($4); next }
|
||||||
NF == 1 && dayline { print "+", startofweek " +" $1-1 " days", "", dayline }
|
NF == 1 && dayline { print "+", startofweek " +" $1-1 " days", "", dayline }
|
||||||
NF == 1 {
|
NF == 1 {
|
||||||
cmd = "date -d '" startofweek " +" $1 " days' +\"%a %e %b %Y\""
|
cmd = "date -d '" startofweek " +" $1 " days' +\"%a %e %b %Y\""
|
||||||
cmd | getline dayline
|
cmd | getline dayline
|
||||||
close(cmd)
|
close(cmd)
|
||||||
dayline = style_day dayline ": " OFF
|
dayline = GREEN dayline ": " OFF
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
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
|
||||||
@@ -58,17 +57,6 @@ 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
|
||||||
@@ -77,27 +65,22 @@ function getcontent(str) {
|
|||||||
return unescape(substr(str, index(str, ":") + 1))
|
return unescape(substr(str, index(str, ":") + 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
# Time-zone aware parsing of DTSTART or DTEND entries.
|
# Time-zone aware parsing of the date/date-time entry at the current record.
|
||||||
#
|
#
|
||||||
# @local variables: tz
|
# @local variables: dt
|
||||||
# @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(dt_param, dt_content, tz, a, i, k) {
|
function parse( dt) {
|
||||||
if (dt_param) {
|
# Get timezone information
|
||||||
split(dt_param, a, ";")
|
for (i=2; i<NF-1; i+=2) {
|
||||||
for (i in a) {
|
if ($i == "TZID") {
|
||||||
k = index(a[i], "=")
|
dt = "TZ=\"" $(i+1) "\" "
|
||||||
if (substr(a[i], 1, k-1) == "TZID") {
|
|
||||||
tz = "TZ=\"" substr(a[i], k + 1) "\" "
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
# Get date/date-time
|
# Get date/date-time
|
||||||
return length(dt_content) == 8 ?
|
return length($NF) == 8 ?
|
||||||
dt dt_content :
|
dt $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)
|
dt gensub(/^([0-9]{8})T([0-9]{2})([0-9]{2})([0-9]{2})(Z)?$/, "\\1 \\2:\\3:\\4\\5", "g", $NF)
|
||||||
}
|
}
|
||||||
|
|
||||||
# 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).
|
||||||
|
90
src/main.sh
90
src/main.sh
@@ -32,9 +32,6 @@ EOF
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Configuration
|
|
||||||
. "sh/config.sh"
|
|
||||||
|
|
||||||
# Theme
|
# Theme
|
||||||
. "sh/theme.sh"
|
. "sh/theme.sh"
|
||||||
|
|
||||||
@@ -53,6 +50,9 @@ fi
|
|||||||
# Reloading command-line options
|
# Reloading command-line options
|
||||||
. "sh/clireload.sh"
|
. "sh/clireload.sh"
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
. "sh/config.sh"
|
||||||
|
|
||||||
# Access to awk scripts
|
# Access to awk scripts
|
||||||
. "sh/awkscripts.sh"
|
. "sh/awkscripts.sh"
|
||||||
|
|
||||||
@@ -68,6 +68,24 @@ fi
|
|||||||
### Start
|
### Start
|
||||||
__refresh_data
|
__refresh_data
|
||||||
|
|
||||||
|
### Exports
|
||||||
|
# The preview calls run in subprocesses. These require the following variables:
|
||||||
|
export ROOT CAT AWK_GET AWK_CALSHIFT AWK_CALANNOT CYAN STRIKE FAINT WHITE ITALIC OFF AWK_ATTACHLS
|
||||||
|
# The reload commands also run in subprocesses, and use in addition
|
||||||
|
export COLLECTION_LABELS DAY_START DAY_END AWK_DAYVIEW AWK_WEEKVIEW AWK_PARSE
|
||||||
|
# as well as the following variables that will be dynamically specified. So, we
|
||||||
|
# export them in the main loop using the following function.
|
||||||
|
|
||||||
|
# __export()
|
||||||
|
# Re-export dynamical variables to subshells.
|
||||||
|
__export() {
|
||||||
|
DISPLAY_DATE=$(date -R -d "$DISPLAY_DATE")
|
||||||
|
export DISPLAY_DATE WEEKLY_DATA_FILE APPROX_DATA_FILE
|
||||||
|
if [ -n "${TZ:-}" ]; then
|
||||||
|
export TZ
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
###
|
###
|
||||||
### Main loop with the command-line argument
|
### Main loop with the command-line argument
|
||||||
### --today
|
### --today
|
||||||
@@ -163,34 +181,30 @@ 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:$STYLE_DV_TZ($TZ)$OFF"
|
[ -n \"\${TZ:-}\" ] && echo \"change-list-label:\$WHITE\$ITALIC(\$TZ)\$OFF\"
|
||||||
)+transform(
|
)+transform(
|
||||||
[ -n {5} ] && echo show-preview
|
[ -n \"\$(echo {} | cut -f 5)\" ] && echo show-preview
|
||||||
)' \
|
)" \
|
||||||
--bind="start:hide-preview" \
|
--bind="start:hide-preview" \
|
||||||
--bind="j:down" \
|
--bind="j:down+hide-preview+transform([ -n \"\$(echo {} | cut -f 5)\" ] && echo show-preview)" \
|
||||||
--bind="k:up" \
|
--bind="k:up+hide-preview+transform([ -n \"\$(echo {} | cut -f 5)\" ] && echo show-preview)" \
|
||||||
--bind="l:reload:$0 --reload-day {1} '+1 day'" \
|
--bind="ctrl-j:down+hide-preview+transform([ -n \"\$(echo {} | cut -f 5)\" ] && echo show-preview)" \
|
||||||
--bind="h:reload:$0 --reload-day {1} '-1 day'" \
|
--bind="ctrl-k:up+hide-preview+transform([ -n \"\$(echo {} | cut -f 5)\" ] && echo show-preview)" \
|
||||||
--bind="right:reload:$0 --reload-day {1} '+1 day'" \
|
--bind="down:down+hide-preview+transform([ -n \"\$(echo {} | cut -f 5)\" ] && echo show-preview)" \
|
||||||
--bind="left:reload:$0 --reload-day {1} '-1 day'" \
|
--bind="up:up+hide-preview+transform([ -n \"\$(echo {} | cut -f 5)\" ] && echo show-preview)" \
|
||||||
--bind="ctrl-l:reload:$0 --reload-day {1} '+1 week'" \
|
--bind="l:hide-preview+reload:$0 --reload-day {1} '+1 day'" \
|
||||||
--bind="ctrl-h:reload:$0 --reload-day {1} '-1 week'" \
|
--bind="h:hide-preview+reload:$0 --reload-day {1} '-1 day'" \
|
||||||
--bind="alt-l:reload:$0 --reload-day {1} '+1 month'" \
|
--bind="right:hide-preview+reload:$0 --reload-day {1} '+1 day'" \
|
||||||
--bind="alt-h:reload:$0 --reload-day {1} '-1 month'" \
|
--bind="left:hide-preview+reload:$0 --reload-day {1} '-1 day'" \
|
||||||
--bind="ctrl-r:reload:$0 --reload-day today" \
|
--bind="ctrl-l:hide-preview+reload:$0 --reload-day {1} '+1 week'" \
|
||||||
|
--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"
|
||||||
@@ -243,7 +257,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" ||
|
||||||
@@ -367,21 +381,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,8,border-bottom \
|
--preview-window=up,7,border-bottom \
|
||||||
--preview="$0 --preview-week {}" \
|
--preview="$0 --preview-week {}" \
|
||||||
--bind="load:pos($DISPLAY_POS)+unbind(load)" \
|
--bind="load:pos($DISPLAY_POS)" \
|
||||||
--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:reload:$0 --reload-week {2} '+1 week'" \
|
--bind="l:unbind(load)+reload:$0 --reload-week {2} '+1 week'" \
|
||||||
--bind="h:reload:$0 --reload-week {2} '-1 week'" \
|
--bind="h:unbind(load)+reload:$0 --reload-week {2} '-1 week'" \
|
||||||
--bind="right:reload:$0 --reload-week {2} '+1 week'" \
|
--bind="right:unbind(load)+reload:$0 --reload-week {2} '+1 week'" \
|
||||||
--bind="left:reload:$0 --reload-week {2} '-1 week'" \
|
--bind="left:unbind(load)+reload:$0 --reload-week {2} '-1 week'" \
|
||||||
--bind="ctrl-l:reload:$0 --reload-week {2} '+1 month'" \
|
--bind="ctrl-l:unbind(load)+reload:$0 --reload-week {2} '+1 month'" \
|
||||||
--bind="ctrl-h:reload:$0 --reload-week {2} '-1 month'" \
|
--bind="ctrl-h:unbind(load)+reload:$0 --reload-week {2} '-1 month'" \
|
||||||
--bind="alt-l:reload:$0 --reload-week {2} '+1 year'" \
|
--bind="alt-l:unbind(load)+reload:$0 --reload-week {2} '+1 year'" \
|
||||||
--bind="alt-h:reload:$0 --reload-week {2} '-1 year'" \
|
--bind="alt-h:unbind(load)+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" \
|
||||||
|
@@ -20,102 +20,87 @@ AWK_APPROX=$(
|
|||||||
@@include awk/approx.awk
|
@@include awk/approx.awk
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export AWK_APPROX
|
|
||||||
|
|
||||||
AWK_MERGE=$(
|
AWK_MERGE=$(
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
@@include awk/merge.awk
|
@@include awk/merge.awk
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export AWK_MERGE
|
|
||||||
|
|
||||||
AWK_PARSE=$(
|
AWK_PARSE=$(
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
@@include awk/parse.awk
|
@@include awk/parse.awk
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export AWK_PARSE
|
|
||||||
|
|
||||||
AWK_WEEKVIEW=$(
|
AWK_WEEKVIEW=$(
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
@@include awk/weekview.awk
|
@@include awk/weekview.awk
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export AWK_WEEKVIEW
|
|
||||||
|
|
||||||
AWK_DAYVIEW=$(
|
AWK_DAYVIEW=$(
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
@@include awk/dayview.awk
|
@@include awk/dayview.awk
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export AWK_DAYVIEW
|
|
||||||
|
|
||||||
AWK_GET=$(
|
AWK_GET=$(
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
@@include awk/get.awk
|
@@include awk/get.awk
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export AWK_GET
|
|
||||||
|
|
||||||
AWK_UPDATE=$(
|
AWK_UPDATE=$(
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
@@include awk/update.awk
|
@@include awk/update.awk
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export AWK_UPDATE
|
|
||||||
|
|
||||||
AWK_NEW=$(
|
AWK_NEW=$(
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
@@include awk/new.awk
|
@@include awk/new.awk
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export AWK_NEW
|
|
||||||
|
|
||||||
AWK_CALSHIFT=$(
|
AWK_CALSHIFT=$(
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
@@include awk/calshift.awk
|
@@include awk/calshift.awk
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export AWK_CALSHIFT
|
|
||||||
|
|
||||||
AWK_CALANNOT=$(
|
AWK_CALANNOT=$(
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
@@include awk/calannot.awk
|
@@include awk/calannot.awk
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export AWK_CALANNOT
|
|
||||||
|
|
||||||
AWK_SET=$(
|
AWK_SET=$(
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
@@include awk/set.awk
|
@@include awk/set.awk
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export AWK_SET
|
|
||||||
|
|
||||||
AWK_ATTACHLS=$(
|
AWK_ATTACHLS=$(
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
@@include awk/attachls.awk
|
@@include awk/attachls.awk
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export AWK_ATTACHLS
|
|
||||||
|
|
||||||
AWK_ATTACHDD=$(
|
AWK_ATTACHDD=$(
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
@@include awk/attachdd.awk
|
@@include awk/attachdd.awk
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export AWK_ATTACHDD
|
|
||||||
|
|
||||||
AWK_ATTACHRM=$(
|
AWK_ATTACHRM=$(
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
@@include awk/attachrm.awk
|
@@include awk/attachrm.awk
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export AWK_ATTACHRM
|
|
||||||
|
|
||||||
AWK_ATTACH=$(
|
AWK_ATTACH=$(
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
@@include awk/attach.awk
|
@@include awk/attach.awk
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
export AWK_ATTACH
|
|
||||||
|
@@ -21,9 +21,9 @@ if [ "${1:-}" = "--preview-event" ]; then
|
|||||||
elif [ "$status" = "CANCELLED" ]; then
|
elif [ "$status" = "CANCELLED" ]; then
|
||||||
symb="❌"
|
symb="❌"
|
||||||
fi
|
fi
|
||||||
echo "📅${symb:-} ${STYLE_EPV_DATETIME}$start${OFF} → ${STYLE_EPV_DATETIME}$end${OFF}"
|
echo "📅${symb:-} ${CYAN}$start${OFF} → ${CYAN}$end${OFF}"
|
||||||
if [ -n "${location:-}" ]; then
|
if [ -n "${location:-}" ]; then
|
||||||
echo "📍 ${STYLE_EPV_LOCATION}$location${OFF}"
|
echo "📍 ${CYAN}$location${OFF}"
|
||||||
fi
|
fi
|
||||||
attcnt=$(awk "$AWK_ATTACHLS" "$fpath" | wc -l)
|
attcnt=$(awk "$AWK_ATTACHLS" "$fpath" | wc -l)
|
||||||
if [ "$attcnt" -gt 0 ]; then
|
if [ "$attcnt" -gt 0 ]; then
|
||||||
@@ -88,13 +88,13 @@ if [ "${1:-}" = "--preview-week" ]; then
|
|||||||
fi
|
fi
|
||||||
# show
|
# show
|
||||||
(
|
(
|
||||||
cal "$month_pre2" "$year_pre2" | awk "$AWK_CALSHIFT" | awk -v cur="${var_pre2:-}" -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" -v style_weekdays="$STYLE_CALENDAR_WEEKDAYS" -v style_cur="$STYLE_CALENDAR_CURRENT_DAY" -v style_highlight="$STYLE_CALENDAR_HL_DAY" "$AWK_CALANNOT"
|
cal "$month_pre2" "$year_pre2" | awk "$AWK_CALSHIFT" | awk -v cur="${var_pre2:-}" "$AWK_CALANNOT"
|
||||||
cal "$month_pre" "$year_pre" | awk "$AWK_CALSHIFT" | awk -v cur="${var_pre:-}" -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_pre" "$year_pre" | awk "$AWK_CALSHIFT" | awk -v cur="${var_pre:-}" "$AWK_CALANNOT"
|
||||||
cal "$month" "$year" | awk "$AWK_CALSHIFT" | awk -v cur="${var:-}" -v day="$day" -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" "$year" | awk "$AWK_CALSHIFT" | awk -v cur="${var:-}" -v day="$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_nex" "$year_nex" | awk "$AWK_CALSHIFT" | awk -v cur="${var_nex:-}" "$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:-}" "$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:-}" "$AWK_CALANNOT"
|
||||||
) | awk '{ l[(NR-1)%8] = l[(NR-1)%8] " " $0 } END {for (i in l) print l[i] }'
|
) | awk '{ l[NR%8] = l[NR%8] " " $0 } END {for (i in l) if (i>0) print l[i] }'
|
||||||
fi
|
fi
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
@@ -20,16 +20,15 @@ if [ -z "${ROOT:-}" ] || [ -z "${COLLECTION_LABELS:-}" ]; then
|
|||||||
err "Configuration is incomplete."
|
err "Configuration is incomplete."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
export ROOT COLLECTION_LABELS
|
SYNC_CMD=${SYNC_CMD:-echo 'Synchronization disabled'}
|
||||||
export SYNC_CMD=${SYNC_CMD:-echo 'Synchronization disabled'}
|
DAY_START=${DAY_START:-8}
|
||||||
export DAY_START=${DAY_START:-8}
|
DAY_END=${DAY_END:-18}
|
||||||
export DAY_END=${DAY_END:-18}
|
ZI_DIR=${ZI_DIR:-/usr/share/zoneinfo/posix}
|
||||||
export ZI_DIR=${ZI_DIR:-/usr/share/zoneinfo/posix}
|
|
||||||
if [ ! -d "$ZI_DIR" ]; then
|
if [ ! -d "$ZI_DIR" ]; then
|
||||||
err "Could not determine time-zone information"
|
err "Could not determine time-zone information"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
export OPEN=${OPEN:-open}
|
OPEN=${OPEN:-open}
|
||||||
|
|
||||||
# Check and load required tools
|
# Check and load required tools
|
||||||
# - FZF: Fuzzy finder `fzf``
|
# - FZF: Fuzzy finder `fzf``
|
||||||
@@ -40,14 +39,14 @@ export OPEN=${OPEN:-open}
|
|||||||
# The presence of POSIX tools is not checked.
|
# The presence of POSIX tools is not checked.
|
||||||
|
|
||||||
if command -v "fzf" >/dev/null; then
|
if command -v "fzf" >/dev/null; then
|
||||||
export FZF="fzf --black"
|
FZF="fzf --black"
|
||||||
else
|
else
|
||||||
err "Did not find the command-line fuzzy finder fzf."
|
err "Did not find the command-line fuzzy finder fzf."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if command -v "uuidgen" >/dev/null; then
|
if command -v "uuidgen" >/dev/null; then
|
||||||
export UUIDGEN="uuidgen"
|
UUIDGEN="uuidgen"
|
||||||
else
|
else
|
||||||
err "Did not find the uuidgen command."
|
err "Did not find the uuidgen command."
|
||||||
exit 1
|
exit 1
|
||||||
@@ -59,8 +58,8 @@ elif command -v "batcat" >/dev/null; then
|
|||||||
CAT="batcat"
|
CAT="batcat"
|
||||||
fi
|
fi
|
||||||
CAT=${CAT:+$CAT --color=always --style=numbers --language=md}
|
CAT=${CAT:+$CAT --color=always --style=numbers --language=md}
|
||||||
export CAT=${CAT:-cat}
|
CAT=${CAT:-cat}
|
||||||
|
|
||||||
if command -v "git" >/dev/null && [ -d "$ROOT/.git" ]; then
|
if command -v "git" >/dev/null && [ -d "$ROOT/.git" ]; then
|
||||||
export GIT="git -C $ROOT"
|
GIT="git -C $ROOT"
|
||||||
fi
|
fi
|
||||||
|
@@ -12,12 +12,15 @@
|
|||||||
# @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" | tr -d "\n")
|
location=$(awk -v field="LOCATION" "$AWK_GET" "$fpath")
|
||||||
summary=$(awk -v field="SUMMARY" "$AWK_GET" "$fpath" | tr -d "\n")
|
summary=$(awk -v field="SUMMARY" "$AWK_GET" "$fpath")
|
||||||
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"
|
||||||
@@ -58,6 +61,12 @@ __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=""
|
||||||
@@ -110,6 +119,8 @@ __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")
|
||||||
@@ -141,6 +152,9 @@ __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"
|
||||||
@@ -161,6 +175,9 @@ __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")
|
||||||
@@ -180,6 +197,9 @@ __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")
|
||||||
@@ -199,6 +219,9 @@ __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=$(
|
||||||
|
@@ -9,7 +9,6 @@ __load_approx_data() {
|
|||||||
xargs -0 -P0 \
|
xargs -0 -P0 \
|
||||||
awk \
|
awk \
|
||||||
-v collection_labels="$COLLECTION_LABELS" \
|
-v collection_labels="$COLLECTION_LABELS" \
|
||||||
-v style_line="$STYLE_LV" \
|
|
||||||
"$AWK_APPROX"
|
"$AWK_APPROX"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,18 +27,15 @@ __load_weeks() {
|
|||||||
# file `$APPROX_DATA_FILE` and the output of `__load_weeks` in the temporary
|
# file `$APPROX_DATA_FILE` and the output of `__load_weeks` in the temporary
|
||||||
# file `@WEEKLY_DATA_FILE`.
|
# file `@WEEKLY_DATA_FILE`.
|
||||||
__refresh_data() {
|
__refresh_data() {
|
||||||
if [ -z "${APPROX_DATA_FILE:-}" ]; then
|
if [ -n "${APPROX_DATA_FILE:-}" ]; then
|
||||||
|
rm -f "$APPROX_DATA_FILE"
|
||||||
|
fi
|
||||||
|
if [ -n "${WEEKLY_DATA_FILE:-}" ]; then
|
||||||
|
rm -f "$WEEKLY_DATA_FILE"
|
||||||
|
fi
|
||||||
APPROX_DATA_FILE=$(mktemp)
|
APPROX_DATA_FILE=$(mktemp)
|
||||||
trap 'rm -f "$APPROX_DATA_FILE"' EXIT INT
|
|
||||||
fi
|
|
||||||
if [ -z "${WEEKLY_DATA_FILE:-}" ]; then
|
|
||||||
WEEKLY_DATA_FILE=$(mktemp)
|
|
||||||
trap 'rm -f "$WEEKLY_DATA_FILE"' EXIT INT
|
|
||||||
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"
|
WEEKLY_DATA_FILE=$(mktemp)
|
||||||
debug "__refresh_data(): going to load weeks"
|
|
||||||
__load_weeks >"$WEEKLY_DATA_FILE"
|
__load_weeks >"$WEEKLY_DATA_FILE"
|
||||||
debug "__refresh_data(): weeks loaded"
|
trap 'rm -f "$APPROX_DATA_FILE" "$WEEKLY_DATA_FILE"' EXIT INT
|
||||||
}
|
}
|
||||||
|
@@ -6,14 +6,6 @@ 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
|
||||||
@@ -33,12 +25,3 @@ __datetime_human_machine() {
|
|||||||
__summary_for_commit() {
|
__summary_for_commit() {
|
||||||
awk -v field="SUMMARY" "$AWK_GET" "$1" | tr -c -d "[:alnum:][:blank:]" | head -c 15
|
awk -v field="SUMMARY" "$AWK_GET" "$1" | tr -c -d "[:alnum:][:blank:]" | head -c 15
|
||||||
}
|
}
|
||||||
|
|
||||||
# Re-export dynamical variables to subshells.
|
|
||||||
__export() {
|
|
||||||
DISPLAY_DATE=$(date -R -d "$DISPLAY_DATE")
|
|
||||||
export DISPLAY_DATE
|
|
||||||
if [ -n "${TZ:-}" ]; then
|
|
||||||
export TZ
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
@@ -1,47 +1,8 @@
|
|||||||
# Colors
|
|
||||||
GREEN="\033[1;32m"
|
GREEN="\033[1;32m"
|
||||||
BLACK="\033[1;30m"
|
|
||||||
RED="\033[1;31m"
|
RED="\033[1;31m"
|
||||||
WHITE="\033[1;97m"
|
WHITE="\033[1;97m"
|
||||||
CYAN="\033[1;36m"
|
CYAN="\033[1;36m"
|
||||||
LIGHT_CYAN="\033[1;36m"
|
|
||||||
STRIKE="\033[9m"
|
STRIKE="\033[9m"
|
||||||
ITALIC="\033[3m"
|
ITALIC="\033[3m"
|
||||||
FAINT="\033[2m"
|
FAINT="\033[2m"
|
||||||
BOLD="\033[1m"
|
OFF="\033[m"
|
||||||
BG="\033[41m"
|
|
||||||
|
|
||||||
export OFF="\033[m"
|
|
||||||
|
|
||||||
# Style
|
|
||||||
# Calendar
|
|
||||||
export STYLE_CALENDAR_MONTH="${STYLE_CALENDAR_MONTH:-$GREEN}"
|
|
||||||
export STYLE_CALENDAR_WEEKDAYS="${STYLE_CALENDAR_WEEKDAYS:-$FAINT}"
|
|
||||||
export STYLE_CALENDAR_CURRENT_DAY="${STYLE_CALENDAR_CURRENT_DAY:-$BLACK$BG}"
|
|
||||||
export STYLE_CALENDAR_HL_DAY="${STYLE_CALENDAR_HL_DAY:-$BOLD$RED}"
|
|
||||||
|
|
||||||
# Week view
|
|
||||||
export STYLE_WV_DAY="${STYLE_WV_DAY:-$GREEN}"
|
|
||||||
export STYLE_WV_EVENT_DELIM="${STYLE_WV_EVENT_DELIM:-$RED / $OFF}"
|
|
||||||
export STYLE_WV_SUMMARY="${STYLE_WV_SUMMARY:-$CYAN}"
|
|
||||||
export STYLE_WV_TIME="${STYLE_WV_TIME:-$WHITE}"
|
|
||||||
export STYLE_WV_CONFIRMED="${STYLE_WV_CONFIRMED:-$CYAN}"
|
|
||||||
export STYLE_WV_TENTATIVE="${STYLE_WV_TENTATIVE:-$FAINT$CYAN}"
|
|
||||||
export STYLE_WV_CANCELLED="${STYLE_WV_CANCELLED:-$STRIKE$FAINT$CYAN}"
|
|
||||||
|
|
||||||
# List view
|
|
||||||
export STYLE_LV="${STYLE_LV:-$FAINT}"
|
|
||||||
|
|
||||||
# Day view
|
|
||||||
export STYLE_DV_ALLDAY="${STYLE_DV_ALLDAY:-$LIGHT_CYAN$ITALIC$FAINT (allday) $OFF}"
|
|
||||||
export STYLE_DV_TIME="${STYLE_DV_TIME:-$LIGHT_CYAN}"
|
|
||||||
export STYLE_DV_CONFIRMED="${STYLE_DV_CONFIRMED:-$CYAN}"
|
|
||||||
export STYLE_DV_TENTATIVE="${STYLE_DV_TENTATIVE:-$FAINT$CYAN}"
|
|
||||||
export STYLE_DV_CANCELLED="${STYLE_DV_CANCELLED:-$STRIKE$FAINT$CYAN}"
|
|
||||||
export STYLE_DV_HOUR="${STYLE_DV_HOUR:-$FAINT}"
|
|
||||||
export STYLE_DV_EMPTYHOUR="${STYLE_DV_EMPTYHOUR:-$FAINT----------------------$OFF}"
|
|
||||||
export STYLE_DV_TZ="$WHITE$ITALIC"
|
|
||||||
|
|
||||||
# Event preview
|
|
||||||
export STYLE_EPV_DATETIME="${STYLE_EPV_DATETIME:-$CYAN}"
|
|
||||||
export STYLE_EPV_LOCATION="${STYLE_EPV_LOCATION:-$GREEN}"
|
|
||||||
|
@@ -58,41 +58,29 @@ __view_day() {
|
|||||||
else
|
else
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
printf "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n" "$s" "$e" "$starttime" "$endtime" "$fpath" "$collection" "$description" "$status"
|
printf "%s\t%s\t%s\t%s\t%s\t%s\t%s\%s\n" "$s" "$e" "$starttime" "$endtime" "$fpath" "$collection" "$description" "$status"
|
||||||
done)
|
done)
|
||||||
fi
|
fi
|
||||||
echo "$sef" | sort -n | awk \
|
echo "$sef" | sort -n | awk -v today="$today" -v daystart="$DAY_START" -v dayend="$DAY_END" "$AWK_DAYVIEW"
|
||||||
-v today="$today" \
|
|
||||||
-v daystart="$DAY_START" \
|
|
||||||
-v dayend="$DAY_END" \
|
|
||||||
-v style_allday="$STYLE_DV_ALLDAY" \
|
|
||||||
-v style_timerange="$STYLE_DV_TIME" \
|
|
||||||
-v style_confirmed="$STYLE_DV_CONFIRMED" \
|
|
||||||
-v style_tentative="$STYLE_DV_TENTATIVE" \
|
|
||||||
-v style_cancelled="$STYLE_DV_CANCELLED" \
|
|
||||||
-v style_hour="$STYLE_DV_HOUR" \
|
|
||||||
-v style_emptyhour="$STYLE_DV_EMPTYHOUR" \
|
|
||||||
"$AWK_DAYVIEW"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# 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=$({
|
||||||
printf "%s" "$files" | xargs -d " " -I {} -P0 \
|
set -- $files
|
||||||
|
for file in "$@"; do
|
||||||
|
file="$ROOT/$file"
|
||||||
awk \
|
awk \
|
||||||
-v collection_labels="$COLLECTION_LABELS" \
|
-v collection_labels="$COLLECTION_LABELS" \
|
||||||
"$AWK_PARSE" "$ROOT/{}"
|
"$AWK_PARSE" "$file"
|
||||||
|
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
|
||||||
@@ -107,11 +95,11 @@ __view_week() {
|
|||||||
status="$1"
|
status="$1"
|
||||||
shift
|
shift
|
||||||
if [ "$status" = "TENTATIVE" ]; then
|
if [ "$status" = "TENTATIVE" ]; then
|
||||||
symb="$STYLE_WV_TENTATIVE"
|
symb="$FAINT$CYAN"
|
||||||
elif [ "$status" = "CANCELLED" ]; then
|
elif [ "$status" = "CANCELLED" ]; then
|
||||||
symb="$STYLE_WV_CANCELLED"
|
symb="$STRIKE"
|
||||||
else
|
else
|
||||||
symb="$STYLE_WV_CONFIRMED"
|
symb=""
|
||||||
fi
|
fi
|
||||||
description="${symb:-}$*$OFF"
|
description="${symb:-}$*$OFF"
|
||||||
for i in $(seq 0 7); do
|
for i in $(seq 0 7); do
|
||||||
@@ -135,20 +123,11 @@ __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
|
||||||
} | sort -n)
|
} | sort -n)
|
||||||
echo "$sef" | awk \
|
echo "$sef" | awk -v startofweek="$startofweek" "$AWK_WEEKVIEW"
|
||||||
-v startofweek="$startofweek" \
|
|
||||||
-v style_day="$STYLE_WV_DAY" \
|
|
||||||
-v style_event_delim="$STYLE_WV_EVENT_DELIM" \
|
|
||||||
-v style_summary="$STYLE_WV_SUMMARY" \
|
|
||||||
-v style_time="$STYLE_WV_TIME" \
|
|
||||||
"$AWK_WEEKVIEW"
|
|
||||||
debug "__view_week(): generate week view ended"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function prints all entries.
|
# This function prints all entries.
|
||||||
|
Reference in New Issue
Block a user