解决 google chrome 浏览器里复制的内容不能粘贴到vmware workstation虚拟机里的问题
1、现象:
ubuntu 上安装的google chrome 浏览器复制的内容不能粘贴到vmware workstation虚拟机里,但能正常复制到其他地方,如gedit里:
google chrome 里复制内容 ---粘贴---》vmware workstation虚拟机 (不能)
google chrome 里复制内容 ---粘贴---》其他地方,如gedit里(正常)
发现发生问题的软件版本:
ubuntu 14.04 + google chrome (36,37的版本都会,35正常) + vmware workstation 10.0.3 build-1895310(虚拟 windows 8.1 32位)
2、解决办法:
论坛上发现的老外搞的办法,用python来在后台监视剪贴板变化,发现是chrome引起的就运行“xsel -o -b|xsel -i -p;xsel -o -p|xsel -i -b”命令,具体原理后面在去了解,先分享方法出来给难兄难弟,呵呵。
老外脚本地址(由衷感谢他的分享):
https://gist.github.com/solariz/2ec85f1f8fe0d4f44b6f
拿过来要改下,监控google chrome引起的剪贴板变化就行了,记得先安装xdotool和xsel
1、安装软件:
sudo apt-get install xdotool xsel
2、改脚本(脚本我命名为cpchrome.py)
3、运行脚本:
nohup python cpchrome.py &
4、google chrome 里复制内容 ---粘贴---》vmware workstation虚拟机 (OK,oo)
5、附上我改过的脚本cpchrome.py(“#sjw add”为我改过的地方):
#!/usr/bin/python ## License: CC0 ## Author: Marco Goetze ## Web: http://solariz.de ## Version: 1.2 ## DIZ: ## Little Helper Script for Linux to make my KeePass Copy and Paste cooperate again with ## Chrome Browser. ## You need to have the latest keepass version and XSEL installed. ## Tested with: ## xsel 1.2.0 ## keepass 2.27 ## xdpyinfo 1.3.1 ## chrome 36 ## on Linux Mint Qiana (x64) on MATE and Cinnamon but should work on any gnome based desktop ## ## Plese see this chrome topic for discussion: https://productforums.google.com/forum/#!topic/chrome/4s5_Sx-e4z0 ## ## You can edit this if needed, I use it since v1.2 to prevent the clipboard copy operation on each Copy Action ## it should only run when invoked by LastPass. To make this happen be sure you have 'xdotool' & 'xsel' installed ## apt-get install xdotool xsel ## without this script will not work! ## #window_name_matches = ['KeePass', 'kdbx', 'Edit Entry', 'Add Entry'] #sjw change window_name_matches = ['Google Chrome'] #sjw add ## no need for changes below here from gi.repository import Gtk, Gdk import subprocess glob_inhalt = "" print "KeePass Linux Clipboard Workaround" print "Version 1.2 by Marco Goetze (www.solariz.de)" def test(*args): global glob_inhalt found = False # Get Clipboard task = subprocess.Popen("xsel -o -b", shell=True, stdout=subprocess.PIPE) data = task.stdout.read() assert task.wait() == 0 # check if changed if data != glob_inhalt: glob_inhalt = data print "Clipboard changed, checking if Lastpass Window is active..." task = subprocess.Popen("xdotool getactivewindow getwindowname", shell=True, stdout=subprocess.PIPE) winID = task.stdout.read().rstrip('\n') ##print winID winID = winID.rpartition('-')[2].strip() #sjw add ##print winID for s in window_name_matches: if s in winID: found = True if found == True: print "Match detected, processing Clipboard..." # wtf... yes, this works. From Clipboard to Primaty to clipboard and chome have it in CTRL-V task = subprocess.Popen("xsel -o -b|xsel -i -p;xsel -o -p|xsel -i -b", shell=True, stdout=subprocess.PIPE) data = task.stdout.read() assert task.wait() == 0 else: print "No Match." clip = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) clip.connect('owner-change',test) Gtk.main()
2015-10-28 最新重写版代码见 http://sjwpython.iteye.com/blog/2252843
相关推荐
VMware Workstation 6.5 虚拟机VMware Workstation 6.5 虚拟机VMware Workstation 6.5 虚拟机
VMware Workstation 虚拟机远程电源管理源码.zipVMware Workstation 虚拟机远程电源管理源码.zipVMware Workstation 虚拟机远程电源管理源码.zipVMware Workstation 虚拟机远程电源管理源码.zipVMware Workstation ...
VMware Workstation虚拟机如何使用yum源
在 VMware Workstation 虚拟机中创建共享文件夹的步骤。
VMware Workstation虚拟机使用资料
VMware Workstation 允许操作系统和应用程序在一台虚拟机内部运行。虚拟机是独立运行主机操作系统的离散环境。在 VMware Workstation 中,你可以在一个窗口中加载一台虚拟机,它可以运行自己的操作系统和应用程序。...
在vmware Workstation中新建虚拟机出现新建虚拟机向导
VMwareWorkstation虚拟机详细使用教程.pdf
Redhat虚拟机与宿主机之间通过NAT方式共享上网设置(原创)
vmware workstation虚拟机在不启用的时候,后台服务还在开启者,有强迫症的童靴们肯定要一个一个关闭它,但是这样很麻烦,于是我就写了一键关闭vmware workstation虚拟机服务和网卡的bat,这样就能很快捷方便的关闭...
VMware Workstation 窗口 使用虚拟网络编辑器 常见网络连接模式 创建新虚拟机 使用虚拟机 VMware Workstation 窗口 1 请在此处输入标题 使用虚拟网络编辑器 2 请在此处输入标题 常见网络连接模式 3 常见网络连接模式...
VMware Workstation(虚拟机) V7.0.0 绿色版
获得VMware Workstation 虚拟机的注册机可以获得最新版本的注册码。本人亲测可以使用,
利用vmware workstation虚拟机搭建cloudstack4.2.1
一.安装VMware Workstation虚拟机软件
vmware workstation 12虚拟机安装llinux
VMware Workstation虚拟机使用方法.docx
VMware Workstation(虚拟机) V6.5.2 Build 156735 汉化版
VMware Workstation(中文名“威睿工作站”)是一款功能强大的桌面虚拟计算机软件,提供用户可在单一的桌面上同时运行不同的操作系统,和进行开发、测试 、部署新的应用程序的最佳解决方案。VMware Workstation可在...
Vmware Vmware Vmware Vmware虚拟机文件越来越大解决方案