Skip to content

Commit f21df7d

Browse files
committed
Allow overriding screenshot tool with environment variable
1 parent e30a5e0 commit f21df7d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ There are three ways to get a prediction from an image.
2424

2525
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.
2626

27-
Under linux, it is possible to use the GUI with `gnome-screenshot` which comes with multiple monitor support if `gnome-screenshot` was installed beforehand.
27+
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`).
2828

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

pix2tex/gui.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,13 @@ def toggleProcessing(self, value=None):
111111
@pyqtSlot()
112112
def onClick(self):
113113
self.close()
114-
if which('gnome-screenshot'):
114+
if os.environ.get('SCREENSHOT_TOOL') == "gnome-screenshot":
115+
self.snip_using_gnome_screenshot()
116+
elif os.environ.get('SCREENSHOT_TOOL') == "grim":
117+
self.snip_using_grim()
118+
elif os.environ.get('SCREENSHOT_TOOL') == "pil":
119+
self.snipWidget.snip()
120+
elif which('gnome-screenshot'):
115121
self.snip_using_gnome_screenshot()
116122
elif which('grim') and which('slurp'):
117123
self.snip_using_grim()

0 commit comments

Comments
 (0)