Skip to content

Commit

Permalink
Merge pull request #50 from adem/clipboard-wayland-support
Browse files Browse the repository at this point in the history
add Wayland support for "copy to clipboard"
  • Loading branch information
tatsumoto-ren authored Sep 8, 2021
2 parents ecee8e5 + e217ed8 commit 2b6150c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions subs2srs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ Requirements:
* mpv >= 0.32.0
* AnkiConnect
* curl
* xclip
* xclip (when running X11)
* wl-copy (when running Wayland)
Usage:
1. Change `config` according to your needs
Expand Down Expand Up @@ -166,6 +167,10 @@ local function is_running_macOS()
return mp.get_property('options/cocoa-force-dedicated-gpu') ~= nil
end

local function is_running_wayland()
return os.getenv('WAYLAND_DISPLAY') ~= nil
end

local function contains_non_latin_letters(str)
return str:match("[^%c%p%s%w]")
end
Expand Down Expand Up @@ -885,7 +890,7 @@ end

local function init_platform_nix()
local self = {}
local clip = is_running_macOS() and 'LANG=en_US.UTF-8 pbcopy' or 'xclip -i -selection clipboard'
local clip = is_running_macOS() and 'LANG=en_US.UTF-8 pbcopy' or is_running_wayland() and 'wl-copy' or 'xclip -i -selection clipboard'

self.tmp_dir = function()
return '/tmp'
Expand Down

0 comments on commit 2b6150c

Please sign in to comment.