Last active
May 18, 2017 22:47
-
-
Save otherwiseguy/fa4605d07176fbf5468338c0cd43520c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import logging | |
import re | |
import subprocess | |
import sys | |
logging.basicConfig() | |
LOG = logging.getLogger() | |
try: | |
r = re.compile(r'(?P<proto>\w+)://\[?(?P<addr>.*?)\]?:?(?P<port>\d+)?/?$') | |
m = r.search(sys.argv[1]).groupdict() | |
proto_map = { | |
'telnet': ('telnet', m['addr'], m['port'] or '23'), | |
'gopher': ('gopher', m['proto'] + '://' + m['addr'], | |
m['port'] or '70'), | |
} | |
subprocess.call(proto_map[m['proto']]) | |
except Exception as e: | |
LOG.exception(e) | |
input("Press Enter to continue...") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Desktop Entry] | |
Version=1.0 | |
Name=Telnet | |
GenericName=Telnet | |
Comment=Telnet Client | |
Exec=/home/terry/bin/runproto.py %U | |
Terminal=true | |
Type=Application | |
Categories=TerminalEmulator;Network;Telnet;Internet;BBS; | |
MimeType=x-scheme/telnet | |
X-KDE-Protocols=telnet | |
Keywords=Terminal;Emulator;Network;Internet;BBS;Telnet;Client; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
telnet.desktop goes in ~/.local/share/applications then run:
$ xdg-mime default telnet.desktop x-scheme-handler/telnet