Clipboard goes blank after program has ended
Hi there,
Thank for this awesome module. I am using Ubuntu and every time I close my node app, the clipboard goes blank. Is it possible to have it stay like it last was? Like if I copy "Foo" and then close the program, to still be able to paste "Foo"?
Thanks!
I'm glad you are enjoying the module. :)
That's very surprising. Nothing special happens on exit. Underneath the covers, copy-paste uses xclip. I briefly looked through the docs and I don't seeing anything that would explain this behavior.
I'm stumped! Perhaps an extra paste call is being made somewhere?
I'll check and get back to you, thanks for your help!
this is my code, couldn't find anything
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var clipboard = require('copy-paste');
var previousClipboardContent = clipboard.paste();
io.on('connection', function(socket){
console.log('connection');
socket.on('clipboard', function(data){
clipboard.copy(data, function() {
console.log('copied some text: ' + clipboard.paste());
previousClipboardContent = clipboard.paste();
});
});
});
http.listen(3000, function(){
console.log('listening on *:3000');
});
function checkClipboard () {
if (previousClipboardContent !== clipboard.paste()) {
io.emit('clipboard', clipboard.paste());
}
}
setInterval(checkClipboard, 1*1000);