From 882009a092cc131085a63a5e58187551f9737f5c Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Tue, 22 Nov 2022 21:11:29 -0500 Subject: [PATCH] Argument processing minimally in place. --- i38.sh | 29 ++++++++++++++++++++++++++++- scripts/sound.py | 2 ++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/i38.sh b/i38.sh index e79604f..f77a608 100755 --- a/i38.sh +++ b/i38.sh @@ -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/:/ }: ${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 diff --git a/scripts/sound.py b/scripts/sound.py index bc91cab..a39f17a 100644 --- a/scripts/sound.py +++ b/scripts/sound.py @@ -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()