Argument processing minimally in place.

This commit is contained in:
Storm Dragon 2022-11-22 21:11:29 -05:00
parent 12e6b4b664
commit 882009a092
2 changed files with 30 additions and 1 deletions

29
i38.sh
View File

@ -9,7 +9,7 @@ i3Path="${XDG_CONFIG_HOME:-$HOME/.config}/i3"
export DIALOGOPTS='--no-lines --visit-items'
# Check to make sure minimum requirements are installed.
for i in dialog nwg-launchers yad ; do
for i in dialog sgtk-menu yad ; do
if ! command -v "$i" &> /dev/null ; then
missing+=("$i")
fi
@ -54,6 +54,18 @@ yesno() {
dialog --clear --title "Strychnine" --yesno "$*" -1 -1 --stdout && return 0
}
help() {
echo "${0##*/}"
echo "Released under the terms of the WTFPL License: http://www.wtfpl.net"
echo -e "This is a Stormux project: https://stormux.org\n"
echo -e "Usage:\n"
echo "With no arguments, create the i3 configuration."
for i in "${!command[@]}" ; do
echo "-${i/:/ <parameter>}: ${command[${i}]}"
done | sort
exit 0
}
write_xinitrc()
{
if [[ -f "$HOME/.xinitrc" ]]; then
@ -113,6 +125,21 @@ rc="${rc}"$'\n'"$@"
fi
}
# Array of command line arguments
declare -A command=(
[h]="This help screen."
)
# Convert the keys of the associative array to a format usable by getopts
args="${!command[*]}"
args="${args//[[:space:]]/}"
while getopts "${args}" i ; do
case "$i" in
h) help;;
esac
done
# Create .xinitrc file if requested
if [[ "$1" = "-x" || "$1" = "--xinitrc" ]]; then
write_xinitrc

View File

@ -15,5 +15,7 @@ i3 = i3ipc.Connection()
i3.on('window::new', on_new_window)
i3.on('mode', on_mode)
# get current mode:
# var = i3ipc.ModeEvent(data)
i3.main()