diff --git a/env/.config/hypr/hyprkeybinds.conf b/env/.config/hypr/hyprkeybinds.conf index 5773889..abc5070 100644 --- a/env/.config/hypr/hyprkeybinds.conf +++ b/env/.config/hypr/hyprkeybinds.conf @@ -16,7 +16,7 @@ $fileManager = $terminal -e yazi $fileBrowser = uwsm app -- nautilus $menu = hyprlauncher $scripts = ~/.local/scripts/hypr -$pwa = $scripts/launch-webapp +$pwa = $scripts/webapp launch $tmuxSessionator = ~/.local/scripts/tmux-sessionator $clipboardHistory = com.ghostty.clipse $terminal --class=com.ghostty.clipse -e clipse $uninstallDesktop = $terminal --class=com.ghostty.float -e $scripts/uninstall-desktop-app diff --git a/env/.local/scripts/hypr/install-webapp b/env/.local/scripts/hypr/utils/webapp/install similarity index 97% rename from env/.local/scripts/hypr/install-webapp rename to env/.local/scripts/hypr/utils/webapp/install index 5418375..2a52fac 100755 --- a/env/.local/scripts/hypr/install-webapp +++ b/env/.local/scripts/hypr/utils/webapp/install @@ -3,7 +3,9 @@ # Adapted from https://github.com/basecamp/omarchy/tree/master?tab=readme-ov-file THIS_FILE=${BASH_SOURCE[0]} -THIS=$(basename "$THIS_FILE") +THIS=${THIS:-$(basename "$THIS_FILE")} +LOG_FILE=${LOG_FILE:-"$THIS.log"} +LOG_LABEL=$(basename "$THIS_FILE") function usage() { cat </dev/null | head -1) --app="$url" "$app_args" diff --git a/env/.local/scripts/hypr/webapp b/env/.local/scripts/hypr/webapp new file mode 100755 index 0000000..75f57b3 --- /dev/null +++ b/env/.local/scripts/hypr/webapp @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +set -e +set -o nounset +set -o pipefail + +SCRIPTS=${SCRIPTS:-$HOME/.local/scripts} +THIS_FILE=${BASH_SOURCE[0]} +LOG_LABEL=$(basename "$THIS_FILE") +THIS=${THIS:-$LOG_LABEL} +LOG_FILE=${LOG_FILE:-"$LOG_LABEL.log"} + +usage() { + cat < + + FLAGS: + -h | --help: Show this help page. + + COMMANDS: + install: Generate a '.desktop' file for a web app. + launch: Launch a url as a web app. + +RUN '$THIS --help' for more information about a command. + +EOF +} + +# Logging utility function, use in place of echo. +log() { + logging log --source "$THIS_FILE" "$@" +} + +################################################################################ +# MAIN +################################################################################ + +# Setup logging file and label. +source "$SCRIPTS/hypr/logging" +setup-logging "$LOG_FILE" "$LOG_LABEL" + +while [[ $# -gt 0 ]]; do + if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then + usage + elif [[ $1 == "install" ]]; then + shift + THIS="$THIS install" "$SCRIPTS/hypr/utils/webapp/install" "$@" + elif [[ $1 == "launch" ]]; then + shift + THIS="$THIS launch" "$SCRIPTS/hypr/utils/webapp/launch" "$@" + fi + shift +done + diff --git a/webapp b/webapp index ad0545a..36ca727 100755 --- a/webapp +++ b/webapp @@ -51,7 +51,7 @@ log() { install() { local file=$DEV_ENV/env/webapps/$(basename $1) - local script="$DEV_ENV/env/.local/scripts/hypr/install-webapp" + local script="$DEV_ENV/env/.local/scripts/hypr/webapp" if [[ ! -x $script ]]; then log "Failed to find install web app script." @@ -69,7 +69,7 @@ install() { log "Installing webapp from spec: $file" if [[ $dry_run == "0" ]]; then - $script --file $file --no-interactive + $script install --file $file --no-interactive fi }