aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-11-11 14:26:19 -0200
committerSilvio Rhatto <rhatto@riseup.net>2018-11-11 14:26:19 -0200
commit53e5bf91034872c35baa5abc7831daaa58d03745 (patch)
tree24e3d24563cb74cf6881f26546d330cbc020d2d4
parent8b8d8b6ff6b7e7130b3693e250712b57e56b92e7 (diff)
downloadkvmx-53e5bf91034872c35baa5abc7831daaa58d03745.tar.gz
kvmx-53e5bf91034872c35baa5abc7831daaa58d03745.tar.bz2
Sketching a better clipboard UX
-rwxr-xr-xkvmx-spice-copy59
l---------kvmx-spice-paste1
2 files changed, 60 insertions, 0 deletions
diff --git a/kvmx-spice-copy b/kvmx-spice-copy
new file mode 100755
index 0000000..3102a33
--- /dev/null
+++ b/kvmx-spice-copy
@@ -0,0 +1,59 @@
+#!/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
+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
diff --git a/kvmx-spice-paste b/kvmx-spice-paste
new file mode 120000
index 0000000..4d2acfa
--- /dev/null
+++ b/kvmx-spice-paste
@@ -0,0 +1 @@
+kvmx-spice-copy \ No newline at end of file