koreader: implement copy-to-clipboard
This commit is contained in:
parent
7ba39ea831
commit
c256d7ded5
|
@ -0,0 +1,40 @@
|
||||||
|
local logger = require("logger")
|
||||||
|
logger.info("applying colin patch colin-impl-clipboard")
|
||||||
|
|
||||||
|
-- source: <https://github.com/ncopa/lua-shell/blob/master/shell.lua>
|
||||||
|
local function shescape(arg)
|
||||||
|
if arg:match("[^A-Za-z0-9_/:=-]") then
|
||||||
|
arg = "'"..arg:gsub("'", "'\\''").."'"
|
||||||
|
end
|
||||||
|
return arg
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 2023/12/15: the default setClipboardText doesn't do anything
|
||||||
|
-- frontend/device/sdl/device.lua calls frontend/device/input.lua is noop
|
||||||
|
local input = require("ffi/input")
|
||||||
|
input.setClipboardText = function(text)
|
||||||
|
logger.info("input.setClipboardText")
|
||||||
|
local cmd = "wl-copy " .. shescape(text)
|
||||||
|
logger.info("invoke: " .. cmd)
|
||||||
|
os.execute(cmd)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 2023/12/15: the default ReaderLink "Copy" option (when clicking a URL) doesn't do anything
|
||||||
|
-- patch so it calls `setClipboardText`
|
||||||
|
local ReaderLink = require("apps/reader/modules/readerlink")
|
||||||
|
local UIManager = require("ui/uimanager")
|
||||||
|
local _ = require("gettext")
|
||||||
|
local orig_ReaderLink_init = ReaderLink.init;
|
||||||
|
ReaderLink.init = function(self)
|
||||||
|
orig_ReaderLink_init(self)
|
||||||
|
self._external_link_buttons["10_copy"] = function(this, link_url)
|
||||||
|
return {
|
||||||
|
text = _("Copy"),
|
||||||
|
callback = function()
|
||||||
|
UIManager:close(this.external_link_dialog)
|
||||||
|
input.setClipboardText(link_url)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -38,9 +38,13 @@ in {
|
||||||
package = pkgs.koreader-from-src;
|
package = pkgs.koreader-from-src;
|
||||||
# koreader applies these lua "patches" at boot:
|
# koreader applies these lua "patches" at boot:
|
||||||
# - <https://github.com/koreader/koreader/wiki/User-patches>
|
# - <https://github.com/koreader/koreader/wiki/User-patches>
|
||||||
# - 2023/10/29: koreader code hasn't changed, but somehow FTP browser seems usable even without the isConnected patch now.
|
# the naming is IMPORTANT. these must start with a `2-` in order to be invoked during the right initialization phase
|
||||||
|
#
|
||||||
|
# 2023/10/29: koreader code hasn't changed, but somehow FTP browser seems usable even without the isConnected patch now.
|
||||||
# fs.".config/koreader/patches/2-colin-NetworkManager-isConnected.lua".symlink.target = "${./2-colin-NetworkManager-isConnected.lua}";
|
# fs.".config/koreader/patches/2-colin-NetworkManager-isConnected.lua".symlink.target = "${./2-colin-NetworkManager-isConnected.lua}";
|
||||||
|
|
||||||
|
fs.".config/koreader/patches/2-02-colin-impl-clipboard-ops.lua".symlink.target = "${./2-02-colin-impl-clipboard-ops.lua}";
|
||||||
|
|
||||||
# koreader news plugin, enabled by default. file format described here:
|
# koreader news plugin, enabled by default. file format described here:
|
||||||
# - <repo:koreader/koreader:plugins/newsdownloader.koplugin/feed_config.lua>
|
# - <repo:koreader/koreader:plugins/newsdownloader.koplugin/feed_config.lua>
|
||||||
fs.".config/koreader/news/feed_config.lua".symlink.text = ''
|
fs.".config/koreader/news/feed_config.lua".symlink.text = ''
|
||||||
|
|
Loading…
Reference in New Issue
Block a user