Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clipboard goes blank after program has ended #31

Open
ghost opened this issue Aug 1, 2015 · 3 comments
Open

Clipboard goes blank after program has ended #31

ghost opened this issue Aug 1, 2015 · 3 comments

Comments

@ghost
Copy link

ghost commented Aug 1, 2015

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!

@xavi-
Copy link
Owner

xavi- commented Aug 2, 2015

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?

@ghost
Copy link
Author

ghost commented Aug 3, 2015

I'll check and get back to you, thanks for your help!

@ghost
Copy link
Author

ghost commented Aug 3, 2015

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant