From c6a0056ad646ccf0ca95130e3c71bb487fa68f0f Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Sun, 28 Sep 2025 17:36:55 -0400 Subject: [PATCH] feat: Adds webapps specs and insallation, also an uninstall-webapp script that will also remove any downloaded icons. --- dev-env | 11 +++ env/.local/scripts/uninstall-webapp | 33 +++++++++ webapp | 110 ++++++++++++++++++++++++++++ webapps/excalidraw.json | 6 ++ webapps/gitea.json | 6 ++ webapps/github.json | 6 ++ webapps/housecallpro.json | 6 ++ webapps/hyprland-wiki.json | 6 ++ webapps/immich.json | 6 ++ webapps/oryx.json | 6 ++ webapps/unifi.json | 6 ++ webapps/youtube.json | 6 ++ 12 files changed, 208 insertions(+) create mode 100755 env/.local/scripts/uninstall-webapp create mode 100755 webapp create mode 100644 webapps/excalidraw.json create mode 100644 webapps/gitea.json create mode 100644 webapps/github.json create mode 100644 webapps/housecallpro.json create mode 100644 webapps/hyprland-wiki.json create mode 100644 webapps/immich.json create mode 100644 webapps/oryx.json create mode 100644 webapps/unifi.json create mode 100644 webapps/youtube.json diff --git a/dev-env b/dev-env index 714d96e..1db676b 100755 --- a/dev-env +++ b/dev-env @@ -12,6 +12,12 @@ if [ -z "$XDG_CONFIG_HOME" ]; then XDG_CONFIG_HOME=$HOME/.config fi +if [ -z "$XDG_DATA_HOME" ]; then + echo "no xdg data home" + echo "using ~/.local/share" + XDG_DATA_HOME=$HOME/.local/share +fi + if [ -z "$DEV_ENV" ]; then echo "env var DEV_ENV needs to be present" exit 1 @@ -114,7 +120,12 @@ copy $DEV_ENV/env/.tmux.conf $HOME/.tmux.conf mkdir $HOME/.gnupg copy_files $DEV_ENV/env/.gnupg $HOME/.gnupg +# Wallpapers +mkdir $HOME/wallpapers +copy_files $DEV_ENV/assets/wallpapers $HOME/wallpapers + copy $DEV_ENV/dev-env $HOME/.local/scripts/dev-env systemctl --user daemon-reload hyprctl reload +exec zsh -l diff --git a/env/.local/scripts/uninstall-webapp b/env/.local/scripts/uninstall-webapp new file mode 100755 index 0000000..90a31de --- /dev/null +++ b/env/.local/scripts/uninstall-webapp @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +# Uninstall's a web app, including it's icon. + +app_dir="$HOME/.local/share/applications" +file="$1" + +if [[ -z "$file" ]]; then + echo -e "Must supplye a web app name to uninstall.\n\n" + echo "Usage: uninstall-webapp " + exit 1 +fi + +file="$(basename $file)" +if [[ ! $file =~ \.desktop$ ]]; then + file="$file.desktop" +fi + +desktop="$app_dir/$file" + +if [[ ! -f "$desktop" ]]; then + echo "No webapp found @: $desktop" + exit 1 +fi + +icon=$(cat $desktop | grep "Icon") +icon="${icon/#Icon=/}" + +echo "Removing Application: $desktop" +rm -rf "$desktop" + +echo "Removing Icon: $icon" +rm -rf "$icon" >/dev/null 2>&1 diff --git a/webapp b/webapp new file mode 100755 index 0000000..b9a964d --- /dev/null +++ b/webapp @@ -0,0 +1,110 @@ +#!/usr/bin/env bash + +# Installs or uninstalls webapps based on the spec in the './webapps' directory. +# +# This is used when setting up a new machine. + +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" + +if [ -z "$DEV_ENV" ]; then + echo "env var DEV_ENV needs to be present" + exit 1 +fi + +if [ -z "$XDG_DATA_HOME" ]; then + echo "no xdg data home" + echo "using ~/.local/share" + XDG_DATA_HOME=~/.local/share +fi + +grep="" +dry_run="0" +uninstall="0" + +while [[ $# -gt 0 ]]; do + echo "ARG: \"$1\"" + + # Handle a --dry or --dry-run argument + if [[ "$1" =~ ^--dry ]]; then + dry_run="1" + # Handle an --uninstall argument + elif [[ "$1" =~ ^--u ]]; then + uninstall="1" + # Handle an --install argument (default) + elif [[ ! "$1" =~ ^--i ]]; then + grep="$1" + fi + shift +done + +log() { + if [[ $dry_run == "1" ]]; then + echo "[DRY_RUN]: $1" + else + echo "$1" + fi +} + +install() { + local file=$(cat $1) + local script="${script_dir}/env/.local/scripts/install-webapp" + + if [[ ! -x $script ]]; then + log "Failed to find install web app script." + exit 1 + fi + + # Install local icons if needed + mkdir -p $XDG_DATA_HOME/applications/icons + for i in $(find $script_dir/assets/icons -mindepth 1 -maxdepth 1 -type f); do + if [[ ! -f $XDG_DATA_HOME/applications/icons/$i ] && [ $dry_run == "0" ]]; then + cp $i $XDG_DATA_HOME/applications/icons + fi + done + + log "Installing webapp from spec: $1" + + if [[ $dry_run == "0" ]]; then + $script \ + --name $(echo $file | jq -r '.name') \ + --url $(echo $file | jq -r '.url') \ + --icon $(echo $file | jq -r '.icon') \ + --exec $(echo $file | jq -r '.exec') \ + --mime $(echo $file | jq -r '.mime') + fi +} + +uninstall() { + local file=$(cat $1) + local script="${script_dir}/env/.local/scripts/uninstall-webapp" + + if [[ ! -x $script ]]; then + log "Failed to find uninstall web app script." + exit 1 + fi + + log "Uninstalling webapp from spec: $1" + + if [[ $dry_run == "0" ]]; then + $script $(echo $file | jq -r '.name') + fi +} + +############################## MAIN ############################## + +log "WEBAPP: -- grep: $grep" + +apps_dir=$(find $script_dir/webapps -mindepth 1 -maxdepth 1 -type f) + +for s in $apps_dir; do + if basename $s | grep -vq "$grep"; then + log "grep \"$grep\" filtered out $s" + continue + fi + + if [[ $uninstall == "1" ]]; then + uninstall $s + else + install $s + fi +done diff --git a/webapps/excalidraw.json b/webapps/excalidraw.json new file mode 100644 index 0000000..f1ffa16 --- /dev/null +++ b/webapps/excalidraw.json @@ -0,0 +1,6 @@ +{ + "name": "Excalidraw", + "url": "https://draw.housh.dev", + "icon": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/excalidraw.png" +} + diff --git a/webapps/gitea.json b/webapps/gitea.json new file mode 100644 index 0000000..38659fd --- /dev/null +++ b/webapps/gitea.json @@ -0,0 +1,6 @@ +{ + "name": "Gitea", + "url": "https://git.housh.dev", + "icon": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/gitea.png" +} + diff --git a/webapps/github.json b/webapps/github.json new file mode 100644 index 0000000..440b7bc --- /dev/null +++ b/webapps/github.json @@ -0,0 +1,6 @@ +{ + "name": "Github", + "url": "https://github.com", + "icon": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/github-light.png" +} + diff --git a/webapps/housecallpro.json b/webapps/housecallpro.json new file mode 100644 index 0000000..6f9da4e --- /dev/null +++ b/webapps/housecallpro.json @@ -0,0 +1,6 @@ +{ + "name": "HouseCall Pro", + "url": "https://pro.housecallpro.com/app/calendar_new", + "icon": "~/.local/share/applications/icons/housecallpro.png" +} + diff --git a/webapps/hyprland-wiki.json b/webapps/hyprland-wiki.json new file mode 100644 index 0000000..b460f26 --- /dev/null +++ b/webapps/hyprland-wiki.json @@ -0,0 +1,6 @@ +{ + "name": "Hyprland Wiki", + "url": "https://wiki.hypr.land", + "icon": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/hyprland.png" +} + diff --git a/webapps/immich.json b/webapps/immich.json new file mode 100644 index 0000000..f9dcfd2 --- /dev/null +++ b/webapps/immich.json @@ -0,0 +1,6 @@ +{ + "name": "Immich", + "url": "https://photos.housh.dev", + "icon": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/immich.png" +} + diff --git a/webapps/oryx.json b/webapps/oryx.json new file mode 100644 index 0000000..f06b283 --- /dev/null +++ b/webapps/oryx.json @@ -0,0 +1,6 @@ +{ + "name": "Oryx", + "url": "https://configure.zsa.io/voyager/layouts/v9LLL/latest/0", + "icon": "~/.local/share/applications/icons/oryx.png" +} + diff --git a/webapps/unifi.json b/webapps/unifi.json new file mode 100644 index 0000000..ddd8d91 --- /dev/null +++ b/webapps/unifi.json @@ -0,0 +1,6 @@ +{ + "name": "Unifi", + "url": "https://unifi.ui.com", + "icon": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/unifi.png" +} + diff --git a/webapps/youtube.json b/webapps/youtube.json new file mode 100644 index 0000000..38e6e74 --- /dev/null +++ b/webapps/youtube.json @@ -0,0 +1,6 @@ +{ + "name": "YouTube", + "url": "https://youtube.com", + "icon": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/youtube.png" +} +