From 83ac34736df760e81760d20b039e8063936648e1 Mon Sep 17 00:00:00 2001 From: rpop0 <38384209+rpop0@users.noreply.github.com> Date: Sun, 25 Aug 2024 22:43:16 +0300 Subject: [PATCH] Added full path for clip.exe for WSL (#125) (#126) * Added full path for clip.exe for WSL (#125) * Made the WSL clip path a fallback Getting the clipboard for WSL will check if clip.exe exists before just using the full path as a fallback. --- extrakto_plugin.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/extrakto_plugin.py b/extrakto_plugin.py index 9217c3a..2495eda 100755 --- a/extrakto_plugin.py +++ b/extrakto_plugin.py @@ -4,6 +4,7 @@ import platform import re import subprocess +import shutil import sys import traceback @@ -137,7 +138,7 @@ def __init__(self, trigger_pane, launch_mode): if re.search( r"Microsoft|microsoft", open("/proc/sys/kernel/osrelease").read() ): - self.clip_tool = "clip.exe" + self.clip_tool = ExtraktoPlugin._get_wsl_clip_executable() elif os.environ.get("XDG_SESSION_TYPE", None) == "wayland": self.clip_tool = "wl-copy" else: @@ -413,6 +414,12 @@ def capture(self): self.copy(PRJ_URL) else: return 0 + @staticmethod + def _get_wsl_clip_executable(): + if shutil.which('clip.exe') is None: + return '/mnt/c/Windows/System32/clip.exe' + return 'clip.exe' + if __name__ == "__main__":