7 Commits

19 changed files with 579 additions and 170 deletions

View File

@@ -17,14 +17,18 @@ windowrule = size 90% 80%, class:^(com.ghostty.weather)$
# Force windows to be a floating window # 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:^(blueberry.py|org.gnome.Nautilus|com.ghostty.float)$
windowrule = tag +floating-window, class:^(com.ghostty.utils-launcher)$ # windowrule = tag +floating-window, class:^(com.ghostty.utils-launcher)$
# Force to stay focused when visible. # Force to stay focused when visible.
windowrule = stayfocused, class:(blueberry.py) windowrule = stayfocused, class:(blueberry.py)
windowrule = stayfocused, class:Pinentry.gtk windowrule = stayfocused, class:Pinentry.gtk
windowrule = stayfocused, class:com.ghostty.float windowrule = stayfocused, class:com.ghostty.float
windowrule = stayfocused, class:com.ghostty.utils-launcher
# windowrule = stayfocused, class:.*pass.proton.me.* # Utils-Launcher
windowrule = stayfocused, class:^(com.ghostty.utils-launcher)$
windowrule = float, class:^(com.ghostty.utils-launcher)$
windowrule = center, class:^(com.ghostty.utils-launcher)$
windowrule = size 80% 80%, class:^(com.ghostty.utils-launcher)$
# Clipboard history tui in floating window. # Clipboard history tui in floating window.
windowrule = tag +floating-window, class:.*clipse.* windowrule = tag +floating-window, class:.*clipse.*

View File

@@ -11,16 +11,20 @@
"name": "Clipboard - clear history", "name": "Clipboard - clear history",
"exec": "$SCRIPTS/hypr/clear-clipboard-history && echo Done" "exec": "$SCRIPTS/hypr/clear-clipboard-history && echo Done"
}, },
{
"name": "Monitors - stats / picker",
"exec": "$SCRIPTS/hypr/monitor-picker"
},
{ {
"name": "Waybar - restart", "name": "Waybar - restart",
"exec": "$SCRIPTS/hypr/waybarctl --restart" "exec": "$SCRIPTS/hypr/waybarctl --restart"
}, },
{ {
"name": "Waybar -- toggle", "name": "Waybar - toggle",
"exec": "$SCRIPTS/hypr/waybarctl --toggle" "exec": "$SCRIPTS/hypr/waybarctl --toggle"
}, },
{ {
"name": "Windows - active window table / picker", "name": "Windows - window stats / picker",
"exec": "$SCRIPTS/hypr/window-table" "exec": "$SCRIPTS/hypr/window-table"
}, },
{ {

View File

@@ -219,6 +219,7 @@ source <(fzf --zsh)
# I tried sourcing them in the the `.zshenv` files, but did not work. # I tried sourcing them in the the `.zshenv` files, but did not work.
_source_if "$ZDOTDIR/.zshrc-local" _source_if "$ZDOTDIR/.zshrc-local"
_source_if "$LOCAL_ENV" _source_if "$LOCAL_ENV"
_source_if "$SCRIPTS/catppuccin-colors"
# pnpm # pnpm
export PNPM_HOME="$XDG_DATA_HOME/pnpm" export PNPM_HOME="$XDG_DATA_HOME/pnpm"

View File

@@ -31,4 +31,4 @@ export BASE="#1e1e2e"
export MANTLE="#181825" export MANTLE="#181825"
export CRUST="#11111b" 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" 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,preview-label:$TEAL:bold"

View File

@@ -1,12 +1,15 @@
#!/usr/bin/env bash #!/usr/bin/env bash
THIS_FILE=${BASH_SOURCE[0]}
THIS=$(basename "$THIS_FILE")
usage() { usage() {
cat <<EOF cat <<EOF
Close window(s) by address or pattern mode. Close window(s) by address or pattern mode.
USAGE: USAGE:
$ $(basename ${BASH_SOURCE[0]}) [OPTIONS] [MODE] [ARG...] $ $THIS [OPTIONS] [MODE] [ARG...]
MODE: MODE:
--all: Close all windows in all workspaces, any arguments are ignored. --all: Close all windows in all workspaces, any arguments are ignored.
@@ -41,6 +44,7 @@ dry_run_flag="0"
special_flag="0" special_flag="0"
args=() args=()
addresses=() addresses=()
SCRIPTS="${SCRIPTS:-$HOME/.local/scripts}"
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
if [[ $1 =~ ^-a ]] || [[ $1 =~ ^--active-workspace ]]; then if [[ $1 =~ ^-a ]] || [[ $1 =~ ^--active-workspace ]]; then
@@ -62,11 +66,7 @@ while [[ $# -gt 0 ]]; do
done done
log() { log() {
if [[ $dry_run_flag == "1" ]]; then logging log --source "$THIS_FILE" "$@"
echo "[DRY RUN]: $1"
else
echo "$1"
fi
} }
_select_addresses() { _select_addresses() {
@@ -92,10 +92,15 @@ get_special_addresses() {
close() { close() {
log "Closing window address: $1" log "Closing window address: $1"
if [[ $dry_run_flag == "0" ]]; then if [[ $dry_run_flag == "0" ]]; then
hyprctl dispatch closewindow "address:$1" hyprctl dispatch closewindow "address:$1" >/dev/null 2>&1
fi fi
} }
# Setup logging file and label
source "$SCRIPTS/hypr/logging"
setup-logging "/tmp/$THIS.log" "$THIS"
export LOG_ENABLE_DRY_RUN="$dry_run_flag"
if [[ $active_workspace_flag == "1" ]]; then if [[ $active_workspace_flag == "1" ]]; then
# Set addresses to active workspace windows. # Set addresses to active workspace windows.
id=$(hyprctl activeworkspace -j | jq -r '.id') id=$(hyprctl activeworkspace -j | jq -r '.id')
@@ -123,7 +128,7 @@ else
fi fi
if [[ ${#addresses} == 0 ]]; then if [[ ${#addresses} == 0 ]]; then
log "No windows found." log --warning "No windows found."
exit 0 exit 0
fi fi

View File

@@ -2,7 +2,8 @@
# Adapted from https://github.com/basecamp/omarchy/tree/master?tab=readme-ov-file # Adapted from https://github.com/basecamp/omarchy/tree/master?tab=readme-ov-file
THIS=$(basename ${BASH_SOURCE[0]}) THIS_FILE=${BASH_SOURCE[0]}
THIS=$(basename "$THIS_FILE")
function usage() { function usage() {
cat <<EOF cat <<EOF
@@ -88,21 +89,9 @@ launch_flag="0"
interactive_flag="0" # This is an internal flag, to not log some things when launch is used. interactive_flag="0" # This is an internal flag, to not log some things when launch is used.
interactive_mode=false interactive_mode=false
no_interactive_flag="0" no_interactive_flag="0"
SCRIPTS="${SCRIPTS}" SCRIPTS="${SCRIPTS:-$HOME/.local/scripts}"
XDG_DATA_HOME=${XDG_DATA_HOME} XDG_DATA_HOME=${XDG_DATA_HOME}
if [[ -z "$SCRIPTS" ]]; then
echo "SCRIPTS not set"
echo "using ~/.local/scripts"
SCRIPTS=$HOME/.local/scripts
fi
if [[ -z "$XDG_DATA_HOME" ]]; then
echo "XDG_DATA_HOME not set"
echo "using ~/.local/share"
XDG_DATA_HOME=$HOME/.local/share
fi
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
usage && exit 0 usage && exit 0
@@ -138,15 +127,7 @@ while [[ $# -gt 0 ]]; do
done done
log() { log() {
if [[ $dry_run == "1" ]]; then logging log --source "$THIS_FILE" "$@"
echo -e "\e[34m[DRY_RUN]=>\e[0m $1"
else
echo -e "$1"
fi
}
log_error() {
log "\e[31m[ERROR]:\e[0m $1"
} }
launch() { launch() {
@@ -164,7 +145,7 @@ check_properties() {
load_from_file() { load_from_file() {
if [[ ! -f $1 ]]; then if [[ ! -f $1 ]]; then
log_error "File '$1' is not found or readable." && exit 1 log --error "File '$1' is not found or readable." && exit 1
fi fi
file=$(cat $1) file=$(cat $1)
app_name=$(echo $file | jq -r '.name // ""') app_name=$(echo $file | jq -r '.name // ""')
@@ -213,7 +194,7 @@ set_icon_ref() {
if curl -sL -o "$icon_path" "$icon_ref"; then if curl -sL -o "$icon_path" "$icon_ref"; then
icon_path="$icon_dir/$app_name.png" icon_path="$icon_dir/$app_name.png"
else else
log_error "Failed to download icon." && exit 1 log --error "Failed to download icon." && exit 1
fi fi
fi fi
else else
@@ -254,6 +235,17 @@ EOF
# MAIN # MAIN
################################################################################ ################################################################################
# Setup logging file and label
source "$SCRIPTS/hypr/logging"
setup-logging "/tmp/$THIS.log" "$THIS"
export LOG_ENABLE_DRY_RUN="$dry_run"
if [[ -z "$XDG_DATA_HOME" ]]; then
log "XDG_DATA_HOME not set"
log "using ~/.local/share"
XDG_DATA_HOME=$HOME/.local/share
fi
if [[ $launch_flag == "1" ]]; then if [[ $launch_flag == "1" ]]; then
launch && exit 0 launch && exit 0
fi fi
@@ -268,7 +260,7 @@ if [[ "$?" == "1" ]]; then
# Check if the '--no-interactive' flag was passed and exit with error. # Check if the '--no-interactive' flag was passed and exit with error.
[[ $no_interactive_flag == "1" ]] && [[ $no_interactive_flag == "1" ]] &&
log_error "Required properties not set and '--no-interactive' flag was passed." && log --error "Required properties not set and '--no-interactive' flag was passed." &&
exit 1 exit 1
# Only log this if not in interactive mode. # Only log this if not in interactive mode.
@@ -281,7 +273,7 @@ if [[ "$?" == "1" ]]; then
check_properties check_properties
if [[ "$?" == "1" ]]; then if [[ "$?" == "1" ]]; then
# Exit if they were not set during interactive mode. # Exit if they were not set during interactive mode.
log_error "You must set app name, app URL, and icon URL!" && exit 1 log --error "You must set app name, app URL, and icon URL!" && exit 1
fi fi
# Set flag that we are in interactive mode. # Set flag that we are in interactive mode.

View File

@@ -1,5 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
THIS_FILE=${BASH_SOURCE[0]}
THIS=$(basename "$THIS_FILE")
usage() { usage() {
cat <<EOF cat <<EOF
@@ -10,7 +13,7 @@ This is used in keybinds and by other scripts as a general entrypoint for managi
USAGE: USAGE:
$ $(basename ${BASH_SOURCE[0]}) [OPTIONS] PATTERN [LAUNCH_CMD...] $ $THIS [OPTIONS] PATTERN [LAUNCH_CMD...]
OPTIONS: OPTIONS:
@@ -47,6 +50,7 @@ launch_cmd=()
pattern="" pattern=""
special_flag="0" special_flag="0"
special="" special=""
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
if [[ $1 == "-c" ]] || [[ $1 == "--or-close" ]]; then if [[ $1 == "-c" ]] || [[ $1 == "--or-close" ]]; then
@@ -77,17 +81,26 @@ while [[ $# -gt 0 ]]; do
shift shift
done done
log() {
logging log --source "$THIS_FILE" "$@"
}
# Redirects all output of hyprctl dispatch commands.
hypr_dispatch() {
hyprctl dispatch "$@" >/dev/null 2>&1
}
toggle_special() { toggle_special() {
if [[ -z $special ]]; then if [[ -z $special ]]; then
echo "[ERROR]: No name supplied for special workspace." log --error " No name supplied for special workspace."
exit 1 exit 1
fi fi
hyprctl dispatch togglespecialworkspace $special hypr_dispatch togglespecialworkspace $special
} }
launch_application() { launch_application() {
echo "Launching..." log "Launching..."
echo "'${launch_cmd[@]}'" log "'${launch_cmd[@]}'"
eval exec ${launch_cmd[@]} eval exec ${launch_cmd[@]}
} }
@@ -95,15 +108,19 @@ launch_application() {
# MAIN # MAIN
################################################################################ ################################################################################
# Setup logging file and label
source "$SCRIPTS/hypr/logging"
setup-logging "/tmp/$THIS.log" "$THIS"
if [[ -z $pattern ]]; then if [[ -z $pattern ]]; then
echo "[ERROR]: Must supply a pattern to match the window class." log --error "Must supply a pattern to match the window class."
usage && exit 1 usage && exit 1
elif [[ -z $launch_cmd ]]; then elif [[ -z $launch_cmd ]]; then
echo "[ERROR]: Must supply a launch command to match the window class." log --error "Must supply a launch command to match the window class."
usage && exit 1 usage && exit 1
fi fi
echo "Pattern: $pattern" log "Pattern: $pattern"
addresses=$(hyprctl clients -j | jq ".[] | select(.class | contains(\"$pattern\")) | .address") addresses=$(hyprctl clients -j | jq ".[] | select(.class | contains(\"$pattern\")) | .address")
# If no addresses, then launch the application. # If no addresses, then launch the application.
@@ -127,14 +144,14 @@ fi
# Check if both close and focus flags were passed, so we don't do the # Check if both close and focus flags were passed, so we don't do the
# wrong thing. # wrong thing.
if [[ $focus_flag == "1" ]] && [[ $close_flag == "1" ]]; then if [[ $focus_flag == "1" ]] && [[ $close_flag == "1" ]]; then
echo "[ERROR]: Both focus and close flag were passed." log --error "Both focus and close flag were passed."
exit 1 exit 1
fi fi
for address in ${addresses[@]}; do for address in ${addresses[@]}; do
# Clean the address of quotes. # Clean the address of quotes.
address=${address//\"/} address=${address//\"/}
echo "Handling address: '$address'" log "Handling address: '$address'"
if [[ $focus_active_only_flag == "1" ]] || [[ $close_active_only_flag == "1" ]]; then if [[ $focus_active_only_flag == "1" ]] || [[ $close_active_only_flag == "1" ]]; then
# get the workspace name for the address. # get the workspace name for the address.
@@ -142,19 +159,19 @@ for address in ${addresses[@]}; do
# check that the window is on the active workspace. # check that the window is on the active workspace.
if [[ $active_window_workspace == $workspace ]]; then if [[ $active_window_workspace == $workspace ]]; then
echo "Performing action: '$action', on window: '$address'" log "Performing action: '$action', on window: '$address'"
hyprctl dispatch $action "address:$address" hypr_dispatch $action "address:$address"
# early out if focusing a window. # early out if focusing a window.
[[ $focus_active_only_flag ]] && exit 0 [[ $focus_active_only_flag ]] && exit 0
else else
# the window is not on the active workspace, so skip it. # the window is not on the active workspace, so skip it.
echo "Skipping window: $address" log "Skipping window: $address"
fi fi
else else
# We don't have the focus_active_only_flag or close_active_only_flag set, so we perform # We don't have the focus_active_only_flag or close_active_only_flag set, so we perform
# the action on the window. # the action on the window.
echo "Performing action: '$action', on window: '$address'" log "Performing action: '$action', on window: '$address'"
hyprctl dispatch $action "address:$address" hypr_dispatch $action "address:$address"
fi fi
done done

View File

@@ -1,6 +1,8 @@
# /usr/bin/env bash #! /usr/bin/env bash
# Adapted from https://github.com/basecamp/omarchy/tree/master?tab=readme-ov-file # Adapted from https://github.com/basecamp/omarchy/tree/master?tab=readme-ov-file
THIS_FILE=${BASH_SOURCE[0]}
THIS=$(basename "$THIS_FILE")
usage() { usage() {
cat <<EOF cat <<EOF
@@ -10,7 +12,7 @@ essentially just generates the pattern and launch command to pass into that scri
USAGE: USAGE:
$ launch-webapp [OPTIONS] <url> [ARGS...] $ $THIS [OPTIONS] <url> [ARGS...]
OPTIONS: OPTIONS:
@@ -43,13 +45,7 @@ browser="chromium.desktop"
url="" url=""
launch_args=() launch_args=()
app_args="" app_args=""
SCRIPTS="${SCRIPTS}" SCRIPTS="${SCRIPTS:-$HOME/.local/scripts}"
if [[ -z $SCRIPTS ]]; then
echo "scripts directory not set"
echo "using ~/.local/scripts"
SCRIPTS=~/.local/scripts
fi
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
if [[ $1 =~ ^--special ]] || [[ $1 =~ ^-s ]]; then if [[ $1 =~ ^--special ]] || [[ $1 =~ ^-s ]]; then
@@ -77,20 +73,28 @@ pattern() {
echo $pattern echo $pattern
} }
log() {
logging log --source "$THIS_FILE" "$@"
}
################################################## ##################################################
# MAIN # MAIN
################################################## ##################################################
# setup logging file and label
source "$SCRIPTS/hypr/logging"
setup-logging "/tmp/$THIS.log" "$THIS"
if [[ -z $url ]]; then if [[ -z $url ]]; then
echo "[ERROR]: Must supply a url." && usage && exit 1 log --error "Must supply a url." && usage && exit 1
fi fi
# Any left over args after "--" # Any left over args after "--"
app_args="$@" app_args="$@"
echo "URL: $url" log "URL: $url"
echo "Launch args: ${launch_args[@]}" log "Launch args: ${launch_args[@]}"
echo "App args: ${app_args}" log "App args: ${app_args}"
$SCRIPTS/hypr/launch "${launch_args[@]}" "$(pattern)" \ $SCRIPTS/hypr/launch "${launch_args[@]}" "$(pattern)" \
setsid uwsm app -- $(sed -n 's/^Exec=\([^ ]*\).*/\1/p' {~/.local,~/.nix-profile,/usr}/share/applications/$browser 2>/dev/null | head -1) --app="$url" "$app_args" setsid uwsm app -- $(sed -n 's/^Exec=\([^ ]*\).*/\1/p' {~/.local,~/.nix-profile,/usr}/share/applications/$browser 2>/dev/null | head -1) --app="$url" "$app_args"

165
env/.local/scripts/hypr/logging vendored Executable file
View File

@@ -0,0 +1,165 @@
#!/usr/bin/env bash
# Basic logging utility functions that can be used by scripts to log
# to files. This helps keep console clean for TUI's. Will log
# messages to all registered files, which allows each script to
# declare their own logging file, but also print logs into parent
# processes files, for ease of discovery.
#
# Supports warning and error flags.
#
# Errors and warnings get logged to the file and to the console.
#
#
# EXAMPLE SETUP:
#
# source $SCRIPTS/hypr/logging
# THIS=$(basename ${BASH_SOURCE[0]})
#
# # Setup logging file and label.
# setup-logging "/tmp/$THIS.log" $THIS
#
# function log() {
# logging log --source ${BASH_SOURCE[0]} "$@"
# }
#
# log "My log message."
# log --warning "My warning message."
# log --error "My error message."
#
LOG_FILE=(${LOG_FILE:-})
LOG_INVOCATION_ID=${LOG_INVOCATION_ID:-}
LOG_LABEL=(${LOG_LABEL:-})
# Run in dry run mode, which just prints to the console and does
# not log to the files.
LOG_ENABLE_DRY_RUN=${LOG_ENABLE_DRY_RUN:-"0"}
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
warn_flag="0"
error_flag="0"
__msg() {
if [[ -z "$@" ]]; then
echo -e "\e[31m[ERROR]:\e[0m No logs were supplied."
exit 1
fi
if [[ $warn_flag == "1" ]]; then
echo -e "\e[33m[WARN]:\e[0m $@"
elif [[ $error_flag == "1" ]]; then
echo -e "\e[31m[ERROR]:\e[0m $@"
else
echo "$@"
fi
}
__ensure_setup() {
if [[ -z $LOG_FILE ]] || [[ -z $LOG_INVOCATION_ID ]] || [[ -z $LOG_LABEL ]]; then
echo -e "\e[31m[ERROR]:\e[0m Logging is not properly setup."
echo "Perhaps you didn't call 'setup-logging' first."
print_logger_env && exit 1
fi
}
logging() {
__ensure_setup
# Reset flags
log_flag="0"
warn_flag="0"
error_flag="0"
source_file=""
args=()
while [[ $# -gt 0 ]]; do
if [[ $1 == "-w" ]] || [[ $1 =~ ^--warn ]]; then
log_flag="1"
warn_flag="1"
elif [[ $1 == "-e" ]] || [[ $1 =~ ^--error ]]; then
log_flag="1"
error_flag="1"
elif [[ $1 == "-s" ]] || [[ $1 =~ ^--source ]]; then
shift
source_file="$1"
elif [[ $1 == "log" ]]; then
log_flag="1"
else
args+=("$1")
fi
shift
done
if [[ -z $source_file ]]; then
echo -e "\e[31m[ERROR]:\e[0m Must supply the source file the logs originate from."
exit 1
fi
if [[ -z $args ]]; then
echo -e "\e[31m[ERROR]:\e[0m No log message supplied."
exit 1
fi
msg="$(__msg ${args[@]})"
if [[ $LOG_ENABLE_DRY_RUN == "0" ]]; then
# Loop over log files logging message to each file.
for i in "${!LOG_FILE[@]}"; do
prefix="[id: $LOG_INVOCATION_ID][time: $($SCRIPTS/isosec)][label: ${LOG_LABEL[i]}][source: $source_file] : "
m="$prefix $msg"
echo -e "$m" >>${LOG_FILE[i]}
done
# Also log errors and warning messages to the console.
if [[ $error_flag == "1" ]] || [[ $warn_flag == "1" ]]; then
echo -e "[id: $LOG_INVOCATION_ID]: $msg"
fi
else
# Dry run mode, so just log to the console
echo -e "\e[34m[DRY RUN]:\e[0m $msg"
fi
}
setup-logging() {
label=""
file=""
if [[ "${#@}" == "1" ]]; then
file="/tmp/$1.log"
label="$1"
else
file="$1"
label="$2"
fi
if [[ -z "$file" ]]; then
echo -e "\e[31m[ERROR]:\e[0m Must supply a log file."
exit 1
fi
if [[ -z "$label" ]]; then
echo -e "\e[31m[ERROR]:\e[0m Must supply a logger label."
exit 1
fi
LOG_FILE+=("$file")
LOG_INVOCATION_ID=${LOG_INVOCATION_ID:-$RANDOM}
if [[ -n "$LOG_LABEL" ]]; then
LOG_LABEL+=("${LOG_LABEL[@]}=>$label")
else
LOG_LABEL+=("$label")
fi
export LOG_FILE
export LOG_LABEL
export LOG_INVOCATION_ID
}
print_logger_env() {
echo "LOG_FILE: ${LOG_FILE[@]}"
echo "LOG_INVOCATION_ID: $LOG_INVOCATION_ID"
echo "LOG_LABEL: ${LOG_LABEL[@]}"
}
export -f setup-logging
export -f logging
export -f print_logger_env

101
env/.local/scripts/hypr/monitor-picker vendored Executable file
View File

@@ -0,0 +1,101 @@
#!/usr/bin/env bash
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
THIS_FILE=${BASH_SOURCE[0]}
THIS=$(basename $THIS_FILE)
usage() {
cat <<EOF
Displays a monitor picker and stats preview. This script will accept any fzf options that you'd
like to pass. The id of the monitor is returned from this script upon selection.
USAGE:
$ $THIS [OPTIONS] [FZF_OPTIONS...]
OPTIONS:
--no-default-footer: Disable the 'Monitors' footer (supplying your own footer disables default as well).
--no-preview: Disables the monitor stats preview window.
-h | --help: Show this help page.
EOF
}
uses_supplied_footer="0"
no_preview_flag="0"
fzf_opts=("--style=full" "--delimiter=|" "--with-nth=2" "--preview-label=[ Monitor Stats ]")
rows=()
monitor_data=$(hyprctl monitors -j | jq 'sort_by(.id)')
while [[ $# -gt 0 ]]; do
if [[ $1 =~ ^--footer ]]; then
uses_supplied_footer="1"
fzf_opts+=("$1")
elif [[ $1 == "--no-preview" ]]; then
no_preview_flag="1"
elif [[ $1 == "--no-default-footer" ]]; then
uses_supplied_footer="1"
elif [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
usage && exit 0
else
fzf_opts+=("$1")
fi
shift
done
# Logging utility function, use in place of echo.
log() {
logging log --source "$THIS_FILE" "$@"
}
footer() {
cat <<'EOF'
__ ___ _ __
/ |/ /__ ___ (_) /____ _______
/ /|_/ / _ \/ _ \/ / __/ _ \/ __(_-<
/_/ /_/\___/_//_/_/\__/\___/_/ /___/
EOF
}
generate_rows() {
readarray -t ids <<<"$(echo "$monitor_data" | jq -r '.[] | .id')"
readarray -t names <<<"$(echo "$monitor_data" | jq -r '.[] | .name')"
# Zip into rows.
for i in "${!ids[@]}"; do
rows+=("${ids[i]}|${names[i]}")
done
}
################################################################################
# MAIN
################################################################################
# Setup logging file and label.
source "$SCRIPTS/hypr/logging"
setup-logging "$THIS"
[[ -z ${FZF_DEFAULT_OPTS} ]] &&
[[ -f $SCRIPTS/catppuccin-colors ]] &&
source $SCRIPTS/catppuccin-colors
if [[ $uses_supplied_footer == "0" ]]; then
fzf_opts+=("--footer=$(footer)")
fi
generate_rows
sel=""
# For some reason can't get the preview to work when setting in the fzf_opts array.
if [[ $no_preview_flag == "0" ]]; then
sel=$(printf '%s\n' "${rows[@]}" | fzf "${fzf_opts[@]}" --preview="$SCRIPTS/hypr/preview-stats monitor {1}")
else
sel=$(printf '%s\n' "${rows[@]}" | fzf "${fzf_opts[@]}")
fi
# revove everything but the id portion.
sel=${sel%%|*}
echo "$sel"

56
env/.local/scripts/hypr/preview-stats vendored Executable file
View File

@@ -0,0 +1,56 @@
#!/usr/bin/env bash
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
THIS_FILE=${BASH_SOURCE[0]}
THIS=$(basename $THIS_FILE)
usage() {
cat <<EOF
Utility for getting fzf preview data.
USAGE:
$ $THIS <mode> <arg>
MODES:
monitor: Get monitor data, arg is the monitor id.
window: Get window data, arg is the window address.
workspace: Get workspace data, arg is the workspace id.
EOF
}
# Logging utility function, use in place of echo.
log() {
logging log --source "$THIS_FILE" "$@"
}
################################################################################
# MAIN
################################################################################
# Setup logging file and label.
source "$SCRIPTS/hypr/logging"
setup-logging "$THIS"
if [[ ! "${#@}" == "2" ]]; then
log --error "Unexpected argument count: ${#@}, expected: 2"
usage && exit 1
fi
mode="$1"
# Remove single quotes from the arg.
arg="${2//\'/}"
if [[ $mode == "monitor" ]]; then
hyprctl monitors -j | jq -C ".[] | select(.id == $arg)"
elif [[ $mode == "window" ]]; then
hyprctl clients -j | jq -C ".[] | select(.address == \"$arg\")"
elif [[ $mode == "workspace" ]]; then
hyprctl workspaces -j | jq -C ".[] | select(.id == $arg)"
else
log --error "Unexpected mode: $mode"
usage && exit 1
fi

View File

@@ -1,5 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
THIS_FILE=${BASH_SOURCE[0]}
THIS=$(basename "$THIS_FILE")
usage() { usage() {
cat <<EOF cat <<EOF
@@ -12,7 +15,7 @@ the workspace.
USAGE: USAGE:
$ $(basename ${BASH_SOURCE[0]}) [OPTIONS] <workspace> $ $THIS [OPTIONS] <workspace>
OPTIONS: OPTIONS:
@@ -23,6 +26,7 @@ EOF
target_workspace="" target_workspace=""
active_workspace=$(hyprctl activewindow -j | jq -r '.workspace.name') active_workspace=$(hyprctl activewindow -j | jq -r '.workspace.name')
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
if [[ $1 =~ ^-h ]] || [[ $1 =~ ^--help ]]; then if [[ $1 =~ ^-h ]] || [[ $1 =~ ^--help ]]; then
@@ -33,15 +37,22 @@ while [[ $# -gt 0 ]]; do
shift shift
done done
log() {
logging log --source "$THIS_FILE" "$@"
}
source "$SCRIPTS/hypr/logging"
setup-logging "/tmp/$THIS.log" "$THIS"
if [[ -z target_workspace ]]; then if [[ -z target_workspace ]]; then
echo "[ERROR]: Must supply a workpsace to switch to." log --error "Must supply a workpsace to switch to."
usage && exit 1 usage && exit 1
fi fi
# If active window is on a special workspace, then toggle the special workspace off. # If active window is on a special workspace, then toggle the special workspace off.
if [[ $active_workspace =~ ^special ]]; then if [[ $active_workspace =~ ^special ]]; then
echo "Toggling special workspace: '$active_workspace'" log "Toggling special workspace: '$active_workspace'"
hyprctl dispatch togglespecialworkspace ${active_workspace#special:} hyprctl dispatch togglespecialworkspace ${active_workspace#special:} >/dev/null 2>&1
# Only toggle the special workspace if trying to switch to previous and we're currently # Only toggle the special workspace if trying to switch to previous and we're currently
# on a special workspace. # on a special workspace.
@@ -50,5 +61,5 @@ if [[ $active_workspace =~ ^special ]]; then
fi fi
fi fi
echo "Switching to workspace: $target_workspace" log "Switching to workspace: $target_workspace"
hyprctl dispatch workspace $target_workspace hyprctl dispatch workspace $target_workspace >/dev/null 2>&1

View File

@@ -1,10 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Uninstalls '.desktop' applications, including their icon. THIS_FILE=${BASH_SOURCE[0]}
# THIS=$(basename "$THIS_FILE")
# This is primarily used for uninstalling web app's, if a
# desktop app was installed via the package manager, then the
# package manager should be used to uninstall the application.
usage() { usage() {
cat <<EOF cat <<EOF
@@ -15,11 +12,12 @@ package manager, then it should be used to uninstall the application.
Usage: Usage:
uninstall-desktop-app [OPTIONS] [FILE...] $ $THIS [OPTIONS] [FILE...]
OPTIONS: OPTIONS:
--dry-run: Perform but don't actually remove anything.
-h | --help: Show the help page. --dry-run: Perform but don't actually remove anything.
-h | --help: Show the help page.
If no files are supplied, then an interactive session will be If no files are supplied, then an interactive session will be
started that allows you to choose the applications to remove. started that allows you to choose the applications to remove.
@@ -32,27 +30,31 @@ interactive_mode="0"
dry_run="0" dry_run="0"
help_flag="0" help_flag="0"
XDG_DATA_HOME=${XDG_DATA_HOME} XDG_DATA_HOME=${XDG_DATA_HOME}
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
if [[ $1 =~ ^--dry ]]; then if [[ $1 =~ ^--dry ]]; then
dry_run="1" dry_run="1"
elif [[ $1 =~ ^-h ]] || [[ $1 =~ ^--h ]]; then elif [[ $1 =~ ^-h ]] || [[ $1 =~ ^--h ]]; then
help_flag="1" usage && exit 0
else else
files+=("$1") files+=("$1")
fi fi
shift shift
done done
# Early out for help option. log() {
if [[ $help_flag == "1" ]]; then logging log --source "$THIS_FILE" "$@"
usage }
exit 0
fi ############################## MAIN ##############################
source "$SCRIPTS/hypr/logging"
setup-logging "/tmp/$THIS.log" "$THIS"
if [[ -z $XDG_DATA_HOME ]]; then if [[ -z $XDG_DATA_HOME ]]; then
echo "xdg data home is not set" log "xdg data home is not set"
echo "using: ~/.local/share" log "using: ~/.local/share"
XDG_DATA_HOME=$HOME/.local/share XDG_DATA_HOME=$HOME/.local/share
fi fi
@@ -65,16 +67,6 @@ if [[ ${#files} == 0 ]]; then
) )
fi fi
log() {
if [[ $dry_run == "1" ]]; then
echo "[DRY RUN]: $1"
else
echo "$1"
fi
}
############################## MAIN ##############################
for f in ${files[@]}; do for f in ${files[@]}; do
icon="" icon=""

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
THIS=$(basename ${BASH_SOURCE[0]}) THIS_FILE=${BASH_SOURCE[0]}
THIS=$(basename $THIS_FILE)
usage() { usage() {
cat <<EOF cat <<EOF
@@ -25,6 +26,8 @@ window_padding_x="2"
config_file="" config_file=""
launch_flag="0" launch_flag="0"
rows=()
invocation_id=${RANDOM}
XDG_CONFIG_HOME=${XDG_CONFIG_HOME} XDG_CONFIG_HOME=${XDG_CONFIG_HOME}
SCRIPTS=${SCRIPTS} SCRIPTS=${SCRIPTS}
@@ -38,11 +41,9 @@ while [[ $# -gt 0 ]]; do
shift shift
done done
if [[ -z $XDG_CONFIG_HOME ]]; then log() {
echo "XDG_CONFIG_HOME not set" logging log --source "$THIS_FILE" "$@"
echo "using ~/.config" }
XDG_CONFIG_HOME=$HOME/.config
fi
launch() { launch() {
ghostty --class=$window_class --window-padding-x=$window_padding_x \ ghostty --class=$window_class --window-padding-x=$window_padding_x \
@@ -61,19 +62,38 @@ footer() {
EOF EOF
} }
generate_rows() {
readarray -t names <<<"$(echo "$1" | jq -r '.[] | .name')"
readarray -t execs <<<"$(echo "$1" | jq -r '.[] | .exec')"
for i in "${!names[@]}"; do
rows+=("${execs[i]}|${names[i]}")
done
}
################################################################################ ################################################################################
# MAIN # MAIN
################################################################################ ################################################################################
# Setup logging file and label.
source "$SCRIPTS/hypr/logging"
setup-logging "/tmp/$THIS.log" "$THIS"
if [[ -z $XDG_CONFIG_HOME ]]; then
log "XDG_CONFIG_HOME not set"
log "using ~/.config"
XDG_CONFIG_HOME=$HOME/.config
fi
if [[ -z $config_file ]]; then if [[ -z $config_file ]]; then
echo "No config file set." log "No config file set."
echo "Using ~/.config/utils-launcher/config.json" log "Using ~/.config/utils-launcher/config.json"
config_file="$XDG_CONFIG_HOME/utils-launcher/config.json" config_file="$XDG_CONFIG_HOME/utils-launcher/config.json"
fi fi
if [[ -z $SCRIPTS ]]; then if [[ -z $SCRIPTS ]]; then
echo "SCRIPTS not set" log "SCRIPTS not set"
echo "using ~/.local/scripts" log "using ~/.local/scripts"
SCRIPTS=$HOME/.local/scripts SCRIPTS=$HOME/.local/scripts
fi fi
@@ -82,26 +102,33 @@ if [[ $launch_flag == "1" ]]; then
fi fi
if [[ ! -f $config_file ]]; then if [[ ! -f $config_file ]]; then
echo "[ERROR]: no config file set" && exit 1 log "[ERROR]: no config file set" && exit 1
fi fi
file_data=$(cat $config_file) file_data=$(cat $config_file)
# Setup colors before calling fzf. # Setup colors before calling fzf.
[[ -f $SCRIPTS/catppuccin-colors ]] && source $SCRIPTS/catppuccin-colors [[ -f $SCRIPTS/catppuccin-colors ]] && source $SCRIPTS/catppuccin-colors
sel=$(echo "$file_data" | jq -r '.[] | .name' | fzf --style=full --footer="$(footer)")
echo "Selection: $sel" generate_rows "$file_data"
sel=$(
printf "%s\n" "${rows[@]}" |
fzf --style=full --footer="$(footer)" --with-nth=2 --delimiter='|' \
--preview-label='[ Command ]' \
--preview='printf "\nName: {2}\nExec: {1}"'
)
log "Selection: $sel"
if [[ -n "$sel" ]]; then if [[ -n "$sel" ]]; then
# Load the exec command for the selection. # Parse the exec command for the selection.
exec_cmd=$(echo $file_data | jq -r ".[] | select(.name == \"$sel\") | .exec") exec_cmd=${sel%%|*}
echo "Exec: '$exec_cmd'" log "Exec: '$exec_cmd'"
if [[ -z $exec_cmd ]]; then if [[ -z $exec_cmd ]]; then
echo "[ERROR]: Command is empty." && exit 1 log "[ERROR]: Command is empty." && exit 1
fi fi
eval exec uwsm app -- "$exec_cmd" eval exec uwsm app -- "$exec_cmd"
else else
echo "No selection." log "No selection."
fi fi

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
THIS=$(basename ${BASH_SOURCE[0]}) THIS_FILE=${BASH_SOURCE[0]}
THIS=$(basename $THIS_FILE)
usage() { usage() {
cat <<EOF cat <<EOF

View File

@@ -24,7 +24,7 @@ uses_supplied_footer="0"
fzf_opts=() fzf_opts=()
rows=() rows=()
window_data=$(hyprctl clients -j | jq 'sort_by(.workspace.id)') window_data=$(hyprctl clients -j | jq 'sort_by(.workspace.id)')
SCRIPTS=${SCRIPTS} SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
if [[ $1 =~ ^--footer ]]; then if [[ $1 =~ ^--footer ]]; then
@@ -36,10 +36,6 @@ while [[ $# -gt 0 ]]; do
shift shift
done done
if [[ -z $SCRIPTS ]]; then
SCRIPTS=$HOME/.local/scripts
fi
footer() { footer() {
cat <<'EOF' cat <<'EOF'
_ ___ __ _ ___ __
@@ -52,13 +48,11 @@ EOF
generate_rows() { generate_rows() {
readarray -t addresses <<<"$(echo "$window_data" | jq -r '.[] | .address')" readarray -t addresses <<<"$(echo "$window_data" | jq -r '.[] | .address')"
readarray -t classes <<<$(echo "$window_data" | jq -r '.[] | .class')
readarray -t titles <<<$(echo "$window_data" | jq -r '.[] | .title') readarray -t titles <<<$(echo "$window_data" | jq -r '.[] | .title')
readarray -t workspaces <<<$(echo "$window_data" | jq -r '.[] | .workspace.name')
# Zip into rows. # Zip into rows.
for i in "${!addresses[@]}"; do for i in "${!addresses[@]}"; do
rows+=("${workspaces[i]}=>${titles[i]}=>${classes[i]}=>${addresses[i]}") rows+=("${addresses[i]}|${titles[i]}")
done done
} }
@@ -79,15 +73,12 @@ generate_rows
sel=$( sel=$(
printf '%s\n' "${rows[@]}" | printf '%s\n' "${rows[@]}" |
fzf --style=full "${fzf_opts[@]}" \ fzf --style=full "${fzf_opts[@]}" \
--preview-label='[ Window Stats ]' --delimiter='=>' --with-nth=2 \ --preview-label='[ Window Stats ]' --delimiter='|' --with-nth=2 \
--preview='echo -e "Title: {2}\nClass: {3}\nWorkspace: {1}\nAddress: {4}"' --preview="$SCRIPTS/hypr/preview-stats window {1}"
) )
[[ -z $sel ]] && exit 1 [[ -z $sel ]] && exit 1
# remove spaces and quotes from result.
sel=${sel//\"/}
sel=${sel// /}
# revove everything but the address portion. # revove everything but the address portion.
sel=${sel##*=>} sel=${sel%%|*}
echo "$sel" echo "$sel"

View File

@@ -1,5 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
THIS_FILE=${BASH_SOURCE[0]}
THIS=$(basename $THIS_FILE)
usage() { usage() {
cat <<EOF cat <<EOF
@@ -9,7 +12,7 @@ There are no required options for this script to work.
USAGE: USAGE:
$ $(basename ${BASH_SOURCE[0]}) [OPTIONS] $ $THIS [OPTIONS]
OPTIONS: OPTIONS:
@@ -50,7 +53,7 @@ show_window_class_flag="0"
launch_args=() launch_args=()
selected_value="" selected_value=""
SCRIPTS=${SCRIPTS} SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
if [[ $launch_flag == "1" ]]; then if [[ $launch_flag == "1" ]]; then
@@ -93,6 +96,10 @@ action_footer() {
EOF EOF
} }
log() {
logging log --source "$THIS_FILE" "$@"
}
show_table_return_choice() { show_table_return_choice() {
local opts=() local opts=()
if [[ $show_window_class_flag == "1" ]]; then if [[ $show_window_class_flag == "1" ]]; then
@@ -115,7 +122,7 @@ ask_what_to_do_with_selection() {
printf "%s\n" "${choices[@]}" | printf "%s\n" "${choices[@]}" |
fzf --style=full --footer="$(action_footer)" --header="What should we do with the selected window?" fzf --style=full --footer="$(action_footer)" --header="What should we do with the selected window?"
) )
echo "Choice: $choice" log "Choice: $choice"
if [[ $choice == "Quit" ]]; then if [[ $choice == "Quit" ]]; then
exit 0 exit 0
elif [[ $choice == "Close window" ]]; then elif [[ $choice == "Close window" ]]; then
@@ -135,6 +142,12 @@ ask_what_to_do_with_selection() {
fi fi
} }
# Prevent hyprctl dispatch calls from printing to the console.
hypr_dispatch() {
hyprctl dispatch "$@" >/dev/null 2>&1
return $?
}
move_to_workspace() { move_to_workspace() {
local workspace_id="" local workspace_id=""
@@ -146,7 +159,7 @@ move_to_workspace() {
fi fi
if [[ -z $move_to_workspace_name ]]; then if [[ -z $move_to_workspace_name ]]; then
echo "[ERROR]: No workspace set to move window to." log --error "No workspace set to move window to."
exit 1 exit 1
fi fi
@@ -158,7 +171,7 @@ move_to_workspace() {
fi fi
if [[ -z $workspace_id ]]; then if [[ -z $workspace_id ]]; then
echo "[ERROR]: No workspace id found for: '$move_to_workspace_name'" log --error "No workspace id found for: '$move_to_workspace_name'"
exit 1 exit 1
fi fi
@@ -167,37 +180,41 @@ move_to_workspace() {
action="movetoworkspacesilent" action="movetoworkspacesilent"
fi fi
echo "Moving window: '$selected_value' to workspace: '$workspace_id'" log "Moving window: '$selected_value' to workspace: '$workspace_id'"
hyprctl dispatch $action "$workspace_id,address:$selected_value" hypr_dispatch $action "$workspace_id,address:$selected_value"
} }
handle_selected_value() { handle_selected_value() {
if [[ $ignore_flag == "1" ]]; then if [[ $ignore_flag == "1" ]]; then
echo "Ignore flag set, selection: '$selected_value'" log "Ignore flag set, selection: '$selected_value'"
exit 0 exit 0
elif [[ $clipboard_flag == "1" ]]; then elif [[ $clipboard_flag == "1" ]]; then
echo "Copying to clipboard, selection: $selected_value" log "Copying to clipboard, selection: $selected_value"
wl-copy $selected_value wl-copy $selected_value
exit 0 exit 0
elif [[ $focus_flag == "1" ]]; then elif [[ $focus_flag == "1" ]]; then
echo "Focusing window, selection: $selected_value" log "Focusing window, selection: $selected_value"
hyprctl dispatch focuswindow "address:$selected_value" hypr_dispatch focuswindow "address:$selected_value"
exit 0 exit 0
elif [[ $close_flag == "1" ]]; then elif [[ $close_flag == "1" ]]; then
echo "Closing window, selection: $selected_value" log "Closing window, selection: $selected_value"
hyprctl dispatch closewindow "address:$selected_value" hypr_dispatch closewindow "address:$selected_value"
exit 0 exit 0
elif [[ $move_flag == "1" ]] || [[ $move_silent_flag == "1" ]]; then elif [[ $move_flag == "1" ]] || [[ $move_silent_flag == "1" ]]; then
move_to_workspace && exit 0 move_to_workspace && exit 0
fi fi
# TODO: Choose from list of what to do with the selected_value. # TODO: Choose from list of what to do with the selected_value.
echo "No flag set, selection: '$selected_value'" log "No flag set, selection: '$selected_value'"
} }
################################################## ##################################################
# MAIN # MAIN
################################################## ##################################################
# Setup logging file and label.
source "$SCRIPTS/hypr/logging"
setup-logging "/tmp/$THIS.log" "$THIS"
if [[ $launch_flag == "1" ]]; then if [[ $launch_flag == "1" ]]; then
ghostty --class="$window_class" --window-padding-x="$window_padding_x" \ ghostty --class="$window_class" --window-padding-x="$window_padding_x" \
--keybind="ctrl+c=quit" \ --keybind="ctrl+c=quit" \
@@ -214,11 +231,11 @@ else
handle_selected_value handle_selected_value
# If we got here then no flag was passed in initially on how to handle the # If we got here then no flag was passed in initially on how to handle the
# selected window, so ask what they'd like to do. Then handle it. # selected window, so ask what they'd like to do. Then handle it.
echo "Asking what to do with selction." log "Asking what to do with selction."
ask_what_to_do_with_selection ask_what_to_do_with_selection
[[ -n $selected_value ]] && handle_selected_value [[ -n $selected_value ]] && handle_selected_value
# If you make it here, We just give up... Don't start an endless loop. # If you make it here, We just give up... Don't start an endless loop.
echo "Giving up without a selection." log "Giving up without a selection."
fi fi
fi fi

View File

@@ -69,11 +69,9 @@ EOF
generate_rows() { generate_rows() {
readarray -t names <<<"$(echo "$workspaces" | jq -r '.[] | .name')" readarray -t names <<<"$(echo "$workspaces" | jq -r '.[] | .name')"
readarray -t ids <<<"$(echo "$workspaces" | jq -r '.[] | .id')" readarray -t ids <<<"$(echo "$workspaces" | jq -r '.[] | .id')"
readarray -t monitors <<<"$(echo "$workspaces" | jq -r '.[] | .monitor')"
readarray -t windows <<<"$(echo "$workspaces" | jq -r '.[] | .windows')"
for i in "${!names[@]}"; do for i in "${!names[@]}"; do
rows+=("${ids[i]}|${monitors[i]}|${windows[i]}|${names[i]}") rows+=("${ids[i]}|${names[i]}")
done done
} }
@@ -93,9 +91,9 @@ fi
sel=$( sel=$(
printf "%s\n" "${rows[@]}" | printf "%s\n" "${rows[@]}" |
fzf --style=full "${fzf_opts[@]}" \ fzf --style=full "${fzf_opts[@]}" --delimiter='|' --with-nth=2 \
--delimiter='|' --with-nth=4 --preview-label='[ Workspace Stats ]' \ --preview-label='[ Workspace Stats ]' \
--preview='printf "Name: {4}\nID: {1}\nWindows: {2}\nMonitor: {3}"' --preview="$SCRIPTS/hypr/preview-stats workspace {1}"
) )
[[ -z $sel ]] && exit 1 [[ -z $sel ]] && exit 1

49
gen
View File

@@ -40,29 +40,30 @@ generate_run() {
local dest="$DEV_ENV/runs/$file" local dest="$DEV_ENV/runs/$file"
fail_if_exists $dest fail_if_exists $dest
log "Creating new run: $dest" log "Creating new run: $dest"
printf "#!/usr/bin/env bash\n\n" >$dest cat >"$dest" <<'EOF'
printf "yay \${1:-\"-S --noconfirm\"} # packages\n" >>$dest #!/usr/bin/env bash
yay ${1:-"-S --noconfirm"} # packages
EOF
chmod +x $dest chmod +x $dest
} }
generate_webapp() { generate_webapp() {
local dest="$DEV_ENV/env/webapps/$file" local dest="$DEV_ENV/env/webapps/$file"
# Check that the destination ends with '.json', fix if not.
if [[ ! $dest =~ \.json$ ]]; then if [[ ! $dest =~ \.json$ ]]; then
dest="$dest.json" dest="$dest.json"
fi fi
fail_if_exists $dest fail_if_exists $dest
log "Creating new webapp: $dest" log "Creating new webapp: $dest"
cat >"$dest" <<'EOF'
printf "{\n" >$dest {
printf " \"name\": \"My App\",\n" >>$dest "name": "My App",
printf " \"url\": \"https://example.com\",\n" >>$dest "url": "https://example.com",
printf " \"icon\": \"https://icon.com\"\n" >>$dest "icon": "https://icon.com"
printf "}" >>$dest }
EOF
} }
@@ -70,7 +71,29 @@ generate_script() {
local dest="$DEV_ENV/env/.local/scripts/$file" local dest="$DEV_ENV/env/.local/scripts/$file"
fail_if_exists $dest fail_if_exists $dest
log "Creating new script: $dest" log "Creating new script: $dest"
printf "#!/usr/bin/env bash\n\n" >$dest cat >"$dest" <<'EOF'
#!/usr/bin/env bash
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
THIS_FILE=${BASH_SOURCE[0]}
THIS=$(basename $THIS_FILE)
# Logging utility function, use in place of echo.
log() {
logging log --source "$THIS_FILE" "$@"
}
################################################################################
# MAIN
################################################################################
# Setup logging file and label.
source "$SCRIPTS/hypr/logging"
setup-logging "$THIS"
log "Starting $THIS..."
EOF
chmod +x $dest chmod +x $dest
echo $dest echo $dest
} }