Skip to content

Commit

Permalink
Some minor bugfixes in "gum" mode
Browse files Browse the repository at this point in the history
  • Loading branch information
vaisarger committed Mar 26, 2024
1 parent a716a78 commit 9c89e5c
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 32 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ Simplified way to code bash made GUI frontend dialogs! Check the youtube video:

## Introduction to EBG

... There is [bashlib](https://github.com/cyberark/bash-lib) that is for the code
itselft, well so for the GUIs there is **EasyBashGUI** then!

**E**asy **B**ash **G**ui shortened as EBG, is a Posix compliant Bash functions
library that aims to give unified GUI functions using frontends for dialogs boxeds
(from the user's point of view are frontends but from the EGB side are backends)
Expand Down
94 changes: 77 additions & 17 deletions lib/easybashgui.lib
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#####################################
#####################################
#
LIB_VERSION="13.0.0"
LIB_VERSION="13.0.1"
LIB_NAME="easybashgui.lib"
LIB_URL="https://github.com/BashGui/easybashgui"
LIB_AUTHOR="Vittorio Cagnetta"
Expand Down Expand Up @@ -1436,11 +1436,37 @@ elif [ "${mode}" = "gum" ]
#
testo="${@}"
#
#which_terminal="$(ps -o comm= -p $(ps -o ppid= -p $(ps -o ppid= -p $$ )))"
which_terminal="$(ps -o comm= -p $(ps -o ppid= -p $$ ))"
#
#########################################
#
frame "${widget_color}" "please confirm"
gum confirm --affirmative="Ok" --negative="Cancel" "$(echo -e "${testo}" )"
exit_code="${?}"
#
if [ "${which_terminal}" = "mate-terminal" -o "${which_terminal}" = "qterminal" -o "${which_terminal}" = "lxterminal" ]
then
#
gum confirm --affirmative="Ok" --negative="Cancel" "$(echo -e "${testo}" )"
exit_code="${?}"
echo -e "\n\t${testo}"
#
else
#
echo -e "\n\t${testo}"
gum choose --item.foreground 250 "Ok" "Cancel" 1> "${dir_tmp}/${file_tmp}"
answer=$(0< "${dir_tmp}/${file_tmp}" )
exit_code=$(if [ "${answer}" = "Ok" ]
then
echo 0
elif [ "${answer}" = "Cancel" ]
then
echo 1
else
echo 1
fi )
#
fi
#
echo
#########################################
#
Expand Down Expand Up @@ -1551,6 +1577,35 @@ elif [ "${notify_send}" = "NO" ]
#
notify_message_alt()
{
local FUNCT_NAME="notify_message_alt"
local IFS=$' \t\n'
#
#########################################
# Begin check for user custom geometry (and let's remove icon option)...
while [ "${1}" = "--width" -o "${1}" = "-w" -o "${1}" = "--height" -o "${1}" = "-h" -o "${1}" = "--icon" -o "${1}" = "-i" ]
do
if [ "${1}" = "--icon" -o "${1}" = "-i" ]
then
icon_parameter="${2}" ; [ -e "${icon_parameter}" ] && shift 2 || shift 1
continue
fi
w_or_h="$(if [ "${1}" = "--width" -o "${1}" = "-w" ]
then
echo "width"
elif [ "${1}" = "--height" -o "${1}" = "-h" ]
then
echo "height"
fi )"
parameter=$(echo -n "${2}" | tr -dc '[[:digit:]]' ) ; [ ${#parameter} -eq 0 ] && break
reset_geometry="YES" && eval "local ${w_or_h}=${parameter}" && shift 2
done
# End check for user custom geometry (and let's remove icon option)...
#########################################
#
: notify_send_seconds
notify_message_text="${@}"
#
#########################################
wait_for "\n\n${notify_message_text}\n\n\n\n(Please, install \"kdialog\" or \"notify-send\" for a nicer notification)\n\n."
sleep ${notify_send_seconds}
terminate_wait_for
Expand All @@ -1565,31 +1620,36 @@ elif [ "${notify_send}" = "NO" ]
local widget_color="yellow"
#
#########################################
# Begin check for user custom geometry...
while [ "${1}" = "--width" -o "${1}" = "-w" -o "${1}" = "--height" -o "${1}" = "-h" ]
# Begin check for user custom geometry (and let's remove icon option)...
while [ "${1}" = "--width" -o "${1}" = "-w" -o "${1}" = "--height" -o "${1}" = "-h" -o "${1}" = "--icon" -o "${1}" = "-i" ]
do
if [ "${1}" = "--icon" -o "${1}" = "-i" ]
then
icon_parameter="${2}" ; [ -e "${icon_parameter}" ] && shift 2 || shift 1
continue
fi
w_or_h="$(if [ "${1}" = "--width" -o "${1}" = "-w" ]
then
echo "width"
elif [ "${1}" = "--height" -o "${1}" = "-h" ]
then
echo "height"
fi )"
then
echo "width"
elif [ "${1}" = "--height" -o "${1}" = "-h" ]
then
echo "height"
fi )"
parameter=$(echo -n "${2}" | tr -dc '[[:digit:]]' ) ; [ ${#parameter} -eq 0 ] && break
reset_geometry="YES" && eval "local ${w_or_h}=${parameter}" && shift 2
done
# End check for user custom geometry...
# End check for user custom geometry (and let's remove icon option)...
#########################################
#
num_secondi=4
testo="${@}"
: notify_send_seconds
notify_message_text="${@}"
#
#########################################
frame "${widget_color}" "notification"
#bare_msg "${widget_color}" "${testo}"
#
echo -e "############################\n############################\n\n"
gum spin -s pulse --title "$(echo -e "${testo}" )" -- sleep ${num_secondi}
echo -e "${testo}"
gum spin -s pulse --title "$(echo -e "${notify_message_text}" )" -- sleep ${notify_send_seconds}
echo -e "${notify_message_text}"
echo -e "\n\n############################\n############################"
#
echo
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#EBGlib=$(wildcard easybashgui_[0-9].[0-9].[0-9])
VERSION=13.0.0
VERSION=13.0.1

#cartelle di destinazione
DESTDIR ?= ""
Expand Down
25 changes: 15 additions & 10 deletions src/easybashgui
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
#
#
###################################################################
MODULE_VERSION="13.0.0"
MODULE_VERSION="13.0.1"
MODULE_NAME="easybashgui"
libexec_dir="/usr/lib/easybashgui"
###################################################################
Expand Down Expand Up @@ -670,20 +670,25 @@ elif [ "${eb_gui_fallback}" = "true" ]
local IFS=$' \t\n'
#
#########################################
# Begin check for user custom geometry...
while [ "${1}" = "--width" -o "${1}" = "-w" -o "${1}" = "--height" -o "${1}" = "-h" ]
# Begin check for user custom geometry (and let's remove icon option)...
while [ "${1}" = "--width" -o "${1}" = "-w" -o "${1}" = "--height" -o "${1}" = "-h" -o "${1}" = "--icon" -o "${1}" = "-i" ]
do
if [ "${1}" = "--icon" -o "${1}" = "-i" ]
then
icon_parameter="${2}" ; [ -e "${icon_parameter}" ] && shift 2 || shift 1
continue
fi
w_or_h="$(if [ "${1}" = "--width" -o "${1}" = "-w" ]
then
echo "width"
elif [ "${1}" = "--height" -o "${1}" = "-h" ]
then
echo "height"
fi )"
then
echo "width"
elif [ "${1}" = "--height" -o "${1}" = "-h" ]
then
echo "height"
fi )"
parameter=$(echo -n "${2}" | tr -dc '[[:digit:]]' ) ; [ ${#parameter} -eq 0 ] && break
reset_geometry="YES" && eval "local ${w_or_h}=${parameter}" && shift 2
done
# End check for user custom geometry...
# End check for user custom geometry (and let's remove icon option)...
#########################################
#
num_secondi=4
Expand Down
2 changes: 1 addition & 1 deletion src/easybashgui-debug
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
#
#
###################################################################
MODULE_VERSION="13.0.0"
MODULE_VERSION="13.0.1"
MODULE_NAME="easybashgui-debug"
###################################################################
#
Expand Down

0 comments on commit 9c89e5c

Please sign in to comment.