Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 9 additions & 25 deletions datepicker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
# RETURN:
# 0 if success, non-zero otherwise.
#######################################

# declare month array
declare -A month=(
[Jan]=1 [Feb]=2 [Mar]=3 [Apr]=4
[May]=5 [Jun]=6 [Jul]=7 [Aug]=8
[Sep]=9 [Oct]=10 [Nov]=11 [Dec]=12
)

function datepicker() {
if [ -z ${GUI_ICON+x} ]; then
GUI_ICON=$XDG_ICO_CALENDAR
Expand Down Expand Up @@ -62,31 +70,7 @@ function datepicker() {
INPUT_DATE=$(kdialog --title="$GUI_TITLE" --icon "$GUI_ICON" --calendar "Select Date")
exit_status=$?
TEXT_MONTH=$(echo "$INPUT_DATE" | cut -d' ' -f2)
if [ "$TEXT_MONTH" == "Jan" ]; then
MONTH=1
elif [ "$TEXT_MONTH" == "Feb" ]; then
MONTH=2
elif [ "$TEXT_MONTH" == "Mar" ]; then
MONTH=3
elif [ "$TEXT_MONTH" == "Apr" ]; then
MONTH=4
elif [ "$TEXT_MONTH" == "May" ]; then
MONTH=5
elif [ "$TEXT_MONTH" == "Jun" ]; then
MONTH=6
elif [ "$TEXT_MONTH" == "Jul" ]; then
MONTH=7
elif [ "$TEXT_MONTH" == "Aug" ]; then
MONTH=8
elif [ "$TEXT_MONTH" == "Sep" ]; then
MONTH=9
elif [ "$TEXT_MONTH" == "Oct" ]; then
MONTH=10
elif [ "$TEXT_MONTH" == "Nov" ]; then
MONTH=11
else #elif [ "$TEXT_MONTH" == "Dec" ]; then
MONTH=12
fi
MONTH=${month["$TEXT_MONTH"]:-0}

DAY=$(echo "$INPUT_DATE" | cut -d' ' -f3)
YEAR=$(echo "$INPUT_DATE" | cut -d' ' -f4)
Expand Down
7 changes: 6 additions & 1 deletion helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
# Variables set in init.sh and used here
# shellcheck disable=SC2154

function listfunc() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is just an alias without any "if platform do a, else do b" logic and has no documentation comments. Doesn't belong in this library.

compgen -A function
}

#######################################
# Attempts to run a privileged command (sudo or equivalent)
# GLOBALS:
Expand All @@ -19,6 +23,7 @@
# RETURN:
# 0 if success, non-zero otherwise.
#######################################

function superuser() {
if [ "$NO_SUDO" == true ]; then
(>&2 echo "${red}No sudo available!${normal}")
Expand All @@ -41,7 +46,7 @@ function superuser() {
#######################################
# Set the GUI_TITLE based on the ACTIVITY and APP_NAME
# GLOBALS:
# GUI_TITLE
# GUI_TITLE
# ACTIVITY
# APP_NAME
# ARGUMENTS:
Expand Down
38 changes: 16 additions & 22 deletions script-dialog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,24 @@
# https://github.com/lunarcloud/script-dialog
# LGPL-2.1 license

# Get the directory where this script is located
# get the directories

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment change doesn't make sense. Only one directory is being gathered by the following line(s) still

SCRIPT_DIALOG_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
CURRENT_FILE="$(realpath -- "${BASH_SOURCE[0]}")"

# Source all modular components
# shellcheck source=./init.sh
source "${SCRIPT_DIALOG_DIR}/init.sh"
# sources everything in folder, excludes current file
for src in ./*.sh

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer a finite list rather than an unbounded "all in folder" for obvious security reasons

do
[[ "$(realpath -- "$src")" == "$CURRENT_FILE" ]] && continue
source "$src" || exit 1
#echo "$src"
done

# shellcheck source=./helpers.sh
source "${SCRIPT_DIALOG_DIR}/helpers.sh"
# execute told function
if declare -f "$1" >/dev/null; then
"$1"
else
echo "Function not found"
fi

# shellcheck source=./messages.sh
source "${SCRIPT_DIALOG_DIR}/messages.sh"
# the rest goes there

# shellcheck source=./inputs.sh
source "${SCRIPT_DIALOG_DIR}/inputs.sh"

# shellcheck source=./lists.sh
source "${SCRIPT_DIALOG_DIR}/lists.sh"

# shellcheck source=./progressbar.sh
source "${SCRIPT_DIALOG_DIR}/progressbar.sh"

# shellcheck source=./pickers.sh
source "${SCRIPT_DIALOG_DIR}/pickers.sh"

# shellcheck source=./datepicker.sh
source "${SCRIPT_DIALOG_DIR}/datepicker.sh"