Alternate for 'clip' command in ubuntu [duplicate]

I am using a python program to copy an input and pasting the output to chrome browser input field .

For windows there is the 'clip' command that pastes the data.

name = "งดดา"
command = 'echo ' + name.strip() + '| clip'
os.system(command)

This works perfectly in windows. I am having issue with pasting the value to input field in Ubuntu. I have tried various ways but have not succeeded yet. I have used Xdo Library which seems to work for standard English words and numbers but doesnot work prefectly for Thai text. Here is the link to the code i have used XDO code for paste.

I believe there is an alterante for 'clip' command in Ubuntu that will do the trick.

The solution here deals with files, but I am using specific texts (Thai texts to be precise which requires tis-620 decoding) which are not supported easily.

0

1 Answer

I managed to solve the issue by using xdotool and xsel

def cb(name): paste = 'xdotool key ctrl+v' enter = 'xdotool key Tab' print("Executing *******************") command = 'echo '+ name.strip()+' | xsel -b' print ("command copy > ",command) os.system(command) print ("command paste> ",paste) os.system(paste) print ("command enter> ",enter) os.system(enter)

Name is any string value that can be sent as argument (number, alphabets , Thai text).

  1. First I copy the name to the clipboard.

  2. Second i paste the input from the clipboard.

  3. Third i press (simulate ) tab and move to the next input box.

Hope this helps someone in future .

You Might Also Like