feat: Adds webapps specs and insallation, also an uninstall-webapp script that will also remove any downloaded icons.

This commit is contained in:
2025-09-28 17:36:55 -04:00
parent d5ab230d3f
commit c6a0056ad6
12 changed files with 208 additions and 0 deletions

11
dev-env
View File

@@ -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

33
env/.local/scripts/uninstall-webapp vendored Executable file
View File

@@ -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 <name | path>"
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

110
webapp Executable file
View File

@@ -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

6
webapps/excalidraw.json Normal file
View File

@@ -0,0 +1,6 @@
{
"name": "Excalidraw",
"url": "https://draw.housh.dev",
"icon": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/excalidraw.png"
}

6
webapps/gitea.json Normal file
View File

@@ -0,0 +1,6 @@
{
"name": "Gitea",
"url": "https://git.housh.dev",
"icon": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/gitea.png"
}

6
webapps/github.json Normal file
View File

@@ -0,0 +1,6 @@
{
"name": "Github",
"url": "https://github.com",
"icon": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/github-light.png"
}

View File

@@ -0,0 +1,6 @@
{
"name": "HouseCall Pro",
"url": "https://pro.housecallpro.com/app/calendar_new",
"icon": "~/.local/share/applications/icons/housecallpro.png"
}

View File

@@ -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"
}

6
webapps/immich.json Normal file
View File

@@ -0,0 +1,6 @@
{
"name": "Immich",
"url": "https://photos.housh.dev",
"icon": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/immich.png"
}

6
webapps/oryx.json Normal file
View File

@@ -0,0 +1,6 @@
{
"name": "Oryx",
"url": "https://configure.zsa.io/voyager/layouts/v9LLL/latest/0",
"icon": "~/.local/share/applications/icons/oryx.png"
}

6
webapps/unifi.json Normal file
View File

@@ -0,0 +1,6 @@
{
"name": "Unifi",
"url": "https://unifi.ui.com",
"icon": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/unifi.png"
}

6
webapps/youtube.json Normal file
View File

@@ -0,0 +1,6 @@
{
"name": "YouTube",
"url": "https://youtube.com",
"icon": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/youtube.png"
}