firecat53 / urlscan

Mutt and terminal url selector (similar to urlview)
GNU General Public License v2.0
213 stars 37 forks source link

mailto links should be opened in mutt #83

Closed AKXX closed 5 years ago

AKXX commented 5 years ago

I can't see an option to set mailto links opened in mutt or some other mail agents.

firecat53 commented 5 years ago

Hmm. I was hoping xdg-open would handle this automatically, but on my machine using i3...it doesn't. I'll keep looking at it.

firecat53 commented 5 years ago

Ok, I figured out my problem so now I can click mailto: links on a webpage and have it open in mutt. For reference:

~/.local/share/applications/mutt.desktop

[Desktop Entry]
Type=Application 
Name=mutt 
Comment=Simple text based Mail User Agent 
Exec=i3-sensible-terminal -e mutt %f
Icon=utilities-terminal 
Terminal=false 
MimeType=x-scheme-handler/mailto; 
Categories=Email;Office;Network;

~/.local/share/applications/mimeapps.list

[Default Applications]
x-scheme-handler/mailto=mutt.desktop;

Once that's working, now you can set urlscan to use xdg-open to open all links instead of the python webbrowser module (which is the default). Change muttrc line to:

macro index,pager b "<pipe-message> urlscan -d -r 'xdg-open \"{}\"'<Enter>" 'call urlscan to extract URLs out of a message'

Notice the escaped quotes on {}...those are important!! And took a long time to figure out...

I'll consider adding xdg-open as a built-in alternative to the webbrowser module. For now, hopefully this setup will work for you.

AKXX commented 5 years ago

I was busy in compiling new distro, just came to write a port for urlscan so checked issues, I hope it will work now, I'll update soon.

AKXX commented 5 years ago

it still opening browser from mutt mailto links.

firecat53 commented 5 years ago

I didn't change anything with urlscan. You have to setup your mutt.desktop and muttrc as I described above.

Edit: you may also have to edit the mutt.desktop Exec line if you aren't using i3.

AKXX commented 5 years ago

yeah I did that. maybe I don't have xdg-open ;-)

AKXX commented 5 years ago

yeah I did that too.

AKXX commented 5 years ago

tried this way too, macro index,pager U "set pipe_decode =yesurlscanset pipe_decode = no""view URLs" lemme try after compiling xdg-utils.

firecat53 commented 5 years ago

If you can get xdg-open 'mailto:joe@joe.com' in a terminal to open mutt then you are on the right track. Otherwise you have to get that working before it will work from urlscan.

AKXX commented 5 years ago

xdg-open 'mailto:joe@joe.com' it also opened a browser window

AKXX commented 5 years ago

before urlscan, any mailto link in browsers weren't working, now if I click on them, they are opened in new browser instances. which means the urlscan is opening them ;-)

firecat53 commented 5 years ago

Then you have to figure out how to get that working first. Took me awhile too. There's a few Stack Overflow questions, but I'm pretty sure I covered everything they mentioned in my answer above.

AKXX commented 5 years ago

Yeah I appreciate your work. Its far better than urlview

firecat53 commented 5 years ago

What's the output of XDG_UTILS_DEBUG_LEVEL=2 xdg-mime query default x-scheme-handler/mailto ?

AKXX commented 5 years ago

Checking /home/ak/.local/share//applications/defaults.list Checking /usr/local/share//applications/defaults.list Checking /usr/share//applications/defaults.list

output of default query

AKXX commented 5 years ago

let me set it this way

firecat53 commented 5 years ago

Looks like it's checking defaults.list instead of mimeapps.list like on my system.

firecat53 commented 5 years ago

This is what you should see (or something similar):

Checking /home/firecat53/.config/mimeapps.list
Checking /home/firecat53/.local/share/applications/mimeapps.list
mutt.desktop
AKXX commented 5 years ago

I have set it, now it shows mutt.desktop , yeah same as yours output

firecat53 commented 5 years ago

Now it should hopefully open a terminal window with mutt when you click a mailto link in your browser

AKXX commented 5 years ago

lemme put it in .config too

firecat53 commented 5 years ago

http://mc-computing.com/HTML_Examples/MailTo.htm

AKXX commented 5 years ago

opened in a new instance of chrome ;-) both from browser and mutt

AKXX commented 5 years ago

lemme reboot maybe there is some issue

AKXX commented 5 years ago

not working even after a reboot. I think I have to modify xdg-open script as once I was able to achieve it with urlview

firecat53 commented 5 years ago

I'm working on the xdg branch right now so you'll be able to cycle through using xdg-open, python webbrowser or a custom --run or --pipe command without having to exit urlscan.

You'll still have to figure out getting xdg-open to work in your own environment though! Any luck with that?

firecat53 commented 5 years ago

Latest commit 728569adb allows cycling through webbrowser, xdg-open, or a --run command. This should allow you to open mailto links using one of those options that works for you. Let me know if you get it working!

firecat53 commented 5 years ago

Haven't heard anything from you for awhile. I'll close this for now. Feel free to re-open if you still assistance.

Awan commented 5 years ago

https://abdullah.today/blog/how-to-use-mailto-links-in-DWM.html is the solution you want.