diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2018-10-24 18:36:38 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2018-10-24 18:36:38 -0300 |
commit | 650128c37a1f56d7c12dd2e7583c111e31591f14 (patch) | |
tree | 4d932f1f6a7f43a7551045d3b8aee7723690eabe | |
parent | 1d9ccc542d0b6d6dd8db085cfb5269a603d90b94 (diff) | |
download | kvmx-650128c37a1f56d7c12dd2e7583c111e31591f14.tar.gz kvmx-650128c37a1f56d7c12dd2e7583c111e31591f14.tar.bz2 |
Adds kvmx-clipboard
-rwxr-xr-x | kvmx | 1 | ||||
-rwxr-xr-x | kvmx-clipboard | 98 | ||||
-rwxr-xr-x | share/provision/desktop-basic | 2 |
3 files changed, 100 insertions, 1 deletions
@@ -277,6 +277,7 @@ function kvmx_spice { fi xdotool search --name "SPICEc:0" set_window --name $VM + xdotool search --name "spice display 0:0" set_window --name $VM fi if [ "$ACTION" == "spice" ]; then diff --git a/kvmx-clipboard b/kvmx-clipboard new file mode 100755 index 0000000..3005c51 --- /dev/null +++ b/kvmx-clipboard @@ -0,0 +1,98 @@ +#!/usr/bin/env bash +# +# kvmx-clipboard manage clipboard sharing between host and guests +# +# Copyright (C) 2018 Silvio Rhatto - rhatto at riseup.net +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation, either version 3 of the License, +# or any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +# Parameters +CONTENT="" + +function __kvmx_clipboard_receive { + local VM="$1" + + if [ "$VM" == "host" ]; then + #CONTENT="`xclip -o`" + CONTENT="`xsel -o`" + else + #CONTENT="`kvmx ssh $VM -X 'DISPLAY=:0 xclip -o'`" + CONTENT="`kvmx ssh $VM -X 'xsel -o --display :0'`" + fi +} + +function __kvmx_clipboard_send { + local VM="$1" + + if [ "$VM" == "host" ]; then + #echo $CONTENT | xclip -i + echo $CONTENT | xsel -i + else + #echo $CONTENT | kvmx ssh $VM -X 'DISPLAY=:0 xclip -i -l 1' + echo $CONTENT | kvmx ssh $VM -X 'xsel -i --display :0' + fi +} + +function __kvmx_clipboard_copy { + local ORIG="$1" + local DEST="$2" + + __kvmx_clipboard_receive $ORIG + __kvmx_clipboard_send $DEST +} + +function __kvmx_clipboard_list { + # That's crude, but fast + instances="`ps aux | grep qemu-system | grep -- '-name ' | sed -e 's/^.*-name //' -e 's/ .*//'`" + instances="host $instances" + + echo "KVMX Clipboard" + echo "" + + n="0" + + # Buld menu entries + for orig_instance in $instances; do + for dest_instance in $instances; do + if [ "$orig_instance" == "$dest_instance" ]; then + continue + fi + + echo "$n: $orig_instance -> $dest_instance" + + let n++ + done + done +} + +function __kvmx_clipboard_menu { + __kvmx_clipboard_list + + echo "" + read -rep "Your choice: " n + + choice="$(__kvmx_clipboard_list | grep ^$n: | sed -e "s/^$n://" -e "s/->//")" + + if [ ! -z "$choice" ]; then + __kvmx_clipboard_copy $choice + fi +} + +# Main +if [ -z "$2" ]; then + __kvmx_clipboard_menu +else + __kvmx_clipboard_copy $1 $2 +fi diff --git a/share/provision/desktop-basic b/share/provision/desktop-basic index b90c83e..7571a89 100755 --- a/share/provision/desktop-basic +++ b/share/provision/desktop-basic @@ -46,7 +46,7 @@ apps/metadot/metadot deps-bundle desktop-basic # Additional packages echo "Installing additional desktop-basic packages..." -$APT_INSTALL xpra lightdm firejail +$APT_INSTALL xpra lightdm firejail xsel # See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=861744 $APT_INSTALL torbrowser-launcher alsa-utils pulseaudio |