mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-13 22:02:34 +00:00
feat: Unifies webapp scripts into a single script with subcommands.
This commit is contained in:
2
env/.config/hypr/hyprkeybinds.conf
vendored
2
env/.config/hypr/hyprkeybinds.conf
vendored
@@ -16,7 +16,7 @@ $fileManager = $terminal -e yazi
|
|||||||
$fileBrowser = uwsm app -- nautilus
|
$fileBrowser = uwsm app -- nautilus
|
||||||
$menu = hyprlauncher
|
$menu = hyprlauncher
|
||||||
$scripts = ~/.local/scripts/hypr
|
$scripts = ~/.local/scripts/hypr
|
||||||
$pwa = $scripts/launch-webapp
|
$pwa = $scripts/webapp launch
|
||||||
$tmuxSessionator = ~/.local/scripts/tmux-sessionator
|
$tmuxSessionator = ~/.local/scripts/tmux-sessionator
|
||||||
$clipboardHistory = com.ghostty.clipse $terminal --class=com.ghostty.clipse -e clipse
|
$clipboardHistory = com.ghostty.clipse $terminal --class=com.ghostty.clipse -e clipse
|
||||||
$uninstallDesktop = $terminal --class=com.ghostty.float -e $scripts/uninstall-desktop-app
|
$uninstallDesktop = $terminal --class=com.ghostty.float -e $scripts/uninstall-desktop-app
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
# Adapted from https://github.com/basecamp/omarchy/tree/master?tab=readme-ov-file
|
# Adapted from https://github.com/basecamp/omarchy/tree/master?tab=readme-ov-file
|
||||||
|
|
||||||
THIS_FILE=${BASH_SOURCE[0]}
|
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() {
|
function usage() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
@@ -237,7 +239,7 @@ EOF
|
|||||||
|
|
||||||
# Setup logging file and label
|
# Setup logging file and label
|
||||||
source "$SCRIPTS/hypr/logging"
|
source "$SCRIPTS/hypr/logging"
|
||||||
setup-logging "$THIS.log" "$THIS"
|
setup-logging "$LOG_FILE" "$LOG_LABEL"
|
||||||
export LOG_ENABLE_DRY_RUN="$dry_run"
|
export LOG_ENABLE_DRY_RUN="$dry_run"
|
||||||
|
|
||||||
if [[ -z "$XDG_DATA_HOME" ]]; then
|
if [[ -z "$XDG_DATA_HOME" ]]; then
|
||||||
@@ -287,7 +289,7 @@ set_icon_ref
|
|||||||
|
|
||||||
# Check that an exec command is set, or default to the 'launch-webapp' script.
|
# Check that an exec command is set, or default to the 'launch-webapp' script.
|
||||||
if [[ -z $exec_cmd ]]; then
|
if [[ -z $exec_cmd ]]; then
|
||||||
exec_cmd="$SCRIPTS/hypr/launch-webapp $app_url"
|
exec_cmd="$SCRIPTS/hypr/webapp launch $app_url"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log "\e[032mCreating web app:\e[0m $desktop_file"
|
log "\e[032mCreating web app:\e[0m $desktop_file"
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
SCRIPTS="${SCRIPTS:-$HOME/.local/scripts}"
|
SCRIPTS="${SCRIPTS:-$HOME/.local/scripts}"
|
||||||
THIS_FILE=${BASH_SOURCE[0]}
|
THIS_FILE=${BASH_SOURCE[0]}
|
||||||
LOG_LABEL=$(basename "$THIS_FILE")
|
LOG_LABEL=$(basename "$THIS_FILE")
|
||||||
THIS=$(basename "$THIS_FILE")
|
THIS=${THIS:-$(basename "$THIS_FILE")}
|
||||||
LOG_FILE=${LOG_FILE:-"$LOG_LABEL.log"}
|
LOG_FILE=${LOG_FILE:-"$LOG_LABEL.log"}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
@@ -29,7 +29,7 @@ NOTES:
|
|||||||
|
|
||||||
Any extra arguments after '--' get passed directly to the browser invocation.
|
Any extra arguments after '--' get passed directly to the browser invocation.
|
||||||
|
|
||||||
$ launch-webapp https://example.com -- --some-random-flag-for-browser=1
|
$ $THIS https://example.com -- --some-random-flag-for-browser=1
|
||||||
|
|
||||||
Any options passed in prior to the '--' get sent to the 'launch' script, so you can pass
|
Any options passed in prior to the '--' get sent to the 'launch' script, so you can pass
|
||||||
options that are not specifically shown here, but the ones shown would be the most commonly
|
options that are not specifically shown here, but the ones shown would be the most commonly
|
||||||
@@ -94,7 +94,7 @@ fi
|
|||||||
# Any left over args after "--"
|
# Any left over args after "--"
|
||||||
app_args="$@"
|
app_args="$@"
|
||||||
|
|
||||||
log "URL: $url"
|
log "Launching URL: $url"
|
||||||
log " Launch args: ${launch_args[@]}"
|
log " Launch args: ${launch_args[@]}"
|
||||||
log " App args: ${app_args}"
|
log " App args: ${app_args}"
|
||||||
|
|
||||||
57
env/.local/scripts/hypr/webapp
vendored
Executable file
57
env/.local/scripts/hypr/webapp
vendored
Executable file
@@ -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 <<EOF
|
||||||
|
Utility for launching or installing a progressive web app.
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
$ $THIS <flags> <command>
|
||||||
|
|
||||||
|
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 <command> --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
|
||||||
|
|
||||||
4
webapp
4
webapp
@@ -51,7 +51,7 @@ log() {
|
|||||||
|
|
||||||
install() {
|
install() {
|
||||||
local file=$DEV_ENV/env/webapps/$(basename $1)
|
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
|
if [[ ! -x $script ]]; then
|
||||||
log "Failed to find install web app script."
|
log "Failed to find install web app script."
|
||||||
@@ -69,7 +69,7 @@ install() {
|
|||||||
log "Installing webapp from spec: $file"
|
log "Installing webapp from spec: $file"
|
||||||
|
|
||||||
if [[ $dry_run == "0" ]]; then
|
if [[ $dry_run == "0" ]]; then
|
||||||
$script --file $file --no-interactive
|
$script install --file $file --no-interactive
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user