#!/bin/bash
# our counter
count=0
# function that increments and updates field 1
increment() {
count=$((count + 1))
echo "1:$count"
}
# function that resets counter and updates field 1
reset() {
count=0
echo "1:$count"
}
# export functions and variable so yad can call them
export -f increment
export -f reset
export count
# run yad form with an increment button, reset button, and a text field
yad --form --title="Counter" \
--field="Value:":RO "$count" \
--field="Increment":fbtn 'bash -c increment' \
--field="Reset":fbtn 'bash -c reset' \
--button="Close:0"