improvements: presentation

- collection label before time
- UTF8 arrow insead of `->`
This commit is contained in:
Ämin Baumeler 2025-06-14 23:11:55 +02:00
parent 903c870dba
commit 06020740cc
3 changed files with 29 additions and 20 deletions

View File

@ -1,26 +1,25 @@
# 11:00|13:00|1748422800|1748430000|fpath|desc... # $s|$e|$starttime|$endtime|$fpath|$collection|$description
# 00:00|00:00|1748296800|1748383200|fpath|desc... function allday(collection, desc) {
function allday(desc) { return collection " " ITALIC FAINT " (allday) " OFF desc
return ITALIC FAINT " (allday) " OFF desc
} }
function endstoday(stop, desc) { function endstoday(stop, collection, desc) {
return CYAN " -- " stop OFF ": " desc return collection " " CYAN " -- " stop OFF ": " desc
} }
function slice(start, stop, desc) { function slice(start, stop, collection, desc) {
if (stop == "00:00") if (stop == "00:00")
return CYAN start " -- " OFF ": " desc return collection " " CYAN start " -- " OFF ": " desc
else else
return CYAN start OFF " -- " CYAN stop OFF ": " desc return collection " " CYAN start OFF " -- " CYAN stop OFF ": " desc
} }
function hrline(hour) { function hrline(hour) {
hour = hour < 10 ? "0"hour : hour hour = hour < 10 ? "0"hour : hour
print today, hour, "", "", "", FAINT hour ":00 ----------------------" OFF print today, hour, "", "", "", " " FAINT hour ":00 ----------------------" OFF
} }
function hrlines(start, stop, h, starth, stoph, tmp, i) { function hrlines(start, stop, h, starth, stoph, tmp, i) {
starth = substr(start, 1, 2) starth = substr(start, 1, 2)
stoph = substr(stop, 1, 2) stoph = substr(stop, 1, 2)
tmp = substr(start, 4, 2) == "00" ? 0 : 1 tmp = substr(start, 4, 2) == "00" ? 0 : 1
for (i=h; i < starth + tmp; i++) for (i=h; i < starth + tmp && i < dayend; i++)
hrline(i) hrline(i)
tmp = substr(stop, 4, 2) == "00" ? 0 : 1 tmp = substr(stop, 4, 2) == "00" ? 0 : 1
if (stoph + tmp < daystart) if (stoph + tmp < daystart)
@ -39,11 +38,11 @@ BEGIN {
OFF = "\033[m" OFF = "\033[m"
OFS = "|" OFS = "|"
} }
$1 == "00:00" && $2 == "00:00" { print today, $1, $3, $4, $5, allday($6); next } $1 == "00:00" && $2 == "00:00" { print today, $1, $3, $4, $5, allday($6, $7); next }
$1 == "00:00" { print today, $1, $3, $4, $5, endstoday($2, $6); next } $1 == "00:00" { print today, $1, $3, $4, $5, endstoday($2, $6, $7); next }
$1 ~ /^[0-9]{2}:[0-9]{2}$/ { $1 ~ /^[0-9]{2}:[0-9]{2}$/ {
daystart = hrlines($1, $2, daystart, starth, stoph, tmp, i) daystart = hrlines($1, $2, daystart, starth, stoph, tmp, i)
print today, $1, $3, $4, $5, slice($1, $2, $6) print today, $1, $3, $4, $5, slice($1, $2, $6, $7)
} }
END { END {
hrlines(dayend":00", 0, daystart, starth, stoph, tmp, i) hrlines(dayend":00", 0, daystart, starth, stoph, tmp, i)

View File

@ -12,7 +12,7 @@ BEGIN {
} }
/^[0-7] 00:00 -- 00:00/ { dayline = dayline " " c(); next } /^[0-7] 00:00 -- 00:00/ { dayline = dayline " " c(); next }
/^[0-7] 00:00 -- / { dayline = dayline " <--" $4 " " c(); next } /^[0-7] 00:00 -- / { dayline = dayline " <--" $4 " " c(); next }
/^[0-7] [0-9]{2}:[0-9]{2} -- 00:00/ { dayline = dayline " " $2 "--> " c(); next } /^[0-7] [0-9]{2}:[0-9]{2} -- 00:00/ { dayline = dayline " " $2 "" c(); next }
/^[0-7] [0-9]{2}:[0-9]{2} -- [0-9]{2}:[0-9]{2}/ { dayline = dayline " " $2 " - " $4 " " c(); next } /^[0-7] [0-9]{2}:[0-9]{2} -- [0-9]{2}:[0-9]{2}/ { dayline = dayline " " $2 " - " $4 " " c(); next }
/^[0-7]$/ && dayline { print "+", startofweek " +" $0-1 " days", "", dayline; } /^[0-7]$/ && dayline { print "+", startofweek " +" $0-1 " days", "", dayline; }
/^[0-7]$/ { /^[0-7]$/ {

View File

@ -123,7 +123,7 @@ if [ "${1:-}" = "--preview-event" ]; then
start=$(datetime_str "$start" "%a ") start=$(datetime_str "$start" "%a ")
end=$(datetime_str "$end" "%a ") end=$(datetime_str "$end" "%a ")
location=$(awk -v field="LOCATION" "$AWK_GET" "$fpath") location=$(awk -v field="LOCATION" "$AWK_GET" "$fpath")
echo "📅 ${CYAN}$start${OFF} -> ${CYAN}$end${OFF}" echo "📅 ${CYAN}$start${OFF} ${CYAN}$end${OFF}"
if [ -n "${location:-}" ]; then if [ -n "${location:-}" ]; then
echo "📍 ${CYAN}$location${OFF}" echo "📍 ${CYAN}$location${OFF}"
fi fi
@ -240,6 +240,8 @@ __view_day() {
shift shift
fpath="$(echo "$1" | sed 's/|/ /g')" # we will use | as delimiter (need to convert back!) fpath="$(echo "$1" | sed 's/|/ /g')" # we will use | as delimiter (need to convert back!)
shift shift
collection="$1"
shift
description="$(echo "$*" | sed 's/|/:/g')" # we will use | as delimiter description="$(echo "$*" | sed 's/|/:/g')" # we will use | as delimiter
# #
daystart=$(date -d "$today 00:00:00" +"%s") daystart=$(date -d "$today 00:00:00" +"%s")
@ -259,7 +261,7 @@ __view_day() {
else else
continue continue
fi fi
echo "$s|$e|$starttime|$endtime|$fpath|$description" echo "$s|$e|$starttime|$endtime|$fpath|$collection|$description"
done) done)
fi fi
echo "$sef" | sort -n | awk -v today="$today" -v daystart="$DAY_START" -v dayend="$DAY_END" "$AWK_DAYVIEW" echo "$sef" | sort -n | awk -v today="$today" -v daystart="$DAY_START" -v dayend="$DAY_END" "$AWK_DAYVIEW"
@ -995,13 +997,19 @@ while true; do
)+transform( )+transform(
[ -n \"\${TZ:-}\" ] && echo \"change-list-label:\$WHITE\$ITALIC(\$TZ)\$OFF\" [ -n \"\${TZ:-}\" ] && echo \"change-list-label:\$WHITE\$ITALIC(\$TZ)\$OFF\"
)+transform( )+transform(
echo {} | grep \|\| || echo show-preview [ -n \"\$(echo {} | cut -d '|' -f 5)\" ] && echo show-preview
)" \ )" \
--bind="start:hide-preview" \ --bind="start:hide-preview" \
--bind="j:down+hide-preview+transform:echo {} | grep \|\| || echo show-preview" \ --bind="j:down+hide-preview+transform([ -n \"\$(echo {} | cut -d '|' -f 5)\" ] && echo show-preview)" \
--bind="k:up+hide-preview+transform:echo {} | grep \|\| || echo show-preview" \ --bind="k:up+hide-preview+transform([ -n \"\$(echo {} | cut -d '|' -f 5)\" ] && echo show-preview)" \
--bind="ctrl-j:down+hide-preview+transform([ -n \"\$(echo {} | cut -d '|' -f 5)\" ] && echo show-preview)" \
--bind="ctrl-k:up+hide-preview+transform([ -n \"\$(echo {} | cut -d '|' -f 5)\" ] && echo show-preview)" \
--bind="down:down+hide-preview+transform([ -n \"\$(echo {} | cut -d '|' -f 5)\" ] && echo show-preview)" \
--bind="up:up+hide-preview+transform([ -n \"\$(echo {} | cut -d '|' -f 5)\" ] && echo show-preview)" \
--bind="l:hide-preview+reload:$0 --reload-day {1} '+1 day'" \ --bind="l:hide-preview+reload:$0 --reload-day {1} '+1 day'" \
--bind="h:hide-preview+reload:$0 --reload-day {1} '-1 day'" \ --bind="h:hide-preview+reload:$0 --reload-day {1} '-1 day'" \
--bind="right:hide-preview+reload:$0 --reload-day {1} '+1 day'" \
--bind="left:hide-preview+reload:$0 --reload-day {1} '-1 day'" \
--bind="ctrl-l:hide-preview+reload:$0 --reload-day {1} '+1 week'" \ --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="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-l:hide-preview+reload:$0 --reload-day {1} '+1 month'" \
@ -1074,6 +1082,8 @@ while true; do
--bind="k:up" \ --bind="k:up" \
--bind="l:unbind(load)+reload:$0 --reload-week {2} '+1 week'" \ --bind="l:unbind(load)+reload:$0 --reload-week {2} '+1 week'" \
--bind="h:unbind(load)+reload:$0 --reload-week {2} '-1 week'" \ --bind="h:unbind(load)+reload:$0 --reload-week {2} '-1 week'" \
--bind="right:unbind(load)+reload:$0 --reload-week {2} '+1 week'" \
--bind="left:unbind(load)+reload:$0 --reload-week {2} '-1 week'" \
--bind="ctrl-l:unbind(load)+reload:$0 --reload-week {2} '+1 month'" \ --bind="ctrl-l:unbind(load)+reload:$0 --reload-week {2} '+1 month'" \
--bind="ctrl-h:unbind(load)+reload:$0 --reload-week {2} '-1 month'" \ --bind="ctrl-h:unbind(load)+reload:$0 --reload-week {2} '-1 month'" \
--bind="alt-l:unbind(load)+reload:$0 --reload-week {2} '+1 year'" \ --bind="alt-l:unbind(load)+reload:$0 --reload-week {2} '+1 year'" \