From: dfinnie Date: 2008-01-03T06:09:58+09:00 Subject: Clipboard command line utility I've been doing a lot of Python for Google's Highly Open Participation contest lately but finally found the time to make a utility I thought of a few weeks ago. Basically, it allows you to pipe to and from the clipboard on the command line. Example: daniel@daniel-desktop:~$ echo 'ruby' | clipboard daniel@daniel-desktop:~$ clipboard ruby daniel@daniel-desktop:~$ You can also access it with the normal Control-C/Control-V shortcuts. So, it's a great concept, but not such a good implementation. First, I doctored the output above. ruby-gnome2 seems to be outputting error messages that I can't get rid of, even after a Google search. This is the real output: daniel@daniel-desktop:~$ echo 'ruby' | clipboard /usr/lib/ruby/1.8/glib2.rb: line 55 GLib-GObject-CRITICAL **:g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed /usr/lib/ruby/1.8/glib2.rb: line 55 GLib-GObject-CRITICAL **:g_param_spec_boxed: assertion `G_TYPE_IS_BOXED (boxed_type)' failed /usr/lib/ruby/1.8/glib2.rb: line 55 GLib-GObject-CRITICAL **:g_object_class_install_property: assertion `G_IS_PARAM_SPEC (pspec)' failed /usr/lib/ruby/1.8/glib2.rb: line 55 GLib-GObject-CRITICAL **:g_param_spec_boxed: assertion `G_TYPE_IS_BOXED (boxed_type)' failed /usr/lib/ruby/1.8/glib2.rb: line 55 GLib-GObject-CRITICAL **:g_object_class_install_property: assertion `G_IS_PARAM_SPEC (pspec)' failed daniel@daniel-desktop:~$ clipboard /usr/lib/ruby/1.8/glib2.rb: line 55 GLib-GObject-CRITICAL **:g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed /usr/lib/ruby/1.8/glib2.rb: line 55 GLib-GObject-CRITICAL **:g_param_spec_boxed: assertion `G_TYPE_IS_BOXED (boxed_type)' failed /usr/lib/ruby/1.8/glib2.rb: line 55 GLib-GObject-CRITICAL **:g_object_class_install_property: assertion `G_IS_PARAM_SPEC (pspec)' failed /usr/lib/ruby/1.8/glib2.rb: line 55 GLib-GObject-CRITICAL **:g_param_spec_boxed: assertion `G_TYPE_IS_BOXED (boxed_type)' failed /usr/lib/ruby/1.8/glib2.rb: line 55 GLib-GObject-CRITICAL **:g_object_class_install_property: assertion `G_IS_PARAM_SPEC (pspec)' failed ruby daniel@daniel-desktop:~$ I have tried doing something like this with stderr, stdout, and defout with no luck: require 'stringio' old_stderr = $stderr $stderr = StringIO.new require 'gtk2' $stderr = old_stderr Any suggestions? I have posted the full source code to http://ruby.pastebin.com/f5ef5f028 I would also like a better way to capture STDIN without blocking if there is no text on STDIN. Thanks, Dan Finnie dan@danfinnie.com