Arieleg / mpv-copyTime

Copy the current time of the video to clipboard.
GNU General Public License v3.0
73 stars 23 forks source link

Copying to clipboard fails under Sway if both xclip and wl-copy are installed #15

Open maxigaz opened 1 year ago

maxigaz commented 1 year ago

I use wl-copy with Sway and xclip with i3 under Arch Linux. I generally prefer using Sway, but I can't use it all the time because certain applications only work properly on i3.

Under Sway, when mpv is run as a native Wayland application, pressing the key combination defined in mp.add_key_binding at the end of the script doesn't actually copy the current time to the clipboard; it only shows the OSD message, 'Copied to Clipboard: [timecode]'

My knowledge in Lua is rather limited, but by looking at the script, I've been able to find that it only checks whether each supported clipboard manager exists in an if-else statement. In my case, xclip is available (the first part of the if statement) and so xclip -silent -in -selection clipboard is run, but it doesn't work under Wayland.

I wonder how to solve this. One idea is to check the current value of the environment variable $XDG_SESSION_TYPE. If it is wayland, use wl-copy, and if it is x11, use xclip.

maxigaz commented 1 year ago

I've just noticed that there's already a pull request fixing this issue: https://github.com/Arieleg/mpv-copyTime/pull/13