Clipboard write

Anyone ever use the clipboard-write node? I've got a debug node hooked up in parallel that says msg.payload = "x", but when I paste from the clipboard it just gives me "payload".

a simple inject seems to work for me... can you share just that part of your flow that fails ?

Hmm. I think I might be off track here. How did you access the clipboard? I realize that this probably isn't going to put anything on the clipboard of the device running the UI. Which is what silly me was hoping for.

good point - i was just trying it all on the one machine so of course it works :slight_smile:

It is based on this library - https://www.npmjs.com/package/copy-paste so I think you are correct - will be the server side clipboard it goes into.

1 Like

I just wanted to be able to copy the notification text, and it looks like it lets me do that, so I'm good. Thanks. Are you the main nr guy?

Are you folks discussing node-red-contrib-clipboard? I haven't tried it before, and I can't make it work. I'm running NR v0.20.0-beta.5 and Node.js v8.15.0, and the browser is Safari on macOS 10.11.6. My flow is

[{"id":"f23d38c3.ea5b","type":"inject","z":"d1d36546.c9449","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":90,"wires":[["f9d764ea.2db1b8"]]},{"id":"f9d764ea.2db1b8","type":"clipboard-read","z":"d1d36546.c9449","name":"","x":390,"y":90,"wires":[["681321c1.855588"]]},{"id":"681321c1.855588","type":"debug","z":"d1d36546.c9449","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":570,"y":90,"wires":[]},{"id":"f1bda44b.21bff8","type":"inject","z":"d1d36546.c9449","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":170,"wires":[["656efb0d.f04504","bacd0528.d8cfc"]]},{"id":"656efb0d.f04504","type":"clipboard-write","z":"d1d36546.c9449","name":"","x":420,"y":170,"wires":[]},{"id":"bacd0528.d8cfc","type":"debug","z":"d1d36546.c9449","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":410,"y":220,"wires":[]}]

The clipboard-read node reports an error

Error: Command failed: xclip -selection clipboard -o
Error: Can't open display: (null)

and the clipboard-write node fails silently. Am I doing something wrong?

Yes we are. I was running NR in chrome on windows, and was thinking that content would go between NR and my windows clipboard. Of course, that isnt the case, so I lost interest. What are you hoping to do?

I have a dashboard that surfaces a button to copy some of the dashboard content to the clipboard. I store content in a global variable referenced by many nodes. All is well.

I also use clipboard-write to copy some of that content to the clipboard. msg.payload is set to that content in a function node before the clipboard-write. clipboard-write seems not to work.

[{"id":"a2bd589d.078638","type":"clipboard-write","z":"dashboard_id","name":"","x":560,"y":1160,"wires":[]},{"id":"ea301efb.3b4c4","type":"ui_button","z":"dashboard_id","name":"Copy to Clipboard","group":"ui_group_id","order":10,"width":"3","height":"1","passthru":false,"label":"Copy to clipboard","tooltip":"","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":110,"y":1120,"wires":[["7802e1ad.82c36"]]},{"id":"7f3b7207.6806dc","type":"debug","z":"dashboard_id","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":530,"y":1120,"wires":[]},{"id":"7802e1ad.82c36","type":"function","z":"dashboard_id","name":"payload to copy","func":"var lines=\"this is a test\"\nmsg.payload=lines\nreturn msg\n","outputs":1,"noerr":0,"x":320,"y":1120,"wires":[["7f3b7207.6806dc","a2bd589d.078638"]]},{"id":"ui_group_id","type":"ui_group","z":0,"name":"Control panel","tab":"cd39e1f4.b9df3","order":1,"disp":true,"width":"40","collapse":false},{"id":"cd39e1f4.b9df3","type":"ui_tab","z":0,"name":"Laguna Research Instrument Dashboard","icon":"dashboard","disabled":false,"hidden":false}]

Any insights would be appreciated. Thanks!

Have you tried a simple case? Try this

[{"id":"2b78b1c6.a96486","type":"inject","z":"646a34cd.8135ac","name":"","topic":"","payload":"Hello World","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":60,"wires":[["612c7ffd.e6311"]]},{"id":"69a1604e.addfe","type":"clipboard-read","z":"646a34cd.8135ac","name":"","x":320,"y":120,"wires":[["f767a1a8.31317"]]},{"id":"612c7ffd.e6311","type":"clipboard-write","z":"646a34cd.8135ac","name":"","x":320,"y":60,"wires":[]},{"id":"f767a1a8.31317","type":"debug","z":"646a34cd.8135ac","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":530,"y":120,"wires":[]},{"id":"a720c660.2beb08","type":"inject","z":"646a34cd.8135ac","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":120,"wires":[["69a1604e.addfe"]]}]

If it doesn't work then
1 - what platform are you using (OS and release)
2 - what version of Node-RED, node.js and dashboard? (you can get this from the startup log)

Your flow works for me.

Wow -- thank you so much for responding so quickly. No joy:

Error: Command failed: xclip -selection clipboard -o
/bin/sh: 1: xclip: not found

Node-red:  1.0.5
[info] Node-RED version: v1.0.5
[info] Node.js  version: v10.20.1
[info] Linux 4.15.0-1065-aws x64 LE

Host OS:
Linux ip-172-30-2-214 4.15.0-1065-aws #69-Ubuntu SMP Thu Mar 26 02:17:29 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
18.04.2 LTS (Bionic Beaver)

That would seem to be a native OP application... so may need to be pre-installed... outside of Node-RED.

sudo apt-get install xclip

Hmm -- installed xclip:

Error: Command failed: xclip -selection clipboard -o
Error: Can't open display: (null)

The github for node-red-contrib-clipboard shows the write js as:

var clipboard = require("copy-paste").global();

module.exports = function(RED) {
    function ClipboardWriteNode(config) {
        RED.nodes.createNode(this,config);
        var node = this;
        this.on('input', function(msg) {
            try {
                clipboard.copy(msg.payload);
            } catch (e) {
                node.error(e);
            }
            node.send(msg);
        });
    }
    RED.nodes.registerType("clipboard-write", ClipboardWriteNode);

If this is a js module, I don't get why it's calling xclip.

I was under the impression this module had been used. If not, I'll just write a bash script to call xclip with the content. Prefer to use nodes if possible -- cleaner.

What version are you on? Should I try to downgrade?

I did it in MacOS and it worked fine