From f212711df305fc4bbd421fbc625d8408845a7ee1 Mon Sep 17 00:00:00 2001 From: Mitchell Riedstra Date: Tue, 23 Jan 2024 23:13:58 -0500 Subject: Add Wayland support --- pm | 22 +++++++++++++++++++--- readme.md | 6 +++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/pm b/pm index ddaa88d..1073edd 100755 --- a/pm +++ b/pm @@ -20,6 +20,10 @@ PASTE_MANAGER_X_SELECTION="${PASTE_MANAGER_X_SELECTION:-clipboard}" # Pretty much anything that implements a demu like interface should work here, # the only option called elsewhere is `-p` _menu="dmenu -l $PASTE_MANAGER_LINES -i" +if [ "$XDG_SESSION_TYPE" = "wayland" ] ; then + _menu="bemenu -l $PASTE_MANAGER_LINES -i" +fi + case $(uname) in Darwin) _menu="choose -m -s 16 -f Monaco -n $PASTE_MANAGER_LINES -w 85" ;; @@ -41,7 +45,12 @@ Darwin) pbcopy ;; *) - xclip -selection "$PASTE_MANAGER_X_SELECTION" + case $XDG_SESSION_TYPE in + wayland) + wl-copy ;; + *) + xclip -selection "$PASTE_MANAGER_X_SELECTION" ;; + esac :; esac } @@ -101,14 +110,21 @@ copyName() { selectName "$(sel "Will copy entry name")" | _clip } +__type() { +case $XDG_SESSION_TYPE in +wayland) wtype -s 2 - ;; +*) xdotool type --delay 2ms --clearmodifiers --file - ;; +esac +} + _type() { selectContent "$(sel "Will type content")" \ - | xdotool type --delay 1ms --clearmodifiers --file - + | __type } typeName() { selectName "$(sel "Will type entry name")" \ - | xdotool type --delay 1ms --clearmodifiers --file - + | __type } rename() { diff --git a/readme.md b/readme.md index 3733fcc..bcc4d45 100644 --- a/readme.md +++ b/readme.md @@ -46,10 +46,14 @@ You'll need `dmenu` installed. You may also wish to bind a hotkey to run the new Environment variables: +`XDG_SESSION_TYPE` if set to `wayland` will utilize `wl-copy` from the +`wl-clipboard` package and `wtype` instead of `xclipboard` and `xdotool` +respectively. `bemenu` is used in place of `dmenu` on Wayland as well. + `PASTE_MANAGER_FILE` can override the file location `PASTE_MANAGER_LINES` overrides the number of lines displayed by `dmenu` `PASTE_MANAGER_X_SELECTION` sets the clipboard selection, you probably want to -leave it set to clipboard, the default. +leave it set to clipboard, the default. ( xorg only ) Edit the source code for further tweaks. The one people may have the most -- cgit v1.2.3