ob_paste_clip.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env python2
  2. # OpenBox pipe menu clipboard manager. Show parcellite clipboard, and inserts selected clip.
  3. #
  4. # Copyright 2013 Joe Bloggs (vapniks@yahoo.com)
  5. #
  6. # These scripts: ob_clipboard_manager.py, ob_clipboard_pipe_menu.py & ob_paste_clip.py
  7. # create a pipe menu for openbox which will display the history of clippings stored by parcellite
  8. # or clipit, and allow you to paste one of them by selecting it.
  9. # Obviously either parcellite or clipit needs to be installed for this to work, and they should not
  10. # be run in daemon mode.
  11. # parcellite should be available from the usual repositories, and clipit can be
  12. # obtained from here: http://clipit.rspwn.com/
  13. # If clipit is used then any static clippings will also be displayed in the pipe menu.
  14. # You may need to alter some of the following variables in ob_clipboard_manager.py:
  15. # clipit_history_file, parcellite_history_file, max_displayed_items
  16. # Installation: copy ob_clipboard_manager.py, ob_clipboard_pipe_menu.py & ob_paste_clip.py to your openbox
  17. # config directory (on Ubuntu its ~/.config/openbox), then add an item to your openbox menu.xml file
  18. # (also in the config dir) in the form:
  19. #
  20. # <menu execute="~/.config/openbox/ob_clipboard_pipe_menu.py" id="clipboard" label="Clipboard"/>
  21. #
  22. # This program is free software: you can redistribute it and/or modify
  23. # it under the terms of the GNU General Public License as published by
  24. # the Free Software Foundation, either version 3 of the License, or
  25. # (at your option) any later version.
  26. #
  27. # This program is distributed in the hope that it will be useful,
  28. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  30. # GNU General Public License for more details.
  31. #
  32. # You should have received a copy of the GNU General Public License
  33. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  34. #
  35. from ob_clipboard_manager import ob_cb_manager
  36. import pygtk
  37. import gtk
  38. import os
  39. import subprocess
  40. import sys
  41. # get the correct clipping
  42. index = int(sys.argv[1])
  43. manager = ob_cb_manager()
  44. clip = manager.clippings[index]
  45. # paste the clipping
  46. x = subprocess.Popen(['xvkbd','-xsendevent','-file','-'],stdin=subprocess.PIPE,stderr=open(os.devnull)).communicate(clip)