2024-03-26 20:03:07 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
2025-06-13 16:09:14 -07:00
|
|
|
export ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
button=$1
|
|
|
|
|
|
|
|
debug(){
|
|
|
|
debug=$ROOT/debug
|
|
|
|
echo $1
|
|
|
|
echo $1>>$debug
|
|
|
|
}
|
|
|
|
# debugging
|
|
|
|
#tail -n 30 "$debug" > tmp && cp tmp "$debug"
|
|
|
|
active=$(bash $ROOT/get_active_window.sh)
|
|
|
|
debug ""
|
|
|
|
debug "$(date +%s)"
|
|
|
|
debug "active: $active"
|
|
|
|
debug "button: $button"
|
|
|
|
|
|
|
|
# source the app folder
|
|
|
|
#APPS="$(pwd)/apps"
|
|
|
|
#if [ -d "$APPS" ]; then
|
|
|
|
# for file in "$APPS"/*; do
|
|
|
|
# if [ -f "$file" ]; then
|
|
|
|
# . "$file"
|
|
|
|
# fi
|
|
|
|
# done
|
|
|
|
#fi
|
|
|
|
. $ROOT/find_or_open.sh
|
|
|
|
. $ROOT/apps/default_commands.sh
|
|
|
|
if [ -f "$ROOT/apps/${active%%_*}.sh" ]; then
|
|
|
|
. "$ROOT/apps/${active%%_*}.sh"
|
|
|
|
debug "$active sourced"
|
|
|
|
else
|
|
|
|
debug "no $active source found"
|
2024-03-26 20:03:07 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
### find and run $1
|
2025-06-13 16:09:14 -07:00
|
|
|
if [[ $(type -t $active) == function ]]; then
|
|
|
|
debug "found $active methods"
|
|
|
|
$active
|
|
|
|
else
|
|
|
|
debug "no $button method found in $active"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $(type -t $button) == function ]]; then
|
|
|
|
debug "found $button"
|
2024-03-26 20:03:07 -07:00
|
|
|
$1
|
|
|
|
else
|
2025-06-13 16:09:14 -07:00
|
|
|
debug "program specific method not found calling all $button"
|
2024-03-26 20:03:07 -07:00
|
|
|
all $1
|
|
|
|
fi
|
|
|
|
|