Is it really necessary to do it like this?

7 views
Skip to first unread message

Stephan Schutter

unread,
Nov 5, 2025, 2:52:09 AMĀ (8 days ago)Ā Nov 5
to yad-c...@googlegroups.com
To make the text end up below the banner image I had to do this (see below). Is there a simpler, better way?Ā 



image.png

while true; do
local _info_rendered _info_line _info_trimmed _info_label
local -a yad_cmd

_info_rendered=$(printf '%b' "$_INFO_TXT")
# Build yad command so informational text is rendered as stacked labels
yad_cmd=(
--form
--image="/opt/rtd/modules/oem-bundle-manager.mod/image/banner.png"
--image-on-top
--title="${_title}"
--columns=1
)

while IFS= read -r _info_line; do
_info_trimmed="${_info_line#"${_info_line%%[![:space:]]*}"}"
_info_trimmed="${_info_trimmed%"${_info_trimmed##*[![:space:]]}"}"
[[ -z "$_info_trimmed" ]] && continue
_info_label="${_info_trimmed//:/\\:}"
yad_cmd+=(--field="$_info_label":LBL)
done <<< "$_info_rendered"

yad_cmd+=(
--width=700
--height=360
--button="Add Bundles to this computer:0"
--button="Remove Bundles from this computer:2"
--button="Information abount this tool:3"
--button="Quit:1"
--buttons-layout=center
)

# Display the yad form and capture the selected button
selection=$(yad "${yad_cmd[@]}")
ret=$?

# Handle the user's selection
case $ret in
0) software::display_bundle_install_choices_gtk --zenity ;;
1) clear && echo "[Quit]" | tee -a "${_log_file}" ; break ;;
2) software::display_bundle_removal_choices_gtk --zenity;;
3) zenity::display_info "$_ABOUT" ;;
252) clear && echo "[ESC]" | tee -a "${_log_file}" && break ;;
*) clear && echo "[Unknown Request]" | tee -a "$${_log_file}" && break ;;
esac
unset _ret
done





Atishtum Rah

unread,
Nov 5, 2025, 12:50:41 PMĀ (8 days ago)Ā Nov 5
to Stephan Schutter, yad-c...@googlegroups.com
Hi Stephan,

I am a recent newbie, as far as Yad goes, but I had programmed on Mini/Mainframe systems for over 30 years (retired back in 2012). Only started using Yad instead of Zenity a couple of weeks ago.

From the experiments I have conducted with a utility script's initial screen this looks to probably be the best way to do this. Hope you don't mind but I am going to use your method, with one change, in my script.

The change is to replace the 2nd and 3rd line in the read loop with a call to the following function:
trim() {
Ā  # Trims the leading & trailing whitespace characters from a variable.
Ā  # Syntax: variable="$(trim "${variable}")"
Ā  local var="$1"
Ā  var="${var#"${var%%[![:space:]]*}"}" # leading
Ā  var="${var%"${var##*[![:space:]]}"}" # trailing
Ā  echo -n "$var"
Ā  }

while IFS= read -r _info_line; do
Ā  _info_trimmed="$(trim "${_info_line}")"
Ā  [[ -z "$_info_trimmed" ]] && continue
Ā  ...
Ā  done <<< "$_info_rendered"
I am still learning about Yad but if I find something simpler/better then I'll let you know.

-- Atishtum
--
You received this message because you are subscribed to the Google Groups "yad-common" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yad-common+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/yad-common/CAEHHLTBVsAx_7GWULp9h_vaNMjjDONxKeXc4NTmqQS2HnWVX4A%40mail.gmail.com.

Kevin M

unread,
Nov 5, 2025, 1:08:09 PMĀ (8 days ago)Ā Nov 5
to yad-c...@googlegroups.com
I retired in 2006 from an IBM mainframe environment, but Bash keeps my brain alive!

The part of the function to remove leading and trailing white space can be done more simply with awk, using the way print is used, (but it may be slower):

awk '{$1=$1};1'
Ā 
Hope this helps.

RegardsĀ 

KevinĀ 

Ananas

unread,
Nov 6, 2025, 3:12:06 AMĀ (7 days ago)Ā Nov 6
to yad-c...@googlegroups.com
hi

using 'echo' is a much easierĀ solution for cutting leading/trailing spaces

line_with_spaces="Ā  Ā  Ā foo bar bazĀ  Ā  "
trimmed_line=$(echo $line_with_spaces)

and pay attention - argument of echo must be UNQUOTED

ср, 5 лист. 2025 р. о 19:50 Atishtum Rah <atis...@gmail.com> пише:


--
wbr,

Victor "Ananas" Ananjevsky

Julio C. Neves

unread,
Nov 6, 2025, 6:39:27 AMĀ (7 days ago)Ā Nov 6
to yad-c...@googlegroups.com
I always tell my students: good shell scripting is very simple, but we often tend to complicate it. 😁

AbraƧos,
Julio

Ā» Quer ser promovido? Aprenda Shell e seja o melhor admin da sua empresa
Ā» Curso no formato presencial ou EAD com aulas ao vivo

Nossos treinamentos te certificarão e podem ser
em sua cidade. Nossa empresa é 100% regulamentada.
==================================================
UNIX is very simple, it just needs a
genius to understand its simplicity.
(Dennis Ritchie)



Reply all
Reply to author
Forward
0 new messages