Page MenuHomeDevCentral
Paste P384

Terminator plugin
ActivePublic

Authored by Duranzed on Mon, Feb 23, 16:11.
Tags
None
Referenced Files
F24497302: Terminator plugin
Mon, Feb 23, 16:11
from terminatorlib.plugin import URLHandler
import subprocess
import os
AVAILABLE = ['ResolveHashURLHandler']
class ResolveHashURLHandler(URLHandler):
capabilities = ['url_handler']
handler_name = 'resolve_hash'
name = 'Nasqueron Resolve Hash'
# REGEX to detect hashes
match = r'\b[0-9a-f]{7,40}\b'
def callback(self, url):
hash_value = url.strip()
try:
#We define the path to resolve-hash module
script_path = os.path.expanduser ("~/bin/resolve-hash")
result = subprocess.check_output(
[script_path, hash_value],
stderr=subprocess.STDOUT,
text=True
)
#We clean the result
final_url = result.strip()
# Terminator only opens a navigator is the URL is correct
if final_url.startswith('http'):
return final_url
except Exception as e:
#if error we return none for terminator to ignore the clic
return None
return None