Hi all, wondering if somebody could tell me what's wrong with my
script that's trying to talk with i3's IPC.
Whenever I try to read a reply from the socket, I apparently just get
an empty string.
I've already read the warning about using a library and not
implementing my own, thanks, but the Ruby library is unmaintained and
doesn't include recent IPC features.
I'm doing this:
___________________ 8>< snip ><8 _____________________________________
#!/usr/bin/env ruby
require 'socket'
socket = Socket.unix(`i3 --get-socketpath`.strip)
payload = "restart"
type = 0
length = payload.length
bytes = socket.write("i3-ipc#{[length, type].pack("LL")}#{payload}")
response = socket.read.unpack("L")
______________________________________________________________________
`bytes' gets the number of bytes written, as expected, and i3 does
indeed restart, so the message was successful. But `response' seems to
be nil. If I just ask for socket.read, I just get the empty string.
Can anyone help? thanks!
--
Kareem