I want to get the values of the form in zenity (Ipaddress value written by user) in order to do some video streaming with ffmpeg, I tried several examples such as lists, forms, .. etc
zenity --forms --title="Add Friend" --text="Enter Multicast address" --separator="," --add-entry="IP address" --add-entry="PORT"
OR
if zenity --list --title="Record Video Stream" --text "Enter the Multicast IP address and port of each of the video stream" --column "Video IP" --print-column=2 --multiple --column "PORT" --editable ip="0.0.0.0" port="2002"
The output from zenity
is the text that was inputted, separated by the --separator
character. The exit code is if it was accepted or not (i.e. OK
, Cancel
selected).
So for example (in bash):
OUTPUT=$(zenity --forms --title="Add Friend" --text="Enter Multicast address" --separator="," --add-entry="IP address" --add-entry="PORT")
accepted=$?
if ((accepted != 0)); then
echo "something went wrong"
exit 1
fi
ip=$(awk -F, '{print $1}' <<<$OUTPUT)
port=$(awk -F, '{print $2}' <<<$OUTPUT)
That gets you the ip address from zenity into the ip variable and the port from the zenity form into the port variable.
The second example is a little more complex, it's using the 'editable' template, which means that you don't get any output if the data is unchanged, but it follows a similar pattern to the previous example. Now, because you said --print-column=
, it only displays that column in the output. Unfortunately, --list
is for the selection of one or more rows from a list of items. Editing multiple rows will work, but you have to select every one of the rows to get the output from that row, even after making a change to the data. In this case, because you didn't specify the --separator
option, the default separator is used |
.
In the second case, using editable and list inputs isn't really what a list is designed to do from a user input perspective.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With