Skip to content

Commit

Permalink
Merge pull request #307 from frankier/override-screenshot-tool
Browse files Browse the repository at this point in the history
Allow overriding screenshot tool with environment variable
  • Loading branch information
lukas-blecher committed Aug 23, 2023
2 parents e30a5e0 + f21df7d commit a1c92a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -24,7 +24,7 @@ There are three ways to get a prediction from an image.

2. Thanks to [@katie-lim](https://github.com/katie-lim), you can use a nice user interface as a quick way to get the model prediction. Just call the GUI with `latexocr`. From here you can take a screenshot and the predicted latex code is rendered using [MathJax](https://www.mathjax.org/) and copied to your clipboard.

Under linux, it is possible to use the GUI with `gnome-screenshot` which comes with multiple monitor support if `gnome-screenshot` was installed beforehand.
Under linux, it is possible to use the GUI with `gnome-screenshot` (which comes with multiple monitor support) if `gnome-screenshot` was installed beforehand. For Wayland, `grim` and `slurp` will be used when they are both available. Note that `gnome-screenshot` is not compatible with wlroots-based Wayland compositors. Since `gnome-screenshot` will be preferred when available, you may have to set the environment variable `SCREENSHOT_TOOL` to `grim` in this case (other available values are `gnome-screenshot` and `pil`).

![demo](https://user-images.githubusercontent.com/55287601/117812740-77b7b780-b262-11eb-81f6-fc19766ae2ae.gif)

Expand Down
8 changes: 7 additions & 1 deletion pix2tex/gui.py
Expand Up @@ -111,7 +111,13 @@ def toggleProcessing(self, value=None):
@pyqtSlot()
def onClick(self):
self.close()
if which('gnome-screenshot'):
if os.environ.get('SCREENSHOT_TOOL') == "gnome-screenshot":
self.snip_using_gnome_screenshot()
elif os.environ.get('SCREENSHOT_TOOL') == "grim":
self.snip_using_grim()
elif os.environ.get('SCREENSHOT_TOOL') == "pil":
self.snipWidget.snip()
elif which('gnome-screenshot'):
self.snip_using_gnome_screenshot()
elif which('grim') and which('slurp'):
self.snip_using_grim()
Expand Down

0 comments on commit a1c92a9

Please sign in to comment.