Skip to content

Commit

Permalink
add function is_xclip_installed()
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsumoto-ren committed Apr 9, 2024
1 parent e06b0fa commit 4a5e15a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion platform/nix.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ local function is_installed(exe_name)
return os.execute("which " .. exe_name) == 0
end

local function is_xclip_installed()
local handle = io.popen("xclip -version 2>&1", "r")
local result = handle:read("*a")
handle:close()
return result:find("xclip version") ~= nil
end

if h.is_mac() then
self.clip_util = "pbcopy"
self.clip_cmd = "LANG=en_US.UTF-8 " .. self.clip_util
Expand All @@ -22,7 +29,7 @@ elseif h.is_wayland() then
else
self.clip_util = "xclip"
self.clip_cmd = self.clip_util .. " -i -selection clipboard"
self.healthy = is_installed(self.clip_util)
self.healthy = is_xclip_installed()
end

self.tmp_dir = function()
Expand Down

0 comments on commit 4a5e15a

Please sign in to comment.