Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Patch JEB 3.8+ GenRegisterJebUriScheme.py to generate registrator also on Linux
--- GenRegisterJebUriScheme.py.orig 2020-01-08 09:41:43.260903761 +0100
+++ GenRegisterJebUriScheme.py 2020-01-08 14:15:01.278159846 +0100
@@ -1,7 +1,7 @@
'''
Generate a platform-dependant script used to register the custom URI handler 'jeb:',
which can be used to execute JEB from other applications.
-TODO: only Windows is implemented; add Linux and macOS
+TODO: only Windows and Linux is implemented; add macOS
How to use:
- once the 'jeb:' URI handler is registered, other applications can invoke JEB
@@ -40,10 +40,42 @@
text = template % path.replace('\\', '\\\\')
outname = 'RegisterJebUriScheme.reg'
+elif n == 'Linux':
+ template = r'''#!/bin/sh
+set -uex
+
+if which xdg-mime > /dev/null; then
+ DESKTOP_DIR="$HOME/.local/share/applications"
+ DESKTOP_PATH="$DESKTOP_DIR/jeb-opener.desktop"
+
+ cat << EOF > "$DESKTOP_PATH"
+[Desktop Entry]
+Type=Application
+Name=JEB decompiler scheme handler
+Exec="{jeb_bin_path}" %u
+StartupNotify=true
+MimeType=x-scheme-handler/jeb;
+EOF
+
+ xdg-mime default "$DESKTOP_PATH" x-scheme-handler/jeb
+ update-desktop-database "$DESKTOP_DIR"
+fi
+
+if which gconftool-2 > /dev/null; then
+ gconftool-2 -t string -s /desktop/gnome/url-handlers/jeb/command '"{jeb_bin_path}" "%s"'
+ gconftool-2 -s /desktop/gnome/url-handlers/jeb/needs_terminal false -t bool
+ gconftool-2 -s /desktop/gnome/url-handlers/jeb/enabled true -t bool
+fi
+'''
+
+ path = os.path.abspath(os.getcwd() + r'/../../jeb_linux.sh')
+ text = template.format(jeb_bin_path=path)
+ outname = 'RegisterJebUriScheme.sh'
+
else:
print('Not implemented for platform %s!' % n)
sys.exit(-1)
-
+
with open(outname, 'w') as f:
f.write(text)
print('Execute the generated file %s to register the JEB URI scheme.' % outname)
@DrZainAzm
Copy link

DrZainAzm commented Dec 18, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment