Difference between revisions of "Changing Clipboard Data From The Shell"

From WebOS Internals
Jump to navigation Jump to search
(New page: How to put data into the clipboard from a rooted Pre. The "'''/tmp/webkit-clipboard'''" file is where "copied" data is stored (hence clipboard). If you want to change what is on the "cli...)
 
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
How to put data into the clipboard from a rooted Pre.
+
{{template:patch}}
 +
== Changing Clipboard Data From The Shell ==
  
The "'''/tmp/webkit-clipboard'''" file is where "copied" data is stored (hence clipboard).  If you want to change what is on the "clipboard" of the phone, just edit this file with whatever you want and when the "paste" routine is called your data will show up.
+
When you use the copy and paste function on your Pre the string has to go somewhere. Right? Well, from what I learned from '''tharris''' which was that the string goes to a file called '''webkit-clipboard''' which is located in the '''/tmp''' directory.
  
Something small but worth noting for testing
 
  
Townsend Ladd Harris (tharris- IRC)
+
== Manual Steps ==
 +
 
 +
 
 +
'''Step One:''' Access the Linux portion of your Pre
 +
 
 +
'''Step Two:''' Edit your clipboard file '''(you need to at least copy and paste something once for the file to show up)'''
 +
 
 +
<pre>
 +
vi /tmp/webkit-clipboard
 +
</pre>
 +
 
 +
'''Step Three:''' Save it.
 +
 
 +
'''Tip:''' for more info on how to use vi, remember Google is your friend...
 +
 
 +
By: JRG
 +
 
 +
 
 +
== WebOS Clipboard Buddy ==
 +
 
 +
'''WebOS Clipboard Buddy''' is a very simple pyGTK app that allows you to easily copy data between your desktop's clipboard and the Pre's clipboard. Feel free to improve upon it. Currently this is Linux only, though it should be trivial to get working under windows. It currently requires that you have the SDK installed (specifically that novacom is functional and available at /usr/local/bin/novacom/novacom).
 +
 
 +
<pre>
 +
#!/usr/bin/env python
 +
 
 +
# Copyright (c) 2009 James Hines
 +
 
 +
# Permission is hereby granted, free of charge, to any person
 +
# obtaining a copy of this software and associated documentation
 +
# files (the "Software"), to deal in the Software without
 +
# restriction, including without limitation the rights to use,
 +
# copy, modify, merge, publish, distribute, sublicense, and/or sell
 +
# copies of the Software, and to permit persons to whom the
 +
# Software is furnished to do so, subject to the following
 +
# conditions:
 +
 
 +
# The above copyright notice and this permission notice shall be
 +
# included in all copies or substantial portions of the Software.
 +
 
 +
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 +
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 +
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 +
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 +
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 +
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 +
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 +
# OTHER DEALINGS IN THE SOFTWARE.
 +
 
 +
 
 +
import gtk
 +
import pygtk
 +
import commands
 +
from subprocess import *
 +
 
 +
DEBUG=True
 +
 
 +
def quit_cb(widget, data = None):
 +
    if data:
 +
        data.set_visible(False)
 +
        gtk.main_quit()
 +
       
 +
def popup_menu_cb(widget, button, time, data = None):
 +
    if button == 3:
 +
        if data:
 +
            data.show_all()
 +
            data.popup(None, None, None, 3, time)
 +
            pass
 +
 
 +
def pre_to_clipboard_cb(widget):
 +
    clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
 +
    result = commands.getstatusoutput('/usr/local/bin/novacom/novacom get file:///tmp/webkit-clipboard')
 +
    if DEBUG:
 +
        print result
 +
    text = result[1]
 +
    clipboard.set_text(text)
 +
 
 +
def clipboard_to_pre_cb(widget):
 +
    clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
 +
    clipboard.request_text(push_to_pre)
 +
 
 +
def push_to_pre(clipboard, text, data):
 +
    pre = Popen(["/usr/local/bin/novacom/novacom", "put", "file:///tmp/webkit-clipboard"], stdin=PIPE, stdout=PIPE)
 +
    pre_output = pre.communicate(text)
 +
    if DEBUG:
 +
        print pre_output
 +
   
 +
 
 +
def about_icon_cb(widget, data = None):
 +
    msgBox = gtk.MessageDialog(parent = None, buttons = gtk.BUTTONS_OK, message_format = "WebOS Clipboard Agent\nVersion 1.1.0\nCopyright 2009, James Hines.")
 +
    msgBox.run()
 +
    msgBox.destroy()
 +
   
 +
statusIcon = gtk.StatusIcon()
 +
   
 +
menu = gtk.Menu()
 +
menuItem = gtk.MenuItem(label = "Copy from Pre")
 +
menuItem.connect('activate', pre_to_clipboard_cb)
 +
menu.append(menuItem)
 +
menuItem = gtk.MenuItem(label = "Copy to Pre")
 +
menuItem.connect('activate', clipboard_to_pre_cb)
 +
menu.append(menuItem)
 +
menuItem = gtk.SeparatorMenuItem()
 +
menu.append(menuItem)
 +
menuItem = gtk.ImageMenuItem(gtk.STOCK_ABOUT)
 +
menuItem.connect('activate', about_icon_cb)
 +
menu.append(menuItem)
 +
menuItem = gtk.ImageMenuItem(gtk.STOCK_QUIT)
 +
menuItem.connect('activate', quit_cb, statusIcon)
 +
menu.append(menuItem)
 +
   
 +
statusIcon.set_from_stock(gtk.STOCK_PASTE)
 +
statusIcon.set_tooltip("WebOS Clipboard Agent")
 +
statusIcon.connect('popup-menu', popup_menu_cb, menu)
 +
statusIcon.set_visible(True)
 +
   
 +
gtk.main()
 +
</pre>

Latest revision as of 11:08, 19 October 2009


Changing Clipboard Data From The Shell

When you use the copy and paste function on your Pre the string has to go somewhere. Right? Well, from what I learned from tharris which was that the string goes to a file called webkit-clipboard which is located in the /tmp directory.


Manual Steps

Step One: Access the Linux portion of your Pre

Step Two: Edit your clipboard file (you need to at least copy and paste something once for the file to show up)

vi /tmp/webkit-clipboard

Step Three: Save it.

Tip: for more info on how to use vi, remember Google is your friend...

By: JRG


WebOS Clipboard Buddy

WebOS Clipboard Buddy is a very simple pyGTK app that allows you to easily copy data between your desktop's clipboard and the Pre's clipboard. Feel free to improve upon it. Currently this is Linux only, though it should be trivial to get working under windows. It currently requires that you have the SDK installed (specifically that novacom is functional and available at /usr/local/bin/novacom/novacom).

#!/usr/bin/env python

# Copyright (c) 2009 James Hines

# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:

# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.


import gtk
import pygtk
import commands
from subprocess import *

DEBUG=True

def quit_cb(widget, data = None):
    if data:
        data.set_visible(False)
        gtk.main_quit()
        
def popup_menu_cb(widget, button, time, data = None):
    if button == 3:
        if data:
            data.show_all()
            data.popup(None, None, None, 3, time)
            pass

def pre_to_clipboard_cb(widget):
    clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
    result = commands.getstatusoutput('/usr/local/bin/novacom/novacom get file:///tmp/webkit-clipboard')
    if DEBUG:
        print result
    text = result[1]
    clipboard.set_text(text)

def clipboard_to_pre_cb(widget):
    clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
    clipboard.request_text(push_to_pre)

def push_to_pre(clipboard, text, data):
    pre = Popen(["/usr/local/bin/novacom/novacom", "put", "file:///tmp/webkit-clipboard"], stdin=PIPE, stdout=PIPE)
    pre_output = pre.communicate(text)
    if DEBUG:
        print pre_output
    

def about_icon_cb(widget, data = None):
    msgBox = gtk.MessageDialog(parent = None, buttons = gtk.BUTTONS_OK, message_format = "WebOS Clipboard Agent\nVersion 1.1.0\nCopyright 2009, James Hines.")
    msgBox.run()
    msgBox.destroy()
    
statusIcon = gtk.StatusIcon()
    
menu = gtk.Menu()
menuItem = gtk.MenuItem(label = "Copy from Pre")
menuItem.connect('activate', pre_to_clipboard_cb)
menu.append(menuItem)
menuItem = gtk.MenuItem(label = "Copy to Pre")
menuItem.connect('activate', clipboard_to_pre_cb)
menu.append(menuItem)
menuItem = gtk.SeparatorMenuItem()
menu.append(menuItem)
menuItem = gtk.ImageMenuItem(gtk.STOCK_ABOUT)
menuItem.connect('activate', about_icon_cb)
menu.append(menuItem)
menuItem = gtk.ImageMenuItem(gtk.STOCK_QUIT)
menuItem.connect('activate', quit_cb, statusIcon)
menu.append(menuItem)
    
statusIcon.set_from_stock(gtk.STOCK_PASTE)
statusIcon.set_tooltip("WebOS Clipboard Agent")
statusIcon.connect('popup-menu', popup_menu_cb, menu)
statusIcon.set_visible(True)
    
gtk.main()