I've written a simple script with user input to assign latency values to a pair of interfaces (on an RPi / Raspbian device) to emulate latency.
#!/bin/bash
# be sure to update the interface names on lines 6, 7, 14, 15, and 17 to match host interface names
echo "Removing existing induced latency values"
sudo tc qdisc del dev enp5s0 root netem
sudo tc qdisc del dev enp0s31f6 root netem
echo "..."
echo "Existing induced latency values removed"
echo -n "Enter new per-interface induced latency value in ms (example: '35' for 35ms per interface): "
read latencyms
sudo tc qdisc add dev enp5s0 root netem delay ${latencyms}ms
sudo tc qdisc add dev enp0s31f6 root netem delay ${latencyms}ms
echo "Changed induced latency value on enp5s0 and enp0s31f6 to ${latencyms}ms"
I'd like to make it a bit more user-friendly with a GUI that does essentially the same thing as the command line, and I'm hoping to use something simple like Zenity.
I've entered the basics into a Zenity script, but I'm not sure how to have that user input from the Zenity GUI become the variable $latencyms in the bash script:
#!/bin/bash
latencyms=$(zenity --entry --title="Please enter the new latency value per-interface")
if [ -n "$latencyms ]
then
zenity --info --text="Latency has been changed to $latencyms per-interface" --no-wrap
fi
Basically what I want to happen is the user input opens the bash script, runs the processes, and feeds the user input to the variable $latencyms. Is this as simple as I'm hoping it will be?