首页 > Script > xsel妙用一则

xsel妙用一则

[总点击:837次]
2009年3月15日

最近写论文,老板只要word格式的文档,无奈之下用crossover安装了一个m$office,好倒是好,但是stardict查词就不方便了,stardict好像是通过访问鼠标选中复制的那个玩意(PRIMARY)里面来取词的,而不是通过剪贴板(CLIPBOARD),这招在wine的程序中就不管用了,因为在wine的程序中选中单词并不会将其寄存起来,所以在word里面就只好先ctrl+c将单词复制到剪贴板,然后再粘贴到stardict中去查询了,非常麻烦。
想到有一个小程序叫xsel的可以访问和修改剪贴板:

XSEL(1x) XSEL(1x)

NAME
xsel – manipulate the X selection.

SYNOPSIS
xsel [OPTION]…

DESCRIPTION
Retrieve and set the X selection.

The X server maintains three selections, called PRIMARY, SECONDARY and CLIPBOARD. The
PRIMARY selection is conventionally used to implement copying and pasting via the mid‐
dle mouse button. The SECONDARY and CLIPBOARD selections are less frequently used by application programs. This program operates on the PRIMARY selection unless otherwise
specified.
….

哈哈,那就简单了,只要将CLIPBOARD里面的内容写到PRIMARY里面就OK了,很简单,只要一句话:

while :;do [ "`xsel -b`" != "`xsel`" ] && xsel -b|xsel;sleep 1;done

测试之下果然是可以的:

发件人 xiooli

Script ,

  1. oldherl
    2009年4月24日17:41 | #1

    这个单词……真orz

本文的评论功能被关闭了.