-
Notifications
You must be signed in to change notification settings - Fork 32
sh: 1: cannot open /tmp/shluainput: No such file #12
Copy link
Copy link
Open
Description
I made a simple color picker for Linux. It is written in Lua but uses Python to get the pixel color. Sometimes it displays some strange messages. They don't break the script, but I just don't want to see them. Looks like there are problems with luash temp files ...
getpixelcolor.py
#!/bin/python3
import gi
gi.require_version("Gdk", "3.0")
from gi.repository import Gdk
import sys
def PixelAt(x, y):
w = Gdk.get_default_root_window()
pb = Gdk.pixbuf_get_from_window(w, x, y, 1, 1)
return pb.get_pixels()
print(tuple(PixelAt(int(sys.argv[1]), int(sys.argv[2]))))colorpicker.lua
#!/bin/luajit
local luash = require "sh"
local socket = require "socket"
local lume = require "lume" -- luarocks install lume
local getlocation = luash.command("xdotool getmouselocation")
local getcolor = luash.command("./getpixelcolor.py")
while true do
socket.sleep(0.1)
local location = tostring(getlocation())
local array = lume.split(location)
if not array[1] or not array[2] then goto continue end
local x = lume.split(array[1], ":")[2]
local y = lume.split(array[2], ":")[2]
local color = tostring(getcolor(x, y))
if not color then goto continue end
print(x, y, color)
::continue::
endoutput
271 186 (31, 31, 31)
389 189 (205, 136, 46)
542 448 (38, 38, 38)
503 746 (38, 38, 38)
sh: 1: cannot open /tmp/shluainput: No such file
478 743
477 742 (38, 38, 38)
419 728 (38, 38, 38)
414 716 (38, 38, 38)
469 712 (38, 38, 38)
475 710 (38, 38, 38)
sh: 1: cannot open /tmp/shluainput: No such file
474 704
278 534 (215, 163, 100)
46 550 (15, 15, 15)
91 637 (38, 38, 38)
82 591 (203, 215, 163)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels