mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-16 23:22:37 +00:00
Compare commits
7 Commits
6d6f24467f
...
a4a560eb3d
| Author | SHA1 | Date | |
|---|---|---|---|
|
a4a560eb3d
|
|||
|
a7e6bc893c
|
|||
|
90c97263cb
|
|||
|
dccb1ca0a3
|
|||
|
f729bedc99
|
|||
|
4edf92e034
|
|||
|
5e8fbbcbab
|
10
env/.config/hypr/windows.conf
vendored
10
env/.config/hypr/windows.conf
vendored
@@ -17,14 +17,18 @@ 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)$
|
||||
# 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.*
|
||||
|
||||
# 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.
|
||||
windowrule = tag +floating-window, class:.*clipse.*
|
||||
|
||||
8
env/.config/utils-launcher/config.json
vendored
8
env/.config/utils-launcher/config.json
vendored
@@ -11,16 +11,20 @@
|
||||
"name": "Clipboard - clear history",
|
||||
"exec": "$SCRIPTS/hypr/clear-clipboard-history && echo Done"
|
||||
},
|
||||
{
|
||||
"name": "Monitors - stats / picker",
|
||||
"exec": "$SCRIPTS/hypr/monitor-picker"
|
||||
},
|
||||
{
|
||||
"name": "Waybar - restart",
|
||||
"exec": "$SCRIPTS/hypr/waybarctl --restart"
|
||||
},
|
||||
{
|
||||
"name": "Waybar -- toggle",
|
||||
"name": "Waybar - toggle",
|
||||
"exec": "$SCRIPTS/hypr/waybarctl --toggle"
|
||||
},
|
||||
{
|
||||
"name": "Windows - active window table / picker",
|
||||
"name": "Windows - window stats / picker",
|
||||
"exec": "$SCRIPTS/hypr/window-table"
|
||||
},
|
||||
{
|
||||
|
||||
1
env/.config/zsh/.zshrc
vendored
1
env/.config/zsh/.zshrc
vendored
@@ -219,6 +219,7 @@ source <(fzf --zsh)
|
||||
# I tried sourcing them in the the `.zshenv` files, but did not work.
|
||||
_source_if "$ZDOTDIR/.zshrc-local"
|
||||
_source_if "$LOCAL_ENV"
|
||||
_source_if "$SCRIPTS/catppuccin-colors"
|
||||
|
||||
# pnpm
|
||||
export PNPM_HOME="$XDG_DATA_HOME/pnpm"
|
||||
|
||||
2
env/.local/scripts/catppuccin-colors
vendored
2
env/.local/scripts/catppuccin-colors
vendored
@@ -31,4 +31,4 @@ 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"
|
||||
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"
|
||||
|
||||
21
env/.local/scripts/hypr/close-windows
vendored
21
env/.local/scripts/hypr/close-windows
vendored
@@ -1,12 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
THIS_FILE=${BASH_SOURCE[0]}
|
||||
THIS=$(basename "$THIS_FILE")
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
|
||||
Close window(s) by address or pattern mode.
|
||||
|
||||
USAGE:
|
||||
$ $(basename ${BASH_SOURCE[0]}) [OPTIONS] [MODE] [ARG...]
|
||||
$ $THIS [OPTIONS] [MODE] [ARG...]
|
||||
|
||||
MODE:
|
||||
--all: Close all windows in all workspaces, any arguments are ignored.
|
||||
@@ -41,6 +44,7 @@ dry_run_flag="0"
|
||||
special_flag="0"
|
||||
args=()
|
||||
addresses=()
|
||||
SCRIPTS="${SCRIPTS:-$HOME/.local/scripts}"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ $1 =~ ^-a ]] || [[ $1 =~ ^--active-workspace ]]; then
|
||||
@@ -62,11 +66,7 @@ while [[ $# -gt 0 ]]; do
|
||||
done
|
||||
|
||||
log() {
|
||||
if [[ $dry_run_flag == "1" ]]; then
|
||||
echo "[DRY RUN]: $1"
|
||||
else
|
||||
echo "$1"
|
||||
fi
|
||||
logging log --source "$THIS_FILE" "$@"
|
||||
}
|
||||
|
||||
_select_addresses() {
|
||||
@@ -92,10 +92,15 @@ get_special_addresses() {
|
||||
close() {
|
||||
log "Closing window address: $1"
|
||||
if [[ $dry_run_flag == "0" ]]; then
|
||||
hyprctl dispatch closewindow "address:$1"
|
||||
hyprctl dispatch closewindow "address:$1" >/dev/null 2>&1
|
||||
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
|
||||
# Set addresses to active workspace windows.
|
||||
id=$(hyprctl activeworkspace -j | jq -r '.id')
|
||||
@@ -123,7 +128,7 @@ else
|
||||
fi
|
||||
|
||||
if [[ ${#addresses} == 0 ]]; then
|
||||
log "No windows found."
|
||||
log --warning "No windows found."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
46
env/.local/scripts/hypr/install-webapp
vendored
46
env/.local/scripts/hypr/install-webapp
vendored
@@ -2,7 +2,8 @@
|
||||
|
||||
# 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() {
|
||||
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_mode=false
|
||||
no_interactive_flag="0"
|
||||
SCRIPTS="${SCRIPTS}"
|
||||
SCRIPTS="${SCRIPTS:-$HOME/.local/scripts}"
|
||||
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
|
||||
if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
|
||||
usage && exit 0
|
||||
@@ -138,15 +127,7 @@ while [[ $# -gt 0 ]]; do
|
||||
done
|
||||
|
||||
log() {
|
||||
if [[ $dry_run == "1" ]]; then
|
||||
echo -e "\e[34m[DRY_RUN]=>\e[0m $1"
|
||||
else
|
||||
echo -e "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
log_error() {
|
||||
log "\e[31m[ERROR]:\e[0m $1"
|
||||
logging log --source "$THIS_FILE" "$@"
|
||||
}
|
||||
|
||||
launch() {
|
||||
@@ -164,7 +145,7 @@ check_properties() {
|
||||
|
||||
load_from_file() {
|
||||
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
|
||||
file=$(cat $1)
|
||||
app_name=$(echo $file | jq -r '.name // ""')
|
||||
@@ -213,7 +194,7 @@ set_icon_ref() {
|
||||
if curl -sL -o "$icon_path" "$icon_ref"; then
|
||||
icon_path="$icon_dir/$app_name.png"
|
||||
else
|
||||
log_error "Failed to download icon." && exit 1
|
||||
log --error "Failed to download icon." && exit 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
@@ -254,6 +235,17 @@ EOF
|
||||
# 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
|
||||
launch && exit 0
|
||||
fi
|
||||
@@ -268,7 +260,7 @@ if [[ "$?" == "1" ]]; then
|
||||
|
||||
# Check if the '--no-interactive' flag was passed and exit with error.
|
||||
[[ $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
|
||||
|
||||
# Only log this if not in interactive mode.
|
||||
@@ -281,7 +273,7 @@ if [[ "$?" == "1" ]]; then
|
||||
check_properties
|
||||
if [[ "$?" == "1" ]]; then
|
||||
# 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
|
||||
|
||||
# Set flag that we are in interactive mode.
|
||||
|
||||
47
env/.local/scripts/hypr/launch
vendored
47
env/.local/scripts/hypr/launch
vendored
@@ -1,5 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
THIS_FILE=${BASH_SOURCE[0]}
|
||||
THIS=$(basename "$THIS_FILE")
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
|
||||
@@ -10,7 +13,7 @@ This is used in keybinds and by other scripts as a general entrypoint for managi
|
||||
|
||||
USAGE:
|
||||
|
||||
$ $(basename ${BASH_SOURCE[0]}) [OPTIONS] PATTERN [LAUNCH_CMD...]
|
||||
$ $THIS [OPTIONS] PATTERN [LAUNCH_CMD...]
|
||||
|
||||
OPTIONS:
|
||||
|
||||
@@ -47,6 +50,7 @@ launch_cmd=()
|
||||
pattern=""
|
||||
special_flag="0"
|
||||
special=""
|
||||
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ $1 == "-c" ]] || [[ $1 == "--or-close" ]]; then
|
||||
@@ -77,17 +81,26 @@ while [[ $# -gt 0 ]]; do
|
||||
shift
|
||||
done
|
||||
|
||||
log() {
|
||||
logging log --source "$THIS_FILE" "$@"
|
||||
}
|
||||
|
||||
# Redirects all output of hyprctl dispatch commands.
|
||||
hypr_dispatch() {
|
||||
hyprctl dispatch "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
toggle_special() {
|
||||
if [[ -z $special ]]; then
|
||||
echo "[ERROR]: No name supplied for special workspace."
|
||||
log --error " No name supplied for special workspace."
|
||||
exit 1
|
||||
fi
|
||||
hyprctl dispatch togglespecialworkspace $special
|
||||
hypr_dispatch togglespecialworkspace $special
|
||||
}
|
||||
|
||||
launch_application() {
|
||||
echo "Launching..."
|
||||
echo "'${launch_cmd[@]}'"
|
||||
log "Launching..."
|
||||
log "'${launch_cmd[@]}'"
|
||||
eval exec ${launch_cmd[@]}
|
||||
}
|
||||
|
||||
@@ -95,15 +108,19 @@ launch_application() {
|
||||
# MAIN
|
||||
################################################################################
|
||||
|
||||
# Setup logging file and label
|
||||
source "$SCRIPTS/hypr/logging"
|
||||
setup-logging "/tmp/$THIS.log" "$THIS"
|
||||
|
||||
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
|
||||
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
|
||||
fi
|
||||
|
||||
echo "Pattern: $pattern"
|
||||
log "Pattern: $pattern"
|
||||
addresses=$(hyprctl clients -j | jq ".[] | select(.class | contains(\"$pattern\")) | .address")
|
||||
|
||||
# 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
|
||||
# wrong thing.
|
||||
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
|
||||
fi
|
||||
|
||||
for address in ${addresses[@]}; do
|
||||
# Clean the address of quotes.
|
||||
address=${address//\"/}
|
||||
echo "Handling address: '$address'"
|
||||
log "Handling address: '$address'"
|
||||
|
||||
if [[ $focus_active_only_flag == "1" ]] || [[ $close_active_only_flag == "1" ]]; then
|
||||
# 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.
|
||||
if [[ $active_window_workspace == $workspace ]]; then
|
||||
echo "Performing action: '$action', on window: '$address'"
|
||||
hyprctl dispatch $action "address:$address"
|
||||
log "Performing action: '$action', on window: '$address'"
|
||||
hypr_dispatch $action "address:$address"
|
||||
# early out if focusing a window.
|
||||
[[ $focus_active_only_flag ]] && exit 0
|
||||
else
|
||||
# the window is not on the active workspace, so skip it.
|
||||
echo "Skipping window: $address"
|
||||
log "Skipping window: $address"
|
||||
fi
|
||||
else
|
||||
# We don't have the focus_active_only_flag or close_active_only_flag set, so we perform
|
||||
# the action on the window.
|
||||
echo "Performing action: '$action', on window: '$address'"
|
||||
hyprctl dispatch $action "address:$address"
|
||||
log "Performing action: '$action', on window: '$address'"
|
||||
hypr_dispatch $action "address:$address"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
30
env/.local/scripts/hypr/launch-webapp
vendored
30
env/.local/scripts/hypr/launch-webapp
vendored
@@ -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
|
||||
THIS_FILE=${BASH_SOURCE[0]}
|
||||
THIS=$(basename "$THIS_FILE")
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
@@ -10,7 +12,7 @@ essentially just generates the pattern and launch command to pass into that scri
|
||||
|
||||
USAGE:
|
||||
|
||||
$ launch-webapp [OPTIONS] <url> [ARGS...]
|
||||
$ $THIS [OPTIONS] <url> [ARGS...]
|
||||
|
||||
OPTIONS:
|
||||
|
||||
@@ -43,13 +45,7 @@ browser="chromium.desktop"
|
||||
url=""
|
||||
launch_args=()
|
||||
app_args=""
|
||||
SCRIPTS="${SCRIPTS}"
|
||||
|
||||
if [[ -z $SCRIPTS ]]; then
|
||||
echo "scripts directory not set"
|
||||
echo "using ~/.local/scripts"
|
||||
SCRIPTS=~/.local/scripts
|
||||
fi
|
||||
SCRIPTS="${SCRIPTS:-$HOME/.local/scripts}"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ $1 =~ ^--special ]] || [[ $1 =~ ^-s ]]; then
|
||||
@@ -77,20 +73,28 @@ pattern() {
|
||||
echo $pattern
|
||||
}
|
||||
|
||||
log() {
|
||||
logging log --source "$THIS_FILE" "$@"
|
||||
}
|
||||
|
||||
##################################################
|
||||
# MAIN
|
||||
##################################################
|
||||
|
||||
# setup logging file and label
|
||||
source "$SCRIPTS/hypr/logging"
|
||||
setup-logging "/tmp/$THIS.log" "$THIS"
|
||||
|
||||
if [[ -z $url ]]; then
|
||||
echo "[ERROR]: Must supply a url." && usage && exit 1
|
||||
log --error "Must supply a url." && usage && exit 1
|
||||
fi
|
||||
|
||||
# Any left over args after "--"
|
||||
app_args="$@"
|
||||
|
||||
echo "URL: $url"
|
||||
echo "Launch args: ${launch_args[@]}"
|
||||
echo "App args: ${app_args}"
|
||||
log "URL: $url"
|
||||
log "Launch args: ${launch_args[@]}"
|
||||
log "App args: ${app_args}"
|
||||
|
||||
$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"
|
||||
|
||||
165
env/.local/scripts/hypr/logging
vendored
Executable file
165
env/.local/scripts/hypr/logging
vendored
Executable 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
101
env/.local/scripts/hypr/monitor-picker
vendored
Executable 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
56
env/.local/scripts/hypr/preview-stats
vendored
Executable 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
|
||||
23
env/.local/scripts/hypr/switch-to-workspace
vendored
23
env/.local/scripts/hypr/switch-to-workspace
vendored
@@ -1,5 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
THIS_FILE=${BASH_SOURCE[0]}
|
||||
THIS=$(basename "$THIS_FILE")
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
|
||||
@@ -12,7 +15,7 @@ the workspace.
|
||||
|
||||
USAGE:
|
||||
|
||||
$ $(basename ${BASH_SOURCE[0]}) [OPTIONS] <workspace>
|
||||
$ $THIS [OPTIONS] <workspace>
|
||||
|
||||
OPTIONS:
|
||||
|
||||
@@ -23,6 +26,7 @@ EOF
|
||||
|
||||
target_workspace=""
|
||||
active_workspace=$(hyprctl activewindow -j | jq -r '.workspace.name')
|
||||
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ $1 =~ ^-h ]] || [[ $1 =~ ^--help ]]; then
|
||||
@@ -33,15 +37,22 @@ while [[ $# -gt 0 ]]; do
|
||||
shift
|
||||
done
|
||||
|
||||
log() {
|
||||
logging log --source "$THIS_FILE" "$@"
|
||||
}
|
||||
|
||||
source "$SCRIPTS/hypr/logging"
|
||||
setup-logging "/tmp/$THIS.log" "$THIS"
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
# If active window is on a special workspace, then toggle the special workspace off.
|
||||
if [[ $active_workspace =~ ^special ]]; then
|
||||
echo "Toggling special workspace: '$active_workspace'"
|
||||
hyprctl dispatch togglespecialworkspace ${active_workspace#special:}
|
||||
log "Toggling special workspace: '$active_workspace'"
|
||||
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
|
||||
# on a special workspace.
|
||||
@@ -50,5 +61,5 @@ if [[ $active_workspace =~ ^special ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Switching to workspace: $target_workspace"
|
||||
hyprctl dispatch workspace $target_workspace
|
||||
log "Switching to workspace: $target_workspace"
|
||||
hyprctl dispatch workspace $target_workspace >/dev/null 2>&1
|
||||
|
||||
42
env/.local/scripts/hypr/uninstall-desktop-app
vendored
42
env/.local/scripts/hypr/uninstall-desktop-app
vendored
@@ -1,10 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Uninstalls '.desktop' applications, including their icon.
|
||||
#
|
||||
# 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.
|
||||
THIS_FILE=${BASH_SOURCE[0]}
|
||||
THIS=$(basename "$THIS_FILE")
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
@@ -15,9 +12,10 @@ package manager, then it should be used to uninstall the application.
|
||||
|
||||
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.
|
||||
|
||||
@@ -32,27 +30,31 @@ interactive_mode="0"
|
||||
dry_run="0"
|
||||
help_flag="0"
|
||||
XDG_DATA_HOME=${XDG_DATA_HOME}
|
||||
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ $1 =~ ^--dry ]]; then
|
||||
dry_run="1"
|
||||
elif [[ $1 =~ ^-h ]] || [[ $1 =~ ^--h ]]; then
|
||||
help_flag="1"
|
||||
usage && exit 0
|
||||
else
|
||||
files+=("$1")
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
# Early out for help option.
|
||||
if [[ $help_flag == "1" ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
log() {
|
||||
logging log --source "$THIS_FILE" "$@"
|
||||
}
|
||||
|
||||
############################## MAIN ##############################
|
||||
|
||||
source "$SCRIPTS/hypr/logging"
|
||||
setup-logging "/tmp/$THIS.log" "$THIS"
|
||||
|
||||
if [[ -z $XDG_DATA_HOME ]]; then
|
||||
echo "xdg data home is not set"
|
||||
echo "using: ~/.local/share"
|
||||
log "xdg data home is not set"
|
||||
log "using: ~/.local/share"
|
||||
XDG_DATA_HOME=$HOME/.local/share
|
||||
fi
|
||||
|
||||
@@ -65,16 +67,6 @@ if [[ ${#files} == 0 ]]; then
|
||||
)
|
||||
fi
|
||||
|
||||
log() {
|
||||
if [[ $dry_run == "1" ]]; then
|
||||
echo "[DRY RUN]: $1"
|
||||
else
|
||||
echo "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
############################## MAIN ##############################
|
||||
|
||||
for f in ${files[@]}; do
|
||||
|
||||
icon=""
|
||||
|
||||
63
env/.local/scripts/hypr/utils-launcher
vendored
63
env/.local/scripts/hypr/utils-launcher
vendored
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
THIS=$(basename ${BASH_SOURCE[0]})
|
||||
THIS_FILE=${BASH_SOURCE[0]}
|
||||
THIS=$(basename $THIS_FILE)
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
@@ -25,6 +26,8 @@ window_padding_x="2"
|
||||
config_file=""
|
||||
launch_flag="0"
|
||||
|
||||
rows=()
|
||||
invocation_id=${RANDOM}
|
||||
XDG_CONFIG_HOME=${XDG_CONFIG_HOME}
|
||||
SCRIPTS=${SCRIPTS}
|
||||
|
||||
@@ -38,11 +41,9 @@ while [[ $# -gt 0 ]]; do
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ -z $XDG_CONFIG_HOME ]]; then
|
||||
echo "XDG_CONFIG_HOME not set"
|
||||
echo "using ~/.config"
|
||||
XDG_CONFIG_HOME=$HOME/.config
|
||||
fi
|
||||
log() {
|
||||
logging log --source "$THIS_FILE" "$@"
|
||||
}
|
||||
|
||||
launch() {
|
||||
ghostty --class=$window_class --window-padding-x=$window_padding_x \
|
||||
@@ -61,19 +62,38 @@ footer() {
|
||||
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
|
||||
################################################################################
|
||||
|
||||
# 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
|
||||
echo "No config file set."
|
||||
echo "Using ~/.config/utils-launcher/config.json"
|
||||
log "No config file set."
|
||||
log "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"
|
||||
log "SCRIPTS not set"
|
||||
log "using ~/.local/scripts"
|
||||
SCRIPTS=$HOME/.local/scripts
|
||||
fi
|
||||
|
||||
@@ -82,26 +102,33 @@ if [[ $launch_flag == "1" ]]; then
|
||||
fi
|
||||
|
||||
if [[ ! -f $config_file ]]; then
|
||||
echo "[ERROR]: no config file set" && exit 1
|
||||
log "[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"
|
||||
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
|
||||
# Load the exec command for the selection.
|
||||
exec_cmd=$(echo $file_data | jq -r ".[] | select(.name == \"$sel\") | .exec")
|
||||
# Parse the exec command for the selection.
|
||||
exec_cmd=${sel%%|*}
|
||||
|
||||
echo "Exec: '$exec_cmd'"
|
||||
log "Exec: '$exec_cmd'"
|
||||
if [[ -z $exec_cmd ]]; then
|
||||
echo "[ERROR]: Command is empty." && exit 1
|
||||
log "[ERROR]: Command is empty." && exit 1
|
||||
fi
|
||||
eval exec uwsm app -- "$exec_cmd"
|
||||
else
|
||||
echo "No selection."
|
||||
log "No selection."
|
||||
fi
|
||||
|
||||
3
env/.local/scripts/hypr/waybarctl
vendored
3
env/.local/scripts/hypr/waybarctl
vendored
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
THIS=$(basename ${BASH_SOURCE[0]})
|
||||
THIS_FILE=${BASH_SOURCE[0]}
|
||||
THIS=$(basename $THIS_FILE)
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
|
||||
19
env/.local/scripts/hypr/window-picker
vendored
19
env/.local/scripts/hypr/window-picker
vendored
@@ -24,7 +24,7 @@ uses_supplied_footer="0"
|
||||
fzf_opts=()
|
||||
rows=()
|
||||
window_data=$(hyprctl clients -j | jq 'sort_by(.workspace.id)')
|
||||
SCRIPTS=${SCRIPTS}
|
||||
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ $1 =~ ^--footer ]]; then
|
||||
@@ -36,10 +36,6 @@ while [[ $# -gt 0 ]]; do
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ -z $SCRIPTS ]]; then
|
||||
SCRIPTS=$HOME/.local/scripts
|
||||
fi
|
||||
|
||||
footer() {
|
||||
cat <<'EOF'
|
||||
_ ___ __
|
||||
@@ -52,13 +48,11 @@ EOF
|
||||
generate_rows() {
|
||||
|
||||
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 workspaces <<<$(echo "$window_data" | jq -r '.[] | .workspace.name')
|
||||
|
||||
# Zip into rows.
|
||||
for i in "${!addresses[@]}"; do
|
||||
rows+=("${workspaces[i]}=>${titles[i]}=>${classes[i]}=>${addresses[i]}")
|
||||
rows+=("${addresses[i]}|${titles[i]}")
|
||||
done
|
||||
}
|
||||
|
||||
@@ -79,15 +73,12 @@ generate_rows
|
||||
sel=$(
|
||||
printf '%s\n' "${rows[@]}" |
|
||||
fzf --style=full "${fzf_opts[@]}" \
|
||||
--preview-label='[ Window Stats ]' --delimiter='=>' --with-nth=2 \
|
||||
--preview='echo -e "Title: {2}\nClass: {3}\nWorkspace: {1}\nAddress: {4}"'
|
||||
--preview-label='[ Window Stats ]' --delimiter='|' --with-nth=2 \
|
||||
--preview="$SCRIPTS/hypr/preview-stats window {1}"
|
||||
)
|
||||
|
||||
[[ -z $sel ]] && exit 1
|
||||
|
||||
# remove spaces and quotes from result.
|
||||
sel=${sel//\"/}
|
||||
sel=${sel// /}
|
||||
# revove everything but the address portion.
|
||||
sel=${sel##*=>}
|
||||
sel=${sel%%|*}
|
||||
echo "$sel"
|
||||
|
||||
49
env/.local/scripts/hypr/window-table
vendored
49
env/.local/scripts/hypr/window-table
vendored
@@ -1,5 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
THIS_FILE=${BASH_SOURCE[0]}
|
||||
THIS=$(basename $THIS_FILE)
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
|
||||
@@ -9,7 +12,7 @@ There are no required options for this script to work.
|
||||
|
||||
USAGE:
|
||||
|
||||
$ $(basename ${BASH_SOURCE[0]}) [OPTIONS]
|
||||
$ $THIS [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
|
||||
@@ -50,7 +53,7 @@ show_window_class_flag="0"
|
||||
launch_args=()
|
||||
selected_value=""
|
||||
|
||||
SCRIPTS=${SCRIPTS}
|
||||
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ $launch_flag == "1" ]]; then
|
||||
@@ -93,6 +96,10 @@ action_footer() {
|
||||
EOF
|
||||
}
|
||||
|
||||
log() {
|
||||
logging log --source "$THIS_FILE" "$@"
|
||||
}
|
||||
|
||||
show_table_return_choice() {
|
||||
local opts=()
|
||||
if [[ $show_window_class_flag == "1" ]]; then
|
||||
@@ -115,7 +122,7 @@ ask_what_to_do_with_selection() {
|
||||
printf "%s\n" "${choices[@]}" |
|
||||
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
|
||||
exit 0
|
||||
elif [[ $choice == "Close window" ]]; then
|
||||
@@ -135,6 +142,12 @@ ask_what_to_do_with_selection() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Prevent hyprctl dispatch calls from printing to the console.
|
||||
hypr_dispatch() {
|
||||
hyprctl dispatch "$@" >/dev/null 2>&1
|
||||
return $?
|
||||
}
|
||||
|
||||
move_to_workspace() {
|
||||
local workspace_id=""
|
||||
|
||||
@@ -146,7 +159,7 @@ move_to_workspace() {
|
||||
fi
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
@@ -158,7 +171,7 @@ move_to_workspace() {
|
||||
fi
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
@@ -167,37 +180,41 @@ move_to_workspace() {
|
||||
action="movetoworkspacesilent"
|
||||
fi
|
||||
|
||||
echo "Moving window: '$selected_value' to workspace: '$workspace_id'"
|
||||
hyprctl dispatch $action "$workspace_id,address:$selected_value"
|
||||
log "Moving window: '$selected_value' to workspace: '$workspace_id'"
|
||||
hypr_dispatch $action "$workspace_id,address:$selected_value"
|
||||
}
|
||||
|
||||
handle_selected_value() {
|
||||
if [[ $ignore_flag == "1" ]]; then
|
||||
echo "Ignore flag set, selection: '$selected_value'"
|
||||
log "Ignore flag set, selection: '$selected_value'"
|
||||
exit 0
|
||||
elif [[ $clipboard_flag == "1" ]]; then
|
||||
echo "Copying to clipboard, selection: $selected_value"
|
||||
log "Copying to clipboard, selection: $selected_value"
|
||||
wl-copy $selected_value
|
||||
exit 0
|
||||
elif [[ $focus_flag == "1" ]]; then
|
||||
echo "Focusing window, selection: $selected_value"
|
||||
hyprctl dispatch focuswindow "address:$selected_value"
|
||||
log "Focusing window, selection: $selected_value"
|
||||
hypr_dispatch focuswindow "address:$selected_value"
|
||||
exit 0
|
||||
elif [[ $close_flag == "1" ]]; then
|
||||
echo "Closing window, selection: $selected_value"
|
||||
hyprctl dispatch closewindow "address:$selected_value"
|
||||
log "Closing window, selection: $selected_value"
|
||||
hypr_dispatch closewindow "address:$selected_value"
|
||||
exit 0
|
||||
elif [[ $move_flag == "1" ]] || [[ $move_silent_flag == "1" ]]; then
|
||||
move_to_workspace && exit 0
|
||||
fi
|
||||
# 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
|
||||
##################################################
|
||||
|
||||
# Setup logging file and label.
|
||||
source "$SCRIPTS/hypr/logging"
|
||||
setup-logging "/tmp/$THIS.log" "$THIS"
|
||||
|
||||
if [[ $launch_flag == "1" ]]; then
|
||||
ghostty --class="$window_class" --window-padding-x="$window_padding_x" \
|
||||
--keybind="ctrl+c=quit" \
|
||||
@@ -214,11 +231,11 @@ else
|
||||
handle_selected_value
|
||||
# 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.
|
||||
echo "Asking what to do with selction."
|
||||
log "Asking what to do with selction."
|
||||
ask_what_to_do_with_selection
|
||||
|
||||
[[ -n $selected_value ]] && handle_selected_value
|
||||
# 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
|
||||
|
||||
10
env/.local/scripts/hypr/workspace-picker
vendored
10
env/.local/scripts/hypr/workspace-picker
vendored
@@ -69,11 +69,9 @@ EOF
|
||||
generate_rows() {
|
||||
readarray -t names <<<"$(echo "$workspaces" | jq -r '.[] | .name')"
|
||||
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
|
||||
rows+=("${ids[i]}|${monitors[i]}|${windows[i]}|${names[i]}")
|
||||
rows+=("${ids[i]}|${names[i]}")
|
||||
done
|
||||
}
|
||||
|
||||
@@ -93,9 +91,9 @@ fi
|
||||
|
||||
sel=$(
|
||||
printf "%s\n" "${rows[@]}" |
|
||||
fzf --style=full "${fzf_opts[@]}" \
|
||||
--delimiter='|' --with-nth=4 --preview-label='[ Workspace Stats ]' \
|
||||
--preview='printf "Name: {4}\nID: {1}\nWindows: {2}\nMonitor: {3}"'
|
||||
fzf --style=full "${fzf_opts[@]}" --delimiter='|' --with-nth=2 \
|
||||
--preview-label='[ Workspace Stats ]' \
|
||||
--preview="$SCRIPTS/hypr/preview-stats workspace {1}"
|
||||
)
|
||||
|
||||
[[ -z $sel ]] && exit 1
|
||||
|
||||
49
gen
49
gen
@@ -40,29 +40,30 @@ generate_run() {
|
||||
local dest="$DEV_ENV/runs/$file"
|
||||
fail_if_exists $dest
|
||||
log "Creating new run: $dest"
|
||||
printf "#!/usr/bin/env bash\n\n" >$dest
|
||||
printf "yay \${1:-\"-S --noconfirm\"} # packages\n" >>$dest
|
||||
cat >"$dest" <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
|
||||
yay ${1:-"-S --noconfirm"} # packages
|
||||
|
||||
EOF
|
||||
chmod +x $dest
|
||||
}
|
||||
|
||||
generate_webapp() {
|
||||
|
||||
local dest="$DEV_ENV/env/webapps/$file"
|
||||
|
||||
# Check that the destination ends with '.json', fix if not.
|
||||
if [[ ! $dest =~ \.json$ ]]; then
|
||||
dest="$dest.json"
|
||||
fi
|
||||
|
||||
fail_if_exists $dest
|
||||
|
||||
log "Creating new webapp: $dest"
|
||||
|
||||
printf "{\n" >$dest
|
||||
printf " \"name\": \"My App\",\n" >>$dest
|
||||
printf " \"url\": \"https://example.com\",\n" >>$dest
|
||||
printf " \"icon\": \"https://icon.com\"\n" >>$dest
|
||||
printf "}" >>$dest
|
||||
cat >"$dest" <<'EOF'
|
||||
{
|
||||
"name": "My App",
|
||||
"url": "https://example.com",
|
||||
"icon": "https://icon.com"
|
||||
}
|
||||
EOF
|
||||
|
||||
}
|
||||
|
||||
@@ -70,7 +71,29 @@ generate_script() {
|
||||
local dest="$DEV_ENV/env/.local/scripts/$file"
|
||||
fail_if_exists $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
|
||||
echo $dest
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user