all repos — taro @ main

mblaze frontend in uxn + crystal

taro-reader (raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/sh

mhandle() {
  case $2 in
    text/html)
      cp $1 ${1}.html
      netsurf ${1}.html
      rm ${1}.html;;
    image/*)
      qiv $1;;
    audio/*|video/*)
      mpv $1;;
    pgp/encrypted)
      gpg --decrypt $1;;
    application/vnd*)
      libreoffice $1;;
    application/pdf)
      zathura $1;;
  esac
}

save_attachments() {
  while true; do
    printf "\n"
    mshow -t
    printf "\n"

    printf "select an attachment to save: "
    read n
    case ${n} in 
      ''|*[!0-9]*) return ;;
      *) file=$(mshow -x . ${n}); mv "${file}" ${TARO_DOWNLOADS} ;;
    esac
  done
}

open_attachments() {
  while true; do
    printf "\n"
    mshow -t
    printf "\n"

    printf "select an attachment to open: "
    read n
    case $n in
      ''|*[!0-9]*) return ;;
      *)  attachment=$(mktemp)
          mshow -O . ${n} > ${attachment}
          mimetype=$(mshow -t | grep ${n}: | awk '{print $2}')
          mhandle ${attachment} ${mimetype}
          rm ${attachment};;
    esac
  done     
}

keep_track_of_mailfile() {
  orig=$1
  stamp=${orig%,}
  new=$(\ls -1 ${stamp}*)
  printf "${new}"
}

mread() {
  local this=$(mseq $@)
  mflag -S ${this}
  while true; do
    this=$(keep_track_of_mailfile ${this}) 
    if [ ! -e ${this} ]; then
      printf "Looks like this email was refiled... Press Enter to close this window. "
      read
      break
    fi
  
    (mshow ${this} ; printf "\n"; mshow -t ${this})| less --mouse -Ps"[o]pen or [s]ave attachments, [r]reply, [f]orward, [q]uit"$

    case $? in
      113) #q
        break;;
      102) #f
        mfwd ${this};;
      114) #r
        mrep ${this};;
      115) #s
        save_attachments;;
      111) #o
        open_attachments;;
    esac

  done
}

mread $@