diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index af444d0..23b1f59 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -90,3 +90,5 @@ bindkey -s ^n "tmux-sessionizer\n" # Zsh syntax highlighting source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh + +source ~/.config/zsh/functions diff --git a/.config/zsh/functions b/.config/zsh/functions new file mode 100644 index 0000000..b1c2e76 --- /dev/null +++ b/.config/zsh/functions @@ -0,0 +1,50 @@ +# Create a desktop launcher for a web app +web2app() { + if [ "$#" -ne 3 ]; then + echo "Usage: web2app (IconURL must be in PNG -- use https://dashboardicons.com)" + return 1 + fi + + local APP_NAME="$1" + local APP_URL="$2" + local ICON_URL="$3" + local ICON_DIR="$HOME/.local/share/applications/icons" + local DESKTOP_FILE="$HOME/.local/share/applications/${APP_NAME}.desktop" + local ICON_PATH="${ICON_DIR}/${APP_NAME}.png" + + mkdir -p "$ICON_DIR" + + if ! curl -sL -o "$ICON_PATH" "$ICON_URL"; then + echo "Error: Failed to download icon." + return 1 + fi + + cat > "$DESKTOP_FILE" <" + return 1 + fi + + local APP_NAME="$1" + local ICON_DIR="$HOME/.local/share/applications/icons" + local DESKTOP_FILE="$HOME/.local/share/applications/${APP_NAME}.desktop" + local ICON_PATH="${ICON_DIR}/${APP_NAME}.png" + + rm "$DESKTOP_FILE" + rm "$ICON_PATH" +}