Add ability to specify type for clipboard contents

This commit is contained in:
Gnarwhal 2024-09-10 15:11:02 +00:00
parent d922b30b5a
commit 0cbb81abdf
Signed by: Gnarwhal
GPG key ID: 0989A73D8C421174

View file

@ -14,6 +14,7 @@
import pyclip import pyclip
from sshare.plugin.config import Argument
from sshare.plugin.config import Flag from sshare.plugin.config import Flag
from sshare.plugin.config import NoDefault from sshare.plugin.config import NoDefault
from sshare.plugin.source import Raw from sshare.plugin.source import Raw
@ -21,13 +22,16 @@ from sshare.plugin.source import Raw
plugin_type = { "source", "feedback" } plugin_type = { "source", "feedback" }
activate = { activate = {
"source": { "from_clipboard" }, "source": { "type" },
"feedback": { "to_clipboard" }, "feedback": { "to_clipboard" },
} }
args = { args = {
"from_clipboard": Flag( "type": Argument(
name="paste", name="paste",
help="Upload the contents of the clipboard" nargs="?",
const=Flag,
default="txt",
help="Upload the contents of the clipboard as text"
), ),
"to_clipboard": Flag( "to_clipboard": Flag(
name="copy", name="copy",
@ -37,7 +41,7 @@ args = {
def get_source(): def get_source():
logger.info("Uploading contents of clipboard") logger.info("Uploading contents of clipboard")
return Raw("txt", pyclip.paste()) return Raw(config.type, pyclip.paste())
def give_feedback(location): def give_feedback(location):
pyclip.copy(location) pyclip.copy(location)