Commit 6fe6a97
Changed files (9)
.assets
icons
.config
hypr
modules
.local
share
applications
.assets/icons/shell.png
Binary file
.config/hypr/modules/vars.conf
@@ -8,3 +8,4 @@ $emojiMenu = rofimoji -a type copy type-numerical
env = LIBVA_DRIVER_NAME,nvidia
env = __GLX_VENDOR_LIBRARY_NAME,nvidia
+env = PATH,$PATH:$HOME/.wraith/bin
\ No newline at end of file
.wraith/bin/install-app
@@ -0,0 +1,63 @@
+#!/bin/bash
+set -e
+
+gum style --foreground 212 --border double --border-foreground 212 --padding "1 2" --align center "
+╻ ╻┏━┓┏━┓╻╺┳╸╻ ╻ ┏━╸┏━┓┏━┓┏━╸╺┳╸
+┃╻┃┣┳┛┣━┫┃ ┃ ┣━┫ ┃ ┣┳┛┣━┫┣╸ ┃
+┗┻┛╹┗╸╹ ╹╹ ╹ ╹ ╹ ┗━╸╹┗╸╹ ╹╹ ╹
+
+Install a Web App or TUI App to your system
+"
+
+if [ "$#" -lt 3 ]; then
+ TUI_OR_WEBAPP=$(gum choose "Web App" "TUI App")
+ APP_NAME=$(gum input --prompt "Name> " --placeholder "Github Desktop")
+ ICON_REF=$(gum input --prompt "Icon URL/Path> " --placeholder "https://example.com/icon.png")
+ SINGLETON=$(gum confirm "Singleton app (focus existing instance)?" && echo "yes" || echo "no")
+
+ if [ "$TUI_OR_WEBAPP" == "Web App" ]; then
+ APP_LOCATION=$(gum input --prompt "URL> " --placeholder "https://github.com")
+ DOMAIN=$(echo "$APP_LOCATION" | awk -F[/:] '{print $4}' | sed 's/^www\.//')
+ APP_ID="chrome-$DOMAIN"
+ [[ "$SINGLETON" == "yes" ]] && CUSTOM_EXEC="launch-or-focus-webapp \"$APP_ID\" \"$APP_LOCATION\"" || CUSTOM_EXEC="launch-webapp \"$APP_LOCATION\""
+ else
+ APP_ID=$(echo "$APP_NAME" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed 's/[^a-z0-9-]//g')
+ APP_LOCATION=$(gum input --prompt "Path> " --placeholder "/usr/bin/htop")
+ [[ "$SINGLETON" == "yes" ]] && CUSTOM_EXEC="launch-or-focus-tui \"$APP_ID\" \"$APP_LOCATION\"" || CUSTOM_EXEC="launch-tui \"$APP_ID\" \"$APP_LOCATION\""
+ fi
+else
+ APP_NAME="$1"; APP_LOCATION="$2"; ICON_REF="$3"; CUSTOM_EXEC="$4"; MIME_TYPES="$5"
+fi
+
+# Validation
+[[ -z "$APP_NAME" || -z "$APP_LOCATION" || -z "$ICON_REF" ]] && { echo "Missing required fields"; exit 1; }
+
+APP_ID=$(echo "$APP_NAME" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed 's/[^a-z0-9-]//g')
+
+# Icon Management
+ICON_DIR="$HOME/.assets/icons"
+mkdir -p "$ICON_DIR"
+if [[ $ICON_REF =~ ^https?:// ]]; then
+ ICON_PATH="$ICON_DIR/$APP_ID.png"
+ curl -sL -o "$ICON_PATH" "$ICON_REF" || { echo "Icon download failed"; exit 1; }
+else
+ ICON_PATH="$ICON_DIR/$ICON_REF"
+fi
+
+# Create .desktop file
+DESKTOP_FILE="$HOME/.local/share/applications/$APP_ID.desktop"
+
+cat >"$DESKTOP_FILE" <<EOF
+[Desktop Entry]
+Version=1.0
+Name=$APP_NAME
+Exec=$CUSTOM_EXEC
+Terminal=false
+Type=Application
+Icon=$ICON_PATH
+StartupNotify=true
+$( [[ -n "$MIME_TYPES" ]] && echo "MimeType=$MIME_TYPES" )
+EOF
+
+chmod +x "$DESKTOP_FILE"
+gum spin --spinner dot --title "Installation complete! You can now find '$APP_NAME' in your app launcher." -- sleep 3
\ No newline at end of file
.wraith/bin/install-webapp
@@ -1,67 +0,0 @@
-#!/bin/bash
-
-if [ "$#" -lt 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 "Github")
- APP_URL=$(gum input --prompt "URL> " --placeholder "https://github.com")
- ICON_REF=$(gum input --prompt "Icon URL> " --placeholder "See https://dashboardicons.com (must use PNG!)")
- CUSTOM_EXEC=""
- MIME_TYPES=""
- INTERACTIVE_MODE=true
-else
- APP_NAME="$1"
- APP_URL="$2"
- ICON_REF="$3"
- CUSTOM_EXEC="$4" # Optional custom exec command
- MIME_TYPES="$5" # Optional mime types
- INTERACTIVE_MODE=false
-fi
-
-# Ensure valid execution
-if [[ -z "$APP_NAME" || -z "$APP_URL" || -z "$ICON_REF" ]]; then
- echo "You must set app name, app URL, and icon URL!"
- exit 1
-fi
-
-# Refer to local icon or fetch remotely from URL
-ICON_DIR="$HOME/.assets/icons"
-if [[ $ICON_REF =~ ^https?:// ]]; then
- ICON_PATH="$ICON_DIR/$APP_NAME.png"
- if curl -sL -o "$ICON_PATH" "$ICON_REF"; then
- ICON_PATH="$ICON_DIR/$APP_NAME.png"
- else
- echo "Error: Failed to download icon."
- exit 1
- fi
-else
- ICON_PATH="$ICON_DIR/$ICON_REF"
-fi
-
-# Use custom exec if provided, otherwise default behavior
-if [[ -n $CUSTOM_EXEC ]]; then
- EXEC_COMMAND="$CUSTOM_EXEC"
-else
- EXEC_COMMAND="$HOME/.wraith/scripts/launch-webapp $APP_URL"
-fi
-
-# Create application .desktop file
-DESKTOP_FILE="$HOME/.local/share/applications/$APP_NAME.desktop"
-
-cat >"$DESKTOP_FILE" <<EOF
-[Desktop Entry]
-Version=1.0
-Name=$APP_NAME
-Comment=$APP_NAME
-Exec=$EXEC_COMMAND
-Terminal=false
-Type=Application
-Icon=$ICON_PATH
-StartupNotify=true
-EOF
-
-# Add mime types if provided
-if [[ -n $MIME_TYPES ]]; then
- echo "MimeType=$MIME_TYPES" >>"$DESKTOP_FILE"
-fi
-
-chmod +x "$DESKTOP_FILE"
\ No newline at end of file
.wraith/bin/launch-or-focus
@@ -0,0 +1,27 @@
+#!/usr/bin/env bash
+
+WINDOW_PATTERN="$1"
+# Default to uwsm-app, but allow override
+LAUNCH_COMMAND="${2:-"uwsm-app -- $WINDOW_PATTERN"}"
+
+# 1. Removed .title check to avoid matching terminal command history
+# 2. Added .initialClass check (helps with some electron apps)
+# 3. Added sort_by(.focusHistoryID) to ensure we grab the most recently used instance
+WINDOW_ADDRESS=$(hyprctl clients -j | jq -r --arg p "$WINDOW_PATTERN" '
+ map(select(
+ (.class | test("\\b" + $p + "\\b"; "i")) or
+ (.initialClass | test("\\b" + $p + "\\b"; "i")) or
+ (.class | contains($p)) or
+ (.class | test($p; "i"))
+ ))
+ | sort_by(.focusHistoryID)
+ | reverse
+ | .[0].address // empty'
+)
+
+if [[ -n $WINDOW_ADDRESS && $WINDOW_ADDRESS != "null" ]]; then
+ hyprctl dispatch focuswindow "address:$WINDOW_ADDRESS"
+else
+ # Use eval to handle arguments in LAUNCH_COMMAND correctly
+ eval exec setsid $LAUNCH_COMMAND &>/dev/null &
+fi
\ No newline at end of file
.wraith/bin/launch-or-focus-tui
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+APP_ID="org.wraith.$(basename $1)"
+LAUNCH_COMMAND="launch-tui $@"
+
+exec launch-or-focus "$APP_ID" "$LAUNCH_COMMAND"
\ No newline at end of file
.wraith/bin/launch-or-focus-webapp
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+WINDOW_PATTERN="$1"
+shift
+LAUNCH_COMMAND="launch-webapp $@"
+
+exec launch-or-focus "$WINDOW_PATTERN" "$LAUNCH_COMMAND"
.wraith/bin/launch-tui
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+APP_ID="org.wraith.$(basename $1)"
+COMMAND="$2"
+
+exec setsid uwsm-app -- xdg-terminal-exec --app-id=$APP_ID -e "$COMMAND" "${@:3}"
\ No newline at end of file