From d90146fde3ce7d551371a74542c2e85d91a23ba6 Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Sun, 21 Sep 2025 01:03:39 -0400 Subject: [PATCH] feat: Adds arch specific scripts and removes raycast (macOS) specific scripts. --- scripts/arch/launch-webapp | 7 ++ scripts/arch/toggle-internal-monitor | 12 +++ scripts/arch/toggle-waybar | 11 +++ scripts/arch/webapp-install | 73 +++++++++++++++++++ scripts/scripts/raycast/pass-attribute.sh | 48 ------------ scripts/scripts/raycast/pass-copy.sh | 47 ------------ scripts/scripts/raycast/pass-gen.sh | 33 --------- .../raycast/script-command.template.sh | 17 ----- 8 files changed, 103 insertions(+), 145 deletions(-) create mode 100755 scripts/arch/launch-webapp create mode 100755 scripts/arch/toggle-internal-monitor create mode 100755 scripts/arch/toggle-waybar create mode 100755 scripts/arch/webapp-install delete mode 100755 scripts/scripts/raycast/pass-attribute.sh delete mode 100755 scripts/scripts/raycast/pass-copy.sh delete mode 100755 scripts/scripts/raycast/pass-gen.sh delete mode 100755 scripts/scripts/raycast/script-command.template.sh diff --git a/scripts/arch/launch-webapp b/scripts/arch/launch-webapp new file mode 100755 index 0000000..842ec4e --- /dev/null +++ b/scripts/arch/launch-webapp @@ -0,0 +1,7 @@ +#!/bin/bash + +# Adapted from https://github.com/basecamp/omarchy/tree/master?tab=readme-ov-file +# +browser="chromium.desktop" + +exec setsid uwsm app -- $(sed -n 's/^Exec=\([^ ]*\).*/\1/p' {~/.local,~/.nix-profile,/usr}/share/applications/$browser 2>/dev/null | head -1) --app="$1" "${@:2}" diff --git a/scripts/arch/toggle-internal-monitor b/scripts/arch/toggle-internal-monitor new file mode 100755 index 0000000..f645e3e --- /dev/null +++ b/scripts/arch/toggle-internal-monitor @@ -0,0 +1,12 @@ +#!/bin/zsh +# +# Toggles the state of the internal laptop monitor, which is useful +# when I'm connected to an external monitor / docks. + +monitor="eDP-1" + +if hyprctl monitors | grep -q "$monitor"; then + hyprctl keyword monitor "$monitor,disable" 1>/dev/null +else + hyprctl keyword monitor "$monitor,enable" 1>/dev/null +fi diff --git a/scripts/arch/toggle-waybar b/scripts/arch/toggle-waybar new file mode 100755 index 0000000..d2a8cda --- /dev/null +++ b/scripts/arch/toggle-waybar @@ -0,0 +1,11 @@ +#!/bin/sh + +WAYBAR_PID=$(pgrep -x waybar) + +if [ -n "$WAYBAR_PID" ]; then + # kill waybar process if it's running. + kill "$WAYBAR_PID" +else + # start waybar in the background. + waybar & +fi diff --git a/scripts/arch/webapp-install b/scripts/arch/webapp-install new file mode 100755 index 0000000..4374484 --- /dev/null +++ b/scripts/arch/webapp-install @@ -0,0 +1,73 @@ +#!/bin/bash + +# Adapted from https://github.com/basecamp/omarchy/tree/master?tab=readme-ov-file +# +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 "My favorite web app") + APP_URL=$(gum input --prompt "URL> " --placeholder "https://example.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/.local/share/applications/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/.local/bin/launch-webapp $APP_URL" +fi + +# Create application .desktop file +DESKTOP_FILE="$HOME/.local/share/applications/$APP_NAME.desktop" + +cat >"$DESKTOP_FILE" <>"$DESKTOP_FILE" +fi + +chmod +x "$DESKTOP_FILE" + +if [[ $INTERACTIVE_MODE == true ]]; then + echo -e "You can now find $APP_NAME using the app launcher (SUPER + SPACE)\n" +fi diff --git a/scripts/scripts/raycast/pass-attribute.sh b/scripts/scripts/raycast/pass-attribute.sh deleted file mode 100755 index 8b79c52..0000000 --- a/scripts/scripts/raycast/pass-attribute.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/zsh -l - -# Required parameters: -# @raycast.schemaVersion 1 -# @raycast.title pass-attribute -# @raycast.mode compact - -# Optional parameters: -# @raycast.icon 🗝️ -# @raycast.argument1 { "type": "text", "placeholder": "Key" } -# @raycast.argument2 { "type": "text", "placeholder": "For" } -# @raycast.packageName Password - -# Documentation: -# @raycast.description Get an attribute / key from the password store -# @raycast.author Michael Housh -# @raycast.authorURL https://github.com/m-housh - -PREFIX="$HOME/.local/share/password-store" -PASS="$(command -v pass)" - -# -# Begin program -# -[ -z "$PASS" ] && \ - echo "Error: pass utility not found." && \ - exit 1 - -key="$1" -file="$2" -selected=$(find "$PREFIX" -type f -name "$file.gpg") - -# Check if we found a password file at the path. -[ -z "$selected" ] && \ - echo "Path not found: $file" && \ - exit 1 - -# Sanitize the path to work with the pass command. -selected="${selected//$PREFIX\//}" -selected="${selected//.gpg/}" - -# Capture the result of searching for the key. -result=$("$PASS" get "$key" "$selected") - -[ -z "$result" ] && echo "Key not found" && exit 1 -echo "$result" | pbcopy -echo "$key: Copied to clipboard" - diff --git a/scripts/scripts/raycast/pass-copy.sh b/scripts/scripts/raycast/pass-copy.sh deleted file mode 100755 index 86288be..0000000 --- a/scripts/scripts/raycast/pass-copy.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/zsh -l - -# Required parameters: -# @raycast.schemaVersion 1 -# @raycast.title pass-copy -# @raycast.mode compact - -# Optional parameters: -# @raycast.icon 🔐 -# @raycast.argument1 { "type": "text", "placeholder": "For" } -# @raycast.packageName Password - -# Documentation: -# @raycast.description Copy password from password-store -# @raycast.author Michael Housh -# @raycast.authorURL https://github.com/m-housh - -PREFIX="$HOME/.local/share/password-store" -LOG=/tmp/pass-copy.out -ISOSEC="$HOME/.local/share/scripts/isosec" -PASS="$(command -v pass)" - -_log() { - echo "$($ISOSEC) $1" >> "$LOG" -} - -# -# Begin program -# -[ -z "$PASS" ] && \ - echo "Error: pass utility not found." && \ - _log "Error: pass utility not found." && \ - exit 1 - -selected=$(find "$PREFIX" -type f -name "$1".gpg) - -[ -z "$selected" ] && \ - _log "Error: Not Found" && \ - _log "Input: $1" && \ - exit 1 - -selected="${selected//$PREFIX\//}" -selected="${selected//.gpg/}" -_log "Running pass with selection: $selected" -"$PASS" --clip "$selected" - - diff --git a/scripts/scripts/raycast/pass-gen.sh b/scripts/scripts/raycast/pass-gen.sh deleted file mode 100755 index ff09a80..0000000 --- a/scripts/scripts/raycast/pass-gen.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/zsh -l - -# Required parameters: -# @raycast.schemaVersion 1 -# @raycast.title pass-gen -# @raycast.mode compact - -# Optional parameters: -# @raycast.icon 🔐 -# @raycast.argument1 { "type": "text", "placeholder": "Path" } -# @raycast.packageName Password - -# Documentation: -# @raycast.description Copy password from password-store -# @raycast.author Michael Housh -# @raycast.authorURL https://github.com/m-housh - -PREFIX="$HOME/.local/share/password-store" -PASS="$(command -v pass)" - -[ -z "$PASS" ] && \ - echo "Error: pass utility not found." && \ - exit 1 - -[ -z "$1" ] && \ - echo "Error: must supply a name/path for the password" && \ - exit 1 - -"$PASS" generate --clip "$1" - -_log "Ending" - - diff --git a/scripts/scripts/raycast/script-command.template.sh b/scripts/scripts/raycast/script-command.template.sh deleted file mode 100755 index b642b7e..0000000 --- a/scripts/scripts/raycast/script-command.template.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -# Raycast Script Command Template -# -# Duplicate this file and remove ".template." from the filename to get started. -# See full documentation here: https://github.com/raycast/script-commands -# -# Required parameters: -# @raycast.schemaVersion 1 -# @raycast.title My First Script -# @raycast.mode fullOutput -# -# Optional parameters: -# @raycast.icon 🤖 -# @raycast.packageName Raycast Scripts - -echo "Hello from My First Script" \ No newline at end of file