From 7e33e62486fcb7d7f95d369b2497286a577a759d Mon Sep 17 00:00:00 2001 From: Ksaper Date: Fri, 24 Feb 2023 21:24:15 +0200 Subject: [PATCH] Replace xclip dep using gtk clipboard --- widget/app_launcher/prompt.lua | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/widget/app_launcher/prompt.lua b/widget/app_launcher/prompt.lua index b97fcc8..15ac313 100644 --- a/widget/app_launcher/prompt.lua +++ b/widget/app_launcher/prompt.lua @@ -2,6 +2,9 @@ -- @author https://github.com/Kasper24 -- @copyright 2021-2022 Kasper24 ------------------------------------------- +local lgi = require('lgi') +local Gtk = lgi.require('Gtk', '3.0') +local Gdk = lgi.require('Gdk', '3.0') local awful = require("awful") local gtable = require("gears.table") local gstring = require("gears.string") @@ -146,13 +149,8 @@ end local function paste(self) local wp = self._private - awful.spawn.easy_async_with_shell("xclip -selection clipboard -o", function(stdout) - if stdout ~= nil then - local n = stdout:find("\n") - if n then - stdout = stdout:sub(1, n - 1) - end - + wp.clipboard:request_text(function(clipboard, text) + if text then wp.text = wp.text:sub(1, wp.cur_pos - 1) .. stdout .. self.text:sub(wp.cur_pos) wp.cur_pos = wp.cur_pos + #stdout generate_markup(self) @@ -413,6 +411,7 @@ local function new() wp.cur_pos = #wp.text + 1 or 1 wp.state = false + wp.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) widget:connect_signal("mouse::enter", function(self, find_widgets_result) capi.root.cursor("xterm")