feat: Initial commit

This commit is contained in:
2025-10-09 22:28:10 -04:00
commit 57facfc210
2 changed files with 145 additions and 0 deletions

32
config.json Normal file
View File

@@ -0,0 +1,32 @@
[
{
"name": "Komodo",
"description": "Manages services and docker stacks that run on the different servers.",
"url": "https://komo.housh.dev"
},
{
"name": "Home-Assistant",
"description": "Manages IOT devices.",
"url": "https://homeassistant.housh.dev"
},
{
"name": "Uptime-Kuma",
"description": "Uptime status of services.",
"url": "https://uptime.housh.dev"
},
{
"name": "Homarr",
"description": "Dashboard website.",
"url": "https://dash.housh.dev"
},
{
"name": "Pocket-ID",
"description": "Authentication services for passkey usage.",
"url": "https://id.housh.dev"
},
{
"name": "Docs",
"description": "Documentation site for HHE.",
"url": "https://docs.housh.dev"
}
]

113
homelab-launcher Executable file
View File

@@ -0,0 +1,113 @@
#!/usr/bin/env bash
set -e
set -o nounset
set -o pipefail
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
THIS_FILE=${BASH_SOURCE[0]}
LOG_LABEL="homelab-launcher"
THIS=${THIS:-$LOG_LABEL}
LOG_FILE=${LOG_FILE:-"$LOG_LABEL.log"}
HOMELAB_LAUNCH_CONFIG=${HOMELAB_LAUNCH_CONFIG:-""}
FZF_DEFAULT_OPTS=${FZF_DEFAULT_OPTS:-""}
window_class="com.ghostty.homelab-launcher"
window_padding_x="10"
# Logging utility function, use in place of echo.
log() {
logging log --source "$THIS_FILE" "$@"
}
footer() {
cat <<'EOF'
__ __ __ __
/ // /__ __ _ ___ / /__ _/ /
/ _ / _ \/ ' \/ -_) / _ `/ _ \
/_//_/\___/_/_/_/\__/_/\_,_/_.__/
EOF
}
prompt_for_selection() {
local rows=()
local desc=""
local sel=""
for name in $(jq -r '.[] | .name' $HOMELAB_LAUNCH_CONFIG); do
desc=$(jq -r ".[] | select(.name == \"$name\") | .description" $HOMELAB_LAUNCH_CONFIG)
rows+=("$desc:$name")
done
sel=$(
printf "%s\n" "${rows[@]}" |
fzf --footer="$(footer)" \
--delimiter=':' \
--with-nth=2 \
--preview-label='[ Description ]' \
--preview='echo -e "\n{1}"' \
--preview-window='down,20%'
)
echo "${sel#*:}"
}
get_url() {
read -r name
if [[ -z $name ]]; then
log "No selection." && exit 1
fi
echo $(jq -r ".[] | select(.name == \"$name\") | .url" $HOMELAB_LAUNCH_CONFIG)
}
picker() {
if [[ -z $HOMELAB_LAUNCH_CONFIG ]]; then
# log "Configuration not set, using: ~/.config/homelab-launcher/config.json"
HOMELAB_LAUNCH_CONFIG="$(pwd)/config.json"
fi
if [[ ! -f $HOMELAB_LAUNCH_CONFIG ]]; then
echo "Error, config file is not setup properly." && exit 1
fi
# Setup fzf color scheme.
[[ -z $FZF_DEFAULT_OPTS ]] &&
source "$SCRIPTS/catppuccin-colors"
while true; do
url=$(prompt_for_selection | get_url)
"$SCRIPTS/hypr/launch-webapp" "$url" >/dev/null 2>&1 &
sleep 0.1 # need to sleep or the application doesn't launch.
done
}
launch() {
ghostty --class="$window_class" --window-padding-x="$window_padding_x" \
--keybind="ctrl+c=quit" \
-e $THIS_FILE picker
}
################################################################################
# MAIN
################################################################################
# Setup logging file and label.
source "$SCRIPTS/hypr/logging"
setup-logging "$LOG_FILE" "$LOG_LABEL"
if [[ ! $# -gt 0 ]]; then
launch && exit 0
fi
while [[ $# -gt 0 ]]; do
if [[ $1 == "launch" ]]; then
launch && exit $?
elif [[ $1 == "picker" ]]; then
picker && exit $?
else
log --error "Invalid argument." && exit 1
fi
shift
done