Jump to content




Copy & Paste (Multiplayer) from Linux

utility

8 replies to this topic

#1 oreillynz

  • New Members
  • 14 posts

Posted 05 April 2012 - 12:14 PM

Playing online?
Can't get Ctrl+V to work correctly for ComputerCraft?
Fighting the urge to scoop your eyes out with a rusty spoon white trying to program in ComputerCraft directly?


Did you know you can get linux to type the contents of the clipboard into minecraft?... Here's how:


First, install some tools:

You'll need to install "xdotool" and "xbindkeys."
You can install these from the command line with "[sudo] apt-get install xdotool, xbindkeys"


Then, copy and paste this script
.. into a sensible location (for example, to "~/autopaste.py)

Spoiler

You'll need to make that script 'runnable', which assuming you've saved it as something like "~/autopaste.py" can be done (via command line) with "chmod +x autopaste.py"


Grab "Pyperclip" for clipboard access

The excellent "pyperclip" module is required, so you'll need to follow that link, and save "pyperclip.py" in the same location.


Set up configuration file for xbindkeys

Then, get xbindkeys to create a default config file and place it where it'll get automatically loaded using:
"xbindkeys --defaults > $HOME/.xbindkeysrc"

Open up this file, and comment out those examples if you don't want them. We're going to add a command to this config file to run the script you copied when you press "Windows+V". Copy the command below into the file:
"~/autoclip.py"
	Mod4+Super_L+v


Last, watch it run:

Make sure xbindkeys is running (you can also check the current shortcut keys with "xbindkeys -s"), then open up an editor in ComputerCraft (within minecraft), copy some code to the clipboard (just as you would normally), and hit "Windows+V"... you should now see linux doing the frantic typing for you, leaving you to make coffee.



More info + Other notes:

Spoiler


#2 Hawk777

  • Members
  • 162 posts

Posted 06 April 2012 - 09:09 AM

Or you can just press CTRL to go into the menu, then press CTRL+V to simultaneously leave the menu and also paste the clipboard.

#3 oreillynz

  • New Members
  • 14 posts

Posted 06 April 2012 - 03:43 PM

You can, but I find when using linux that only the first line gets pasted - even then, the last character is removed.

I suspect it's caused by *nix using single character for line return, where windows uses CR+LF (two characters) - so copying from a linux clipboard ends up with a 'unexpected' error at the end of the first line.

It's slower to use the above method, but at least it works, where-as Ctrl+V doesn't.

#4 libraryaddict

  • New Members
  • 195 posts

Posted 06 April 2012 - 05:08 PM

You know, I was wondering why the linux server hated copy/paste..

#5 Noodle

  • Members
  • 989 posts
  • LocationSometime.

Posted 07 April 2012 - 11:34 PM

Was confused.. Then saw Linux.

#6 TehSomeLuigi

  • Members
  • 70 posts

Posted 08 April 2012 - 01:11 PM

A fellow Linux user :P/>.

Going to bookmark this for reference.


edit: I can't seem to figure out how to work this, but the key combination simply doesn't work..

#7 oreillynz

  • New Members
  • 14 posts

Posted 09 April 2012 - 03:43 AM

Couple of quick questions to help debug....

On the command line, can you check xdotool and xbindkeys are installed? ("xdotool --help" and "xbindkeys --help" should do it)
Did you download and put the "pyperclip.py" file in the same location as the script?
(Oh! Being python, you may need to add an empty "__init__.py" file in the same folder, so python knows it should look in that folder for imports)
If you run "xbindkeys -mk" and press the combination you want, does the output match what you have added to the ~/.xbindkeysrc file?

#8 djblocksaway

    Epic Coderz

  • New Members
  • 397 posts
  • LocationAustralia

Posted 10 April 2012 - 01:40 PM

or you could use a program called scar DIVI and use a special code (Not sure if scar DIVI is for linux though :P/>)

#9 mrcrocodile123

  • Members
  • 25 posts

Posted 29 January 2013 - 07:55 AM

im a tad slow and new to linux, would a video tutorial be possible :/ haha i have a huge code i made on notepad that i wanna put on tekkit server





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users