summary refs log tree commit diff stats
path: root/clipboard
diff options
context:
space:
mode:
Diffstat (limited to 'clipboard')
-rw-r--r--clipboard/selection.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/clipboard/selection.go b/clipboard/selection.go
new file mode 100644
index 0000000..0ff5d7f
--- /dev/null
+++ b/clipboard/selection.go
@@ -0,0 +1,18 @@
+package clipboard
+
+import (
+	"os/exec"
+)
+
+// GetSel returns the primary clipboard selection using the xclip tool
+// & also returns an error (if exists) along with the primary
+// clipboard selection.
+func GetSel() (string, error) {
+	out, err := exec.Command("xclip", "-out").Output()
+	if err != nil {
+		return "", err
+	}
+
+	sel := string(out)
+	return sel, err
+}