On one hand it is definitely a crazy idea on the other hand I wonder if wayland's API is as simple as this and also could be done in 100+ line of bash.
I mean you're not using unix sockets, but you can avoid the whole fifo <-> netcat <-> socket mess, by just doing:
exec 3>/dev/tcp/127.0.0.1/6001 #(first display)
and then just using
echo -n "something something" >&3
And if you want to disconnect:
3<&-
Tools removed from the list: nc, mkfifo
And I'd also do the "append_file" trick a little bit different:
declare -a SEND_BUFFER=()
SEND_BUFFER+=($'\x1') # create window command ID
SEND_BUFFER+=($'\x0') # depth
and so son. Bash has this special notation $'' that creates the escaped values when you use it (Check the "QUOTING" section in the man page). So
echo -e "\n"
is the same as
echo $'\n'
The difference is that you can add $'\n' to an array and then later do something like this:
IFS=""
echo "${SEND_BUFFER[*]}"
unset IFS
This will output SEND_BUFFER as a "string" w/o any additional spaces or other separators.
So, this:
declare -a foo=(a b c d e f)
printed like this:
IFS=""; echo "${foo[*]}"; unset IFS;
turns into this:
abcdef
You could use associative arrays and then assign names to the values, but the order of the entries is not stored and so you'd require a function that would build the string needed.
5 comments
[ 2.6 ms ] story [ 23.5 ms ] threadI mean you're not using unix sockets, but you can avoid the whole fifo <-> netcat <-> socket mess, by just doing:
and then just using And if you want to disconnect: Tools removed from the list: nc, mkfifoAnd I'd also do the "append_file" trick a little bit different:
and so son. Bash has this special notation $'' that creates the escaped values when you use it (Check the "QUOTING" section in the man page). So is the same as The difference is that you can add $'\n' to an array and then later do something like this: This will output SEND_BUFFER as a "string" w/o any additional spaces or other separators.So, this:
printed like this: turns into this: You could use associative arrays and then assign names to the values, but the order of the entries is not stored and so you'd require a function that would build the string needed.$0.02
You could still use the array but instead of using the special quotes, just use single quotes like '\x0' and later echo -e to get your results.