#!/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 . # # Parameters SPOOL="$TMP/.kvmx-spice-copy" BASENAME="`basename $0`" DEST="`xprop -id $WINDOWID | grep "^WM_NAME" | cut -d '=' -f 2 | cut -d '"' -f 2`" # Logic if [ "$BASENAME" == "kvmx-spice-copy" ]; then mkdir -p "$TMP" echo "$DEST" > $SPOOL else if [ -f "$SPOOL" ]; then ORIG="`cat $SPOOL`" else ORIG="host" fi if [ "$ORIG" != "host" ] && ! kvmx running $ORIG &> /dev/null; then exit fi if [ "$DEST" != "host" ] && ! kvmx running $DEST &> /dev/null; then exit fi if ! kvmx running $DEST &> /dev/null; then DEST="host" fi if [ "$ORIG" == "$DEST" ]; then exit fi if [ "$ORIG" == "host" ] && [ "$DEST" == "host" ]; then exit fi # Dispatch kvmx-clipboard $ORIG $DEST fi