Инструменты пользователя

Инструменты сайта


xwindows:xsel

XSel

FIXME

command-line tool to access X clipboard and selection buffers

XSel is a command-line program for getting and setting the contents of the X selection. It can also append and have it follow a growing file (similar to tail -f).

Установка

apt-get install xsel

Обмен содержимым буфера обмена между двумя X Серверами

xsel_clipboard.sh
#! /bin/bash
firstxserver=$1
secondxserver=$2
#set the variables to the default
echo . | xsel --display $firstxserver -b -i
echo . | xsel --display $secondxserver -b -i
clipboard=.
 
while [ 1 ]
do
#get the values of the clipboard
firstdislpayclipboard=$(xsel --display $firstxserver -b -o)
seconddislpayclipboard=$(xsel --display $secondxserver -b -o)
 
#if the first x servers clipboad chages
if [ "$firstdislpayclipboard" != "$clipboard" ]
then
 
#if it doesnt change to be blank
if [ $(echo $firstdislpayclipboard | grep ^$ -c) -ne 1 ]
then
#set the appropriate variables to be the contents of the first comand
seconddislpayclipboard=$firstdislpayclipboard
clipboard=$firstdislpayclipboard
xsel --display $firstxserver -b -o | xsel --display $secondxserver -b -i
else
#if it is blank set it to be .in case if its because the x server went down
echo . | xsel --display $firstxserver -b -i
fi
 
fi
 
#if the second x servers clipboad chages
if [ "$seconddislpayclipboard" != "$clipboard" ]
then
 
#if it doesnt change to be blank
if [ $(echo $seconddislpayclipboard | grep ^$ -c) -ne 1 ]
then
#set the appropriate variables to be the contents of the first comand
firstdislpayclipboard=$seconddislpayclipboard
clipboard=$seconddislpayclipboard
xsel --display $secondxserver -b -o | xsel --display $firstxserver -b -i
else
#if it is blank set it to be .in case if its because the x server went down
echo . | xsel --display $secondxserver -b -i
fi
 
fi
 
sleep 1
done

Пример вызова:

xserver2.sh
#! /bin/bash
/bin/sh -c "X :4 -query xserver2"
(sleep 5s; xsel_clipboard.sh :0 :4) &
exit

Ссылки

xwindows/xsel.txt · Последние изменения: 2017-03-16 10:42 (внешнее изменение)