From acd3bb284ab9a72e6faf4067448e53372392fb62 Mon Sep 17 00:00:00 2001 From: pegasko Date: Thu, 20 Jun 2024 22:47:16 +0300 Subject: [PATCH] Partial support for wayland --- README.md | 16 ++++++++++++++++ fleepit.py | 6 +++--- setup.py | 2 +- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6707051..5855905 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,22 @@ Text seleciton keyboard layout switcher based on xclip / etc for X11 & wayland 2. install module: `pip install fleepit` +# Limitations + +## X11 + +Operation is performed in 3 steps: +* copy - copy selection buffer (primary clipboard) +* paste - write converted selection buffer into secondary (regular) clipboard +* send CTRL+C event + +## Wayland + +Operation is performed in 3 steps with limitations +* copy - reads contents of primary buffer +* paste - write converted selection into secondary (regular) clipboard +* user has to manually press CTRL+C - for the security reasons and/or in order to prevent depending on external daemon services that may expose potential keystroke injection vulnerabilities + # Usage Sample usage for KDE: diff --git a/fleepit.py b/fleepit.py index 8d8caa2..292df10 100644 --- a/fleepit.py +++ b/fleepit.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Requirements: xclip, xdotool +# Requirements: xclip, xdotool (X11); wl-clipboard (Wayland) import subprocess import argparse @@ -89,7 +89,7 @@ def do_x11(args: argparse.Namespace): def do_wayland(args: argparse.Namespace): # Extract selection - result = subprocess.run([ 'wl-paste', '-primary' ], capture_output=True, text=True) + result = subprocess.run([ 'wl-paste', '--primary', '--no-newline' ], capture_output=True, text=True) result.check_returncode() clip = result.stdout if clip.strip() == '': @@ -112,7 +112,7 @@ def do_wayland(args: argparse.Namespace): print(f'converted: "{ converted }"') # Write selection - result = subprocess.run([ 'wl-paste', '-primary' ], text=True, input=converted) + result = subprocess.run([ 'wl-copy' ], text=True, input=converted) result.check_returncode() diff --git a/setup.py b/setup.py index ffd3c0a..56cd304 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ except: setup( name='fleepit', - version='6', + version='7', py_modules=['fleepit'], description='Text seleciton keyboard layout switcher based on xclip / etc for X11 & wayland', url='https://git.pegasko.art/bitrate16/fleepit',