Compare commits

...

2 Commits

Author SHA1 Message Date
a9e6bbd878 feat: improved image quality 2025-07-15 16:39:45 +02:00
adaff4e285 feat: basic image viewer 2025-07-15 15:54:13 +02:00
4 changed files with 39 additions and 6 deletions

View File

@@ -1,8 +1,11 @@
# Retrieve content from iCalendar files # Retrieve content from vCard files
# #
# Mandatory variable: `field`. # Mandatory variable: `field`.
# Name of field to retrieve. # Name of field to retrieve.
# #
# Optional variable: `prop`.
# If `prop` is set, then the property `prop` of `field` is printed.
#
# Optional variable: `format`. # Optional variable: `format`.
# If `format` is set to "csv", then the content is interpreted as # If `format` is set to "csv", then the content is interpreted as
# comma-separated values, and empty values are dropped. # comma-separated values, and empty values are dropped.
@@ -15,16 +18,19 @@
# print content of field `field` # print content of field `field`
BEGIN { FS = ":"; regex = "^" field; } BEGIN { FS = ":"; regex = "^" field; }
BEGINFILE { type = ""; line = ""; } BEGINFILE { line = ""; }
/^BEGIN:(VJOURNAL|VTODO)/ { type = $2 } /^BEGIN:VCARD/ { next }
/^END:/ && $2 == type { nextfile } /^END:VCARD/ { nextfile }
$0 ~ regex { line = $0; next; } $0 ~ regex { line = $0; next; }
/^ / && line { line = line substr($0, 2); next; } /^ / && line { line = line substr($0, 2); next; }
/^[^ ]/ && line { nextfile } /^[^ ]/ && line { nextfile }
ENDFILE { ENDFILE {
if (type) { if (line) {
# Process line # Process line
content = getcontent(line) if (prop)
content = getparam(line, prop)
else
content = getcontent(line)
if (oneline) if (oneline)
content = singleline(content) content = singleline(content)
switch (format) { switch (format) {

View File

@@ -142,6 +142,7 @@ while true; do
--bind="alt-o:change-query($FLAG_ORGANIZATION )" \ --bind="alt-o:change-query($FLAG_ORGANIZATION )" \
--bind="alt-l:change-query($FLAG_LOCATION )" \ --bind="alt-l:change-query($FLAG_LOCATION )" \
--bind="alt-w:toggle-preview-wrap" \ --bind="alt-w:toggle-preview-wrap" \
--bind="/:toggle-preview" \
--bind="ctrl-d:preview-half-page-down" \ --bind="ctrl-d:preview-half-page-down" \
--bind="ctrl-u:preview-half-page-up" \ --bind="ctrl-u:preview-half-page-up" \
--bind="ctrl-s:execute($SYNC_CMD; [ -n \"${GIT:-}\" ] && ${GIT:-echo} add -A && ${GIT:-echo} commit -am 'Synchronized'; printf 'Press <enter> to continue.'; read -r tmp)" || #--color='preview-bg:#ecc297,preview-fg:black' \ --bind="ctrl-s:execute($SYNC_CMD; [ -n \"${GIT:-}\" ] && ${GIT:-echo} add -A && ${GIT:-echo} commit -am 'Synchronized'; printf 'Press <enter> to continue.'; read -r tmp)" || #--color='preview-bg:#ecc297,preview-fg:black' \

View File

@@ -6,6 +6,7 @@ if [ "${1:-}" = "--preview" ]; then
name="$1" name="$1"
shift shift
file="$ROOT/$name" file="$ROOT/$name"
# Get info
awk \ awk \
-v label_tel_text="$LABEL_TEL_TEXT" \ -v label_tel_text="$LABEL_TEL_TEXT" \
-v label_tel_fax="$LABEL_TEL_FAX" \ -v label_tel_fax="$LABEL_TEL_FAX" \
@@ -18,6 +19,26 @@ if [ "${1:-}" = "--preview" ]; then
-v label_home="$LABEL_HOME" \ -v label_home="$LABEL_HOME" \
"$AWK_PREVIEW" "$file" | "$AWK_PREVIEW" "$file" |
$CAT $CAT
# Get photo, if supported and if it exists
if [ "${KITTY:-}" ]; then
photo=$(mktemp)
awk -v field="PHOTO" "$AWK_GET" "$file" | base64 -d -i >"$photo"
type=$(file --mime-type -b "$photo" | cut -d '/' -f 1)
if [ "$type" != "image" ]; then
cat <<EOF >"$photo"
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="1pt" height="1pt" viewBox="0.00 0.00 1.00 1.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"></svg>
EOF
fi
WIDTH=30
if [ "$FZF_PREVIEW_COLUMNS" -lt "$WIDTH" ]; then
WIDTH="$FZF_PREVIEW_COLUMNS"
fi
$KITTY icat --clear --transfer-mode=memory --stdin=no --place="$WIDTH"x"$FZF_PREVIEW_LINES"@0x0 "$photo"
# $CHAFA -f symbols -s "$WIDTH" "$photo"
fi
rm "$photo"
exit exit
fi fi

View File

@@ -65,4 +65,9 @@ if command -v "git" >/dev/null && [ -d "$ROOT/.git" ]; then
export GIT export GIT
fi fi
if command -v "kitty" >/dev/null; then
KITTY="kitty"
export KITTY
fi
export OPEN=${OPEN:-open} export OPEN=${OPEN:-open}