chomp ($subject, $from);
my $note_body = uri_escape(" Subject: $subject\n From: $from");
-exec "emacsclient", "-t", "org-protocol://capture://m/mutt:$mid/mail/$note_body";
+my @EMACS_OPTS;
+if (defined $ENV{DISPLAY} and length($ENV{DISPLAY})) {
+ @EMACS_OPTS = qw(-c)
+} else {
+ @EMACS_OPTS = qw(-t)
+}
+exec "emacsclient", @EMACS_OPTS, "org-protocol://capture://m/mutt:$mid/mail/$note_body";