summarylogtreecommitdiffstats
path: root/mimeo-detection.patch
blob: 40fbdf3ad6193210da70e732aabfcf5bd9b6841b (plain)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
commit 14a285fc21110e35d55ec96e77562b3a0f5983e3
Author: Narrat <autumn-wind@web.de>
Date:   Sun Apr 19 23:49:50 2020 +0200

    Add support for mimeo

diff --git a/scripts/xdg-email.in b/scripts/xdg-email.in
index 6db58ad..70b539a 100644
--- a/scripts/xdg-email.in
+++ b/scripts/xdg-email.in
@@ -234,6 +234,18 @@ open_flatpak()
     fi
 }
 
+open_mimeo()
+{
+    DEBUG 1 "Running mimeo \"$1\""
+    mimeo "$1"
+
+    if [ $? -eq 0 ]; then
+        exit_success
+    else
+        exit_failure_operation_failed
+    fi
+}
+
 open_generic()
 {
     local client
@@ -484,6 +496,10 @@ case "$DE" in
     open_flatpak "$url"
     ;;
 
+    mimeo)
+    open_mimeo "${mailto}"
+    ;;
+
     generic|lxqt|enlightenment)
     open_generic "${mailto}"
     ;;
diff --git a/scripts/xdg-mime.in b/scripts/xdg-mime.in
index 034d0ef..88c0ae3 100644
--- a/scripts/xdg-mime.in
+++ b/scripts/xdg-mime.in
@@ -95,6 +95,16 @@ info_gnome()
     fi
 }
 
+info_mimeo()
+{
+    mimeo -m "$1" | awk 'FNR == 2 {print}' | cut -d' ' -f3
+    if [ $? -eq 0 ]; then
+        exit_success
+    else
+        exit_failure_operation_failed
+    fi
+}
+
 info_generic()
 {
     if mimetype --version >/dev/null 2>&1; then
@@ -600,6 +610,10 @@ if [ "$action" = "info" ]; then
         info_gnome "$filename"
         ;;
 
+        mimeo)
+        info_mimeo "$filename"
+        ;;
+
         *)
         info_generic "$filename"
         ;;
diff --git a/scripts/xdg-open.in b/scripts/xdg-open.in
index 202f3e3..804d486 100644
--- a/scripts/xdg-open.in
+++ b/scripts/xdg-open.in
@@ -262,6 +262,17 @@ open_flatpak()
     fi
 }
 
+open_mimeo()
+{
+    DEBUG 1 "Running mimeo \"$1\""
+    mimeo "$1"
+    if [ $? -eq 0 ]; then
+        exit_success
+    else
+        exit_failure_operation_failed
+    fi
+}
+
 #-----------------------------------------
 # Recursively search .desktop file
 
@@ -569,6 +580,10 @@ case "$DE" in
     open_flatpak "$url"
     ;;
 
+    mimeo)
+    open_mimeo "$url"
+    ;;
+
     generic)
     open_generic "$url"
     ;;
diff --git a/scripts/xdg-screensaver.in b/scripts/xdg-screensaver.in
index 95f707e..9c2f511 100644
--- a/scripts/xdg-screensaver.in
+++ b/scripts/xdg-screensaver.in
@@ -118,7 +118,7 @@ perform_action()
       [ -n "$DISPLAY" ] && screensaver_xserver "$1"
       ;;
 
-    ''|generic)
+    ''|generic|mimeo)
       [ -n "$DISPLAY" ] && screensaver_xserver "$1"
       ;;
   esac
diff --git a/scripts/xdg-settings.in b/scripts/xdg-settings.in
index 3781de8..39734b1 100644
--- a/scripts/xdg-settings.in
+++ b/scripts/xdg-settings.in
@@ -471,6 +471,44 @@ set_browser_xfce()
 }
 
 # }}} xfce
+# {{{ mimeo
+
+get_browser_mimeo()
+{
+    DEBUG 1 "Running mimeo -d 'http:'"
+    mimeo -d http: | awk 'FNR == 2 {print}' | cut -d' ' -f3
+    if [ $? -eq 0 ]; then
+        exit_success
+    else
+        exit_failure_operation_failed
+    fi
+}
+
+check_browser_mimeo()
+{
+    browser=`get_browser_mimeo $1`
+    if [ x"$browser" != x"$1" ]; then
+        echo no
+        exit_success
+    fi
+    echo yes
+    exit_success
+}
+
+set_browser_mimeo()
+{
+    DEBUG 1 "Running mimeo --prefer x-scheme-handler/http \"$1\""
+    for protocol in http https about unknown; do
+        mimeo --prefer x-scheme-handler/$protocol "$1" || return
+    done
+    if [ $? -eq 0 ]; then
+        exit_success
+    else
+        exit_failure_operation_failed
+    fi
+}
+
+# }}} mimeo
 # {{{ generic
 
 get_browser_generic()
@@ -713,6 +751,24 @@ set_url_scheme_handler_xfce()
 }
 
 # }}} xfce
+# {{{ mimeo
+
+get_url_scheme_handler_mimeo()
+{
+    exit_unimplemented_default_handler "$1"
+}
+
+check_url_scheme_handler_mimeo()
+{
+    exit_unimplemented_default_handler "$1"
+}
+
+set_url_scheme_handler_mimeo()
+{
+    exit_unimplemented_default_handler "$1"
+}
+
+# }}} mimeo
 # {{{ generic
 
 get_url_scheme_handler_generic()
@@ -867,6 +923,10 @@ case "$DE" in
     dispatch_specific xfce "$@"
     ;;
 
+    mimeo)
+    dispatch_specific mimeo "$@"
+    ;;
+
     generic|lxqt|enlightenment)
     dispatch_specific generic "$@"
     ;;
diff --git a/scripts/xdg-utils-common.in b/scripts/xdg-utils-common.in
index b4333e2..10b3ebf 100644
--- a/scripts/xdg-utils-common.in
+++ b/scripts/xdg-utils-common.in
@@ -303,6 +303,9 @@ detectDE()
          XFCE)
            DE=xfce
            ;;
+         MIMEO|mimeo)
+           DE=xfce
+           ;;
          X-Generic)
            DE=generic
            ;;
@@ -319,6 +322,7 @@ detectDE()
       elif xprop -root 2> /dev/null | grep -i '^xfce_desktop_window' >/dev/null 2>&1; then DE=xfce
       elif echo $DESKTOP | grep -q '^Enlightenment'; then DE=enlightenment;
       elif [ x"$LXQT_SESSION_CONFIG" != x"" ]; then DE=lxqt;
+      elif which mimeo > /dev/null; then DE=mimeo;
       fi
     fi