penguins-eggs 9.3.23 → 9.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,146 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- #####################################
4
- #####################################
5
- #
6
- # easybashgui "module"
7
- #
8
- # This file is intended to be packaged with scripts that use easybashgui.
9
- #
10
- # This file will try to source easybashgui_X.X.X.lib, or provide
11
- # fallback functions, thus avoiding a hard dependency on easybashgui ".lib" file.
12
- #
13
- #########################
14
- #
15
- # Copyright (C) 2020 Vittorio Cagnetta
16
- #
17
- # Author: Vittorio Cagnetta <vaisarger@gmail.com>
18
- # Author: Christian ? <https://launchpad.net/~cgat-1>
19
- #
20
- # This program is free software; you can redistribute it and/or modify
21
- # it under the terms of the GNU General Public License as published by
22
- # the Free Software Foundation; version 3 of the License.
23
- #
24
- # This program is distributed in the hope that it will be useful,
25
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
26
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
- # GNU General Public License for more details.
28
- #
29
- # You should have received a copy of the GNU General Public License along with this program,
30
- # called, in this distribution, "EasyBashGUI-license"; if not, write to the
31
- # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
32
- #
33
- #########################
34
- #
35
- # There are two easy methods to use easybashgui in your projects.
36
- #
37
- # The basic method introduces a hard dependency on easybashgui. This means
38
- # easybashgui must be installed on the machine your script is running on,
39
- # or your script will fail with an error. This method only requires to
40
- # call "source easybashgui" (once) in your script to be able to use
41
- # easybashgui functions if easybashgui is installed, but will make
42
- # your script fail without it.
43
- #
44
- # The easybashincl method however allows your script to run
45
- # without easybashgui installed, or even available:
46
- #
47
- # 1) Ship a copy of just the "easybashgui" file from the easybashgui
48
- # package with your script's package.
49
- # (in same directory as the calling script, or in an includes/ subdirectory)
50
- # 2) Copy the "easybashincl code snippet" from the "easybashgui" file
51
- # into your script.
52
- # 3) Call "eb_incl easybashgui" from your script.
53
- #
54
- # If you also include the easybashgui.lib file in your package, and
55
- # use the easybashincl method, your script will also work with any supported dialog
56
- # frontend without requiring a separate easybashgui download and installation
57
- # on the target system.
58
-
59
-
60
- ### INCLUDABLE EASYBASH MODULES ###
61
- # The easybashincl code snippet below allows easy inclusion of
62
- # bash scripts from other bash scripts.
63
- #
64
- # Unlike the bash builtin "source" (or "."), it does not require the
65
- # file to be installed in your $PATH.
66
- #
67
- # If the requested module (bash script file) is not in the $PATH,
68
- # the "eb_incl" function will look for it in these places:
69
- #
70
- # * same directory as the calling script
71
- # * includes/ subdirectory
72
- # * ${SHELL_LIBRARY_PATH}
73
- #
74
- # Improvement thanks to Stefano Borini's answer at
75
- # http://stackoverflow.com/questions/78497/design-patterns-or-best-practices-for-shell-scripts
76
- #
77
- #
78
- ###################################################################
79
- MODULE_VERSION="12.0.4"
80
- MODULE_NAME="easybashgui-debug"
81
- ###################################################################
82
- #
83
- clean_temp()
84
- {
85
- local FUNCT_NAME="clean_temp"
86
- local IFS=$' \t\n'
87
- #
88
- if [ -f "${dir_tmp}/${file_tmp}" ] 2> /dev/null
89
- then
90
- rm -f "${dir_tmp}/${file_tmp}" 2> /dev/null
91
- fi
92
- #
93
- if [ -f "${dir_tmp}/${file_ignore}" ] 2> /dev/null
94
- then
95
- rm -f "${dir_tmp}/${file_ignore}" 2> /dev/null
96
- fi
97
- #
98
- }
99
- #
100
- ###################################################################
101
- # Every easybash module should prevent repeated inclusion by
102
- # starting with an if-clause similar to the following:
103
- # ( With its proper module-name in the
104
- # "eb_incl_<module-name>__imported" variable. )
105
- ebg_debug_check="YES"
106
- if [ "${ebg_debug_check}" = "YES" ]
107
- then
108
- #
109
- # avoid "easybashgui-debug" repeated inclusion
110
- if [ "${eb_incl_easybashgui_debug__imported+defined}" = "defined" ]
111
- then
112
- #
113
- [ "${supermode:-unset}" = "unset" ] && declare supermode=""
114
- #
115
- if [ ${#supermode} -eq 0 ]
116
- then
117
- # Prevent repeated inclusion *only if* ${supermode} is not set ...
118
- echo "${MODULE_NAME}: ERR: easybashgui-debug not sourced (already sourced)! -supermode not set- ."
119
- return 0
120
- fi
121
- #
122
- if [ "${supermode}" = "${mode}" ]
123
- then
124
- # Prevent repeated inclusion *only if* ${supermode} = ${mode} ...
125
- echo "${MODULE_NAME}: ERR: easybashgui-debug not sourced (already sourced) -supermode is not different from mode- ."
126
- return 0
127
- fi
128
- #
129
- fi
130
- #
131
- echo -e "...easybashgui-debug sourcing..."
132
- #
133
- #eb_incl_easybashgui_debug__imported=1
134
- eb_incl_easybashgui_debug__imported=please_prevent_next_time
135
- #
136
- export easybashgui_debug_mode=YES
137
- #
138
- fi
139
- #
140
- ###################################################################
141
-
142
- #
143
- # Now let's source actual functions...
144
- # =>
145
- target="easybashgui-debug"
146
- source easybashgui
@@ -1,163 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- #########################
4
- #
5
- # Copyright (C) 2020 Vittorio Cagnetta
6
- #
7
- # Author: Vittorio Cagnetta <vaisarger@gmail.com>
8
- #
9
- # This program is free software; you can redistribute it and/or modify
10
- # it under the terms of the GNU General Public License as published by
11
- # the Free Software Foundation; version 3 of the License.
12
- #
13
- # This program is distributed in the hope that it will be useful,
14
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- # GNU General Public License for more details.
17
- #
18
- # You should have received a copy of the GNU General Public License along with this program,
19
- # called, in this distribution, "EasyBashGUI-license"; if not, write to the
20
- # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
21
- #
22
- #########################
23
- #
24
- ############################
25
- #
26
- #
27
- #
28
- usage()
29
- {
30
- #
31
- echo -e "Usage:>$(basename "${0}" ) [-m [mode]] [box type] <box options>"
32
- echo -e "\t1)Where [modes] are:"
33
- echo -e "\t a \t\t=>\t automatic (normal way)"
34
- echo -e "\t g \t\t=>\t to force gtkdialog"
35
- echo -e "\t k \t\t=>\t to force kdialog"
36
- echo -e "\t z \t\t=>\t to force zenity"
37
- echo -e "\t x \t\t=>\t to force Xdialog"
38
- echo -e "\t d \t\t=>\t to force (c)dialog"
39
- echo -e "\t n \t\t=>\t to force no widget ( => shell boxes)"
40
- echo -e "\n"
41
- echo -e "\tAnd [box types] -> [box options] are:"
42
- echo -e "\t --question -> \"[text]\" \t\t=>\t ( 1 argument, box output to exit code and STDERR )"
43
- echo -e "\t --message -> \"[text]\" \t\t\t=>\t ( 1 argument )"
44
- echo -e "\t --alert_message -> \"[text]\" \t\t=>\t ( 1 argument )"
45
- echo -e "\t --ok_message -> \"[text]\" \t\t=>\t ( 1 argument )"
46
- echo -e "\t --text \t\t\t\t=>\t ( STDIN, NO argument, box output to \"\${dir_tmp}/\${file_tmp}\" and STDERR )"
47
- echo -e "\t --wait_seconds -> \"[integer]\" \t\t=>\t ( 1 argument )"
48
- echo -e "\t --wait_for -> \"[text]\" \t\t=>\t ( 1 argument, PID to kill to \"wait_for__PID\" variable and STDERR )"
49
- echo -e "\t --terminate_wait_for \t\t\t=>\t ( 1 argument only in $(basename "${0}" ), otherwise, NO argument )"
50
- echo -e "\t --fselect -> \"<init. dir.>\" \t\t=>\t ( 1 <optional> argument, box output to \"\${dir_tmp}/\${file_tmp}\" and STDERR )"
51
- echo -e "\t --dselect -> \"<init. dir.>\" \t\t=>\t ( 1 <optional> argument, box output to \"\${dir_tmp}/\${file_tmp}\" and STDERR )"
52
- echo -e "\t --input -> 1 \"[init 1]\" \t\t=>\t ( 2 arguments, box output to \"\${dir_tmp}/\${file_tmp}\" and STDERR )"
53
- echo -e "\t --input -> 2 \"[label 1]\" \"[init 1]\" \"[label 2]\" \"[init 2]\" \t\t\t=> ( 5 arguments, box output to \"\${dir_tmp}/\${file_tmp}\" and STDERR )"
54
- echo -e "\t --input -> 3 \"[label 1]\" \"[init 1]\" \"[label 2]\" \"[init 2]\" \"[label 3]\" \"[init 3]\" => ( 7 arguments, box output to \"\${dir_tmp}/\${file_tmp}\" and STDERR )"
55
- echo -e "\t --menu -> \"[item 1]\" ... \"[item n]\" \t=>\t ( [n] arguments, box output to \"\${dir_tmp}/\${file_tmp}\" and STDERR )"
56
- echo -e "\t --list -> <+|->\"[item 1]\" ... <+|->\"[item n]\" \t=>\t ( [n] arguments, optionally prefixed with \"+\"(plus) or \"-\"(minus), box output to \"\${dir_tmp}/\${file_tmp}\" and STDERR )"
57
- echo -e "\t --progress -> \"[text]\" \t\t\t=>\t ( STDIN -percent-, 1 argument )"
58
- echo -e "\t --progress -> \"[text]\" \"[elements number]\" \t=>\t ( STDIN -\"PROGRESS\"-, 2 arguments )"
59
- echo -e "\t --adjust -> \"[text]\" \"[min value]\" \"[init value]\" \"[max value]\" \t=>\t ( 4 arguments, box output to \"\${dir_tmp}/\${file_tmp}\" and STDERR )"
60
- echo -e "\n\n"
61
- echo -e "\t2)Examples:"
62
- echo -e "\t>$(basename "${0}" ) -m a --question \"Do you like Contry music ?\" 2> a.txt ; a=\"\$(0< a.txt )\" ; rm -f a.txt ; [ \${a} -eq 0 ] && $(basename "${0}" ) -m a --ok_message \"You do like it :)\" || $(basename "${0}" ) -m a --alert_message \"You don't like it :(\" "
63
- echo -e "\t>echo -e \"What's your name?\\\n\\\nMy name's:\\\nVittorio\" | $(basename "${0}" ) -m z --text"
64
- echo -e "\t>$(basename "${0}" ) -m a --wait_seconds 3"
65
- echo -e "\t>$(basename "${0}" ) -m k --wait_for \"I'm sleeping 4 seconds... good night...\" 2> pid.txt ; pid=\"\$(0< pid.txt )\" ; rm -f pid.txt ; sleep 4 ; $(basename "${0}" ) -m k --terminate_wait_for \"\${pid}\" "
66
- echo -e "\t>$(basename "${0}" ) -m x --fselect"
67
- echo -e "\t>$(basename "${0}" ) -m a --input 1 \"(write here IP address)\""
68
- echo -e "\t>$(basename "${0}" ) -m k --input 3 \"Username\" \"root\" \"IP address\" \"192.168.0.1\" \"Destination directory\" \"/tmp\""
69
- echo -e "\t>$(basename "${0}" ) -m d --menu \"Country\" \"Blues\" \"Rock\""
70
- echo -e "\t>for i in 10 20 30 40 50 60 70 80 90 100 ; do echo \"\${i}\" && sleep 2 ; done | $(basename "${0}" ) -m d --progress \"This is a test progress...\""
71
- echo -e "\t>for i in 10 20 30 40 50 60 70 80 90 100 ; do echo \"PROGRESS\" && sleep 2 ; done | $(basename "${0}" ) -m z --progress \"This is a test progress...\" \"10\""
72
- echo -e "\n\n"
73
- echo -e "\t3)Would you like *really* easy dialogs?"
74
- echo -e "\tTry this:"
75
- echo -e "\t>cp easybashgui /usr/local/bin/"
76
- echo -e "\t>touch \"easy_updatedb.sh\""
77
- echo -e "\t>chmod 755 \"easy_updatedb.sh\""
78
- echo -e "\tThen, edit the file like so:"
79
- echo -e "\t"
80
- echo -e "\t#!/usr/bin/env bash"
81
- echo -e "\tsource /usr/local/bin/easybashgui"
82
- echo -e "\tmessage \"Click OK \\\n to update locate db...\""
83
- echo -e "\twait_for \"Updating...\" ; updatedb ; terminate_wait_for"
84
- echo -e "\tok_message \"Update finished ;-)\""
85
- echo -e "\t"
86
- echo -e "\tTry to launch the *same* script in console, in GNOME, in KDE, and finally in text console... ;-)"
87
- echo
88
- #
89
- exit 1
90
- #
91
- } 1>&2
92
- #
93
- #
94
- #
95
- ############################
96
- #
97
- #
98
- #
99
- [ ${#} -eq 0 ] && usage
100
- while getopts ":hvm:" option
101
- do
102
- case ${option} in
103
- "h" )
104
- source easybashgui ; \
105
- echo -e "\nThe library \"${LIB_NAME}\" allows bash scripters to simply provide their scripts a graphical user interface in an easy way: no matter wich dialog type is more appropriate ( if you are in GNOME, in KDE, etc.).\nThe script ( \"$(basename "${0}" )\" ) is used only to show ${LIB_NAME} library capability...\n\n" 1>&2 && usage \
106
- ;;
107
- "v" )
108
- source easybashgui ; \
109
- echo -e "\n${LIB_NAME}: vers. ${LIB_VERSION}\n" 1>&2 && exit \
110
- ;;
111
- "m" )
112
- if [ "${OPTARG}" = "a" ]; then export supermode="auto" && break ; \
113
- elif [ "${OPTARG}" = "g" ]; then export supermode="gtkdialog" && break ; \
114
- elif [ "${OPTARG}" = "k" ]; then export supermode="kdialog" && break ; \
115
- elif [ "${OPTARG}" = "z" ]; then export supermode="zenity" && break ; \
116
- elif [ "${OPTARG}" = "x" ]; then export supermode="Xdialog" && break ; \
117
- elif [ "${OPTARG}" = "d" ]; then export supermode="dialog" && break ; \
118
- elif [ "${OPTARG}" = "n" ]; then export supermode="none" && break ; \
119
- else usage ; \
120
- fi \
121
- ;;
122
- * )
123
- usage \
124
- ;;
125
- esac
126
- #
127
- done
128
- shift $(($OPTIND - 1))
129
- #
130
- #
131
- #
132
- funct="$(echo "${1}" | tr -d '-' )"
133
- case ${funct} in
134
- "question"|\
135
- "message"|"alert_message"|"ok_message"|\
136
- "text"|\
137
- "wait_seconds"|"wait_for"|"terminate_wait_for"|\
138
- "fselect"|"dselect"|\
139
- "input"|\
140
- "menu"|"list"|\
141
- "progress"|\
142
- "adjust" )
143
- :;;
144
-
145
- * )
146
- usage ;;
147
- esac && shift
148
- #
149
- #
150
- #
151
- ############################
152
- # ...main
153
- LIB_CHECK="$(type "easybashgui" 2> /dev/null )" ; [ ${#LIB_CHECK} -eq 0 ] && echo -e "\n\n\n\nYou need to copy \"easybashgui\" in your path ( e.g.: \"cp easybashgui_X.X.X /usr/local/bin/\" )...\n:(\n\n\n\n" 1>&2 && usage
154
- #
155
- source easybashgui
156
- num_param=${#}
157
- eval ${funct} $(for (( index=1 ; index <= ${num_param} ; index++ ))
158
- do
159
- echo -n "\"${1}\" "
160
- shift
161
- done )
162
- clean_temp
163
- # bye! ;-)