Posted 14 May 2014 - 01:49 PM
CC-copy for Linux!
Description
now anyone who has used a minecraft computer knows that the internal editor isnt the best, but works. but i have noticed that cc-copy allows you to upload it to server without needing to use pastebin.com, but does not work at all in Linux under wine, so people using Linux are left in the dark.
so i did some googling and found that their is a program for Linux that does a very similar job to cc-copy, called xdotool. xdotool has many features, such as the ability to type out a single character or a whole string(which is essentially what cc-copy does) so i wrote a little lua script to run xdotool. but before that you will need to install lua and xdotool.
note xdotool requires a special feature of your xserver called XTEST. it was enabled by default on my install so i didn't worry about it, but it may cause issues.
open a terminal and do the following lines (for ubuntu)
then make a new blank file whereever you prefer, and copy in the below script
The Script
this script needs to be run in a terminal and after opening enter the path to the file
then enter the window name, and now will find and select the window.
i wish to point out this does not type edit program, nor save and exit when done, and the default speed for xdotool is 12ms between key presses.
please dont post errors such as "No such file or directory" , as that just means you typed in a path wrong (paths are caps sensitive) or the issue is "bad interpreter error" then change #!/bin/lua to #!/usr/bin/lua
this script is for linux!!! not for windows, do not try using for windows it will not work, instead use cc-copy for windows. any and every windows related errors will be ignored.use at own risk.
Description
now anyone who has used a minecraft computer knows that the internal editor isnt the best, but works. but i have noticed that cc-copy allows you to upload it to server without needing to use pastebin.com, but does not work at all in Linux under wine, so people using Linux are left in the dark.
so i did some googling and found that their is a program for Linux that does a very similar job to cc-copy, called xdotool. xdotool has many features, such as the ability to type out a single character or a whole string(which is essentially what cc-copy does) so i wrote a little lua script to run xdotool. but before that you will need to install lua and xdotool.
note xdotool requires a special feature of your xserver called XTEST. it was enabled by default on my install so i didn't worry about it, but it may cause issues.
open a terminal and do the following lines (for ubuntu)
sudo apt-get install lua5.2
sudo apt-get install xdotool
then make a new blank file whereever you prefer, and copy in the below script
The Script
Spoiler
#!/bin/lua
io.write("Path to File:")
filename=io.read()
io.write("\nwindow name,blank defaults to Minecraft: ")
winame = io.read()
if winame=="" then
winame="Minecraft"
end
a=io.popen("xdotool search --limit 1 --name "..winame) --lists what window id with the name of winame(minecraft window), stops after first match
b=a:read("*a")
a:close()
print("debug:"..B)/>/>/>
os.execute("xdotool windowfocus "..B)/>/>/>-- focus on window with id stored in b
for line in io.lines(filename) do
line=string.gsub(line, "\"", "\\\"") -- excape those pesky quotation marks
os.execute( "xdotool type ".."\""..line.."\"")-- type the line
os.execute("xdotool key KP_Enter") -- simulates enter
end
this script needs to be run in a terminal and after opening enter the path to the file
then enter the window name, and now will find and select the window.
i wish to point out this does not type edit program, nor save and exit when done, and the default speed for xdotool is 12ms between key presses.
please dont post errors such as "No such file or directory" , as that just means you typed in a path wrong (paths are caps sensitive) or the issue is "bad interpreter error" then change #!/bin/lua to #!/usr/bin/lua
this script is for linux!!! not for windows, do not try using for windows it will not work, instead use cc-copy for windows. any and every windows related errors will be ignored.use at own risk.