Files
dotfiles/script/sjb-webapp-installer
T
steveandgitadmin 02a5e0df28 init: new dotfile configuration
Remove all org files using a new script to more config over, The old org
file configuaration were great but required org. This new version only
requires the scripts that is included in the repo.

The configuration are all done but have not ported the theming system
yet.

Signed-off-by: Steve Beaulac <steve@sagacity.ca>
Change-Id: I14cd7fe058a71c8ba9d6d35397dc8d7e6a6a6964
2026-03-02 13:26:21 -05:00

66 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
get_file_extension() {
local url="$1"
# Remove query parameters and fragments
local clean_url="${url%%\?*}"
clean_url="${clean_url%%\#*}"
# Get the filename part
local filename="${clean_url##*/}"
# Check if there's a dot in the filename
if [[ "$filename" == *.* ]]; then
echo "${filename##*.}"
else
echo ""
fi
}
if [ "$#" -ne 3 ]; then
echo -e "\e[32mLet's create a new web app you can start with the app launcher.\n\e[0m"
APP_NAME=$(gum input --prompt "Name> " --placeholder "My favorite web app")
APP_URL=$(gum input --prompt "URL> " --placeholder "https://example.com")
ICON_URL=$(gum input --prompt "Icon URL> " --placeholder "See https://dashboardicons.com (must use PNG!)")
else
APP_NAME="$1"
APP_URL="$2"
ICON_URL="$3"
fi
if [[ -z "$APP_NAME" || -z "$APP_URL" || -z "$ICON_URL" ]]; then
echo "You must set app name, app URL, and icon URL!"
exit 1
fi
ICON_EXT=$(get_file_extension "$ICON_URL")
ICON_DIR="$HOME/.local/share/icons"
DESKTOP_FILE="$HOME/.local/share/applications/$APP_NAME.desktop"
ICON_PATH="$ICON_DIR/$APP_NAME.$ICON_EXT"
mkdir -p "$ICON_DIR"
if ! curl -sL -o "$ICON_PATH" "$ICON_URL"; then
echo "Error: Failed to download icon."
exit 1
fi
cat >"$DESKTOP_FILE" <<EOF
[Desktop Entry]
Version=1.0
Name=$APP_NAME
Comment=$APP_NAME
Exec=chromium --new-window --ozone-platform=wayland --app="$APP_URL" --name="$APP_NAME" --class="$APP_NAME"
Terminal=false
Type=Application
Icon=$APP_NAME
StartupNotify=true
EOF
chmod +x "$DESKTOP_FILE"
if [ "$#" -ne 3 ]; then
echo -e "You can now find $APP_NAME using the app launcher (SUPER + SPACE)\n"
fi