From c38348e62c39a92d9807556b29a86ea100380ee4 Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Sat, 4 Oct 2025 16:57:11 -0400 Subject: [PATCH] feat: Creates a utility launcher fuzzy finder. --- env/.config/hypr/windows.conf | 4 +- env/.config/utils-launcher/config.json | 26 ++++++ env/.local/scripts/catppuccin-colors | 34 ++++++++ env/.local/scripts/hypr/utils-launcher | 107 +++++++++++++++++++++++++ 4 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 env/.config/utils-launcher/config.json create mode 100755 env/.local/scripts/catppuccin-colors create mode 100755 env/.local/scripts/hypr/utils-launcher diff --git a/env/.config/hypr/windows.conf b/env/.config/hypr/windows.conf index 9290a62..5f367dc 100644 --- a/env/.config/hypr/windows.conf +++ b/env/.config/hypr/windows.conf @@ -8,7 +8,7 @@ windowrule = float, tag:floating-window windowrule = center, tag:floating-window -windowrule = size 800 600, tag:floating-window +windowrule = size 60% 60%, tag:floating-window # Weather tui windowrule = float, class:^(com.ghostty.weather)$ @@ -17,11 +17,13 @@ windowrule = size 90% 80%, class:^(com.ghostty.weather)$ # Force windows to be a floating window windowrule = tag +floating-window, class:^(blueberry.py|org.gnome.Nautilus|com.ghostty.float)$ +windowrule = tag +floating-window, class:^(com.ghostty.utils-launcher)$ # Force to stay focused when visible. windowrule = stayfocused, class:(blueberry.py) windowrule = stayfocused, class:Pinentry.gtk windowrule = stayfocused, class:com.ghostty.float +windowrule = stayfocused, class:com.ghostty.utils-launcher # windowrule = stayfocused, class:.*pass.proton.me.* # Clipboard history tui in floating window. diff --git a/env/.config/utils-launcher/config.json b/env/.config/utils-launcher/config.json new file mode 100644 index 0000000..b460ce9 --- /dev/null +++ b/env/.config/utils-launcher/config.json @@ -0,0 +1,26 @@ +[ + { + "name": "Install Web App", + "exec": "$SCRIPTS/hypr/install-webapp" + }, + { + "name": "Uninstall Desktop App", + "exec": "$SCRIPTS/hypr/uninstall-desktop-app" + }, + { + "name": "Active Window Table / Picker", + "exec": "$SCRIPTS/hypr/window-table" + }, + { + "name": "Clear Clipboard History", + "exec": "$SCRIPTS/hypr/clear-clipboard-history && echo Done" + }, + { + "name": "Restart waybar", + "exec": "$SCRIPTS/hypr/waybar-restart" + }, + { + "name": "Toggle waybar", + "exec": "$SCRIPTS/hypr/toggle-waybar" + } +] diff --git a/env/.local/scripts/catppuccin-colors b/env/.local/scripts/catppuccin-colors new file mode 100755 index 0000000..42baa81 --- /dev/null +++ b/env/.local/scripts/catppuccin-colors @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +# Catppuccin-mocha colors https://catppuccin.com/palette/ +# +# This allows this file to be sourced and colors available in other scripts. + +export ROSEWATER="#f5e0dc" +export FLAMINGO="#f2cdcd" +export PINK="#f5c2e7" +export MAUVE="#cba6f7" +export RED="#f38ba8" +export MAROON="#eba0ac" +export PEACH="#fab387" +export YELLOW="#f9e2af" +export GREEN="#a6e3a1" +export TEAL="#94e2d5" +export SKY="#89dceb" +export SAPPHIRE="#74c7ec" +export BLUE="#89b4fa" +export LAVENDER="#b4befe" +export TEXT="#cdd6f4" +export SUBTEXT1="#bac2de" +export SUBTEXT0="#a6adc8" +export OVERLAY2="#9399b2" +export OVERLAY1="#7f849c" +export OVERLAY0="#6c7086" +export SURFACE2="#585b70" +export SURFACE1="#45475a" +export SURFACE0="#313244" +export BASE="#1e1e2e" +export MANTLE="#181825" +export CRUST="#11111b" + +export FZF_DEFAULT_OPTS="--color=header:$MAROON:bold,footer:$MAROON:bold,pointer:$MAUVE,prompt:$MAUVE,fg+:$MAUVE,border:$LAVENDER,info:$LAVENDER,fg:$TEXT,hl:$TEXT:bold,hl+:$TEXT:bold,bg:$BASE,bg+:$SURFACE0" diff --git a/env/.local/scripts/hypr/utils-launcher b/env/.local/scripts/hypr/utils-launcher new file mode 100755 index 0000000..17e701b --- /dev/null +++ b/env/.local/scripts/hypr/utils-launcher @@ -0,0 +1,107 @@ +#!/usr/bin/env bash + +THIS=$(basename ${BASH_SOURCE[0]}) + +usage() { + cat <: Set the location of the configuration file (default: XDG_CONFIG_HOME/utils-launcher/config.json) + -l | --launch: Launches in a new terminal window. + +EOF +} + +window_class="com.ghostty.$THIS" +window_padding_x="2" + +config_file="" +launch_flag="0" + +XDG_CONFIG_HOME=${XDG_CONFIG_HOME} +SCRIPTS=${SCRIPTS} + +while [[ $# -gt 0 ]]; do + if [[ $1 == "-c" ]] || [[ $1 == "--config" ]]; then + shift + config_file="$1" + elif [[ $1 == "-l" ]] || [[ $1 == "--launch" ]]; then + launch_flag="1" + fi + shift +done + +if [[ -z $XDG_CONFIG_HOME ]]; then + echo "XDG_CONFIG_HOME not set" + echo "using ~/.config" + XDG_CONFIG_HOME=$HOME/.config +fi + +launch() { + ghostty --class=$window_class --window-padding-x=$window_padding_x \ + --keybind="ctrl+c=quit" \ + -e ${BASH_SOURCE[0]} --config $config_file +} + +footer() { + cat <<'EOF' + __ ______________ _____ + / / / /_ __/ _/ / / ___/ + / / / / / / / // / \__ \ +/ /_/ / / / _/ // /______/ / +\____/ /_/ /___/_____/____/ + +EOF +} + +################################################################################ +# MAIN +################################################################################ + +if [[ -z $config_file ]]; then + echo "No config file set." + echo "Using ~/.config/utils-launcher/config.json" + config_file="$XDG_CONFIG_HOME/utils-launcher/config.json" +fi + +if [[ -z $SCRIPTS ]]; then + echo "SCRIPTS not set" + echo "using ~/.local/scripts" + SCRIPTS=$HOME/.local/scripts +fi + +if [[ $launch_flag == "1" ]]; then + launch && exit 0 +fi + +if [[ ! -f $config_file ]]; then + echo "[ERROR]: no config file set" && exit 1 +fi + +file_data=$(cat $config_file) + +# Setup colors before calling fzf. +[[ -f $SCRIPTS/catppuccin-colors ]] && source $SCRIPTS/catppuccin-colors +sel=$(echo "$file_data" | jq -r '.[] | .name' | fzf --style=full --footer="$(footer)") + +echo "Selection: $sel" + +if [[ -n "$sel" ]]; then + # Load the exec command for the selection. + exec_cmd=$(echo $file_data | jq -r ".[] | select(.name == \"$sel\") | .exec") + + echo "Exec: '$exec_cmd'" + if [[ -z $exec_cmd ]]; then + echo "[ERROR]: Command is empty." && exit 1 + fi + eval exec uwsm app -- "$exec_cmd" +else + echo "No selection." +fi