/
roundcube.sh
63 lines (47 loc) · 1.33 KB
/
roundcube.sh
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
#!/bin/bash -x
# Ce script permet à Firefox d'utiliser Roundcube pour les URL mailto.
# This script will enable the use of Roundcube for mailto URLs in Firefox.
# Indiquez ici l'adresse de votre serveur Roundcube.
# Replace the following URL by your Roundcube server address.
BROWSER="/usr/bin/firefox"
ROUNDCUBE="https://courrier.example.org/roundcube/"
if [ -n "$1" ] ; then
MAILTO="$( echo "$1" | sed -e "s/^mailto://" )"
URL="$( echo "${MAILTO}" | gawk -v FS="[?=&]" '
BEGIN {
URL = "?_task=mail&_action=compose"
RS="============"
}
{
# Suppression des espaces
gsub( /(\r\n| )/, "" )
# Ajout du destinataire
if ( $1 ) { VALEUR["to"] = $1 }
# Lecture des autres en-têtes
for( I=2 ; I <= NF ; I+= 2 ){
if ( ( tolower($I) == "to" ) && ( "to" in VALEUR ) ){
VALEUR["to] = VALEUR["to] "," $(I+1)
} else {
VALEUR[ tolower($I) ] = $(I+1)
}
}
# Création du lien
if ( "to" in VALEUR ) {
URL = URL "&_to=" VALEUR["to"]
}
if ( "cc" in VALEUR ) {
URL = URL "&_cc=" VALEUR["cc"]
}
if ( "subject" in VALEUR ) {
URL = URL "&_subject=" VALEUR["subject"]
}
if ( "body" in VALEUR ) {
URL = URL "&_body=" VALEUR["body"]
}
print URL
}' )"
"${BROWSER}" "${ROUNDCUBE}${URL}"
else
"${BROWSER}" "${ROUNDCUBE}"
fi
exit 0