mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 06:12:34 +00:00
feat: Renames window-table to windowctl, adds preview data to utils-launcher and windowctl actions.
This commit is contained in:
23
env/.local/scripts/hypr/preview-stats
vendored
23
env/.local/scripts/hypr/preview-stats
vendored
@@ -11,13 +11,14 @@ Utility for getting fzf preview data.
|
||||
|
||||
USAGE:
|
||||
|
||||
$ $THIS <mode> <arg>
|
||||
$ $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.
|
||||
monitor <id>: Get monitor data.
|
||||
window <address>: Get window data.
|
||||
workspace <id>: Get workspace data.
|
||||
utlis <name> <config>: Get utils-launcher data.
|
||||
|
||||
EOF
|
||||
}
|
||||
@@ -35,8 +36,8 @@ log() {
|
||||
source "$SCRIPTS/hypr/logging"
|
||||
setup-logging "$THIS"
|
||||
|
||||
if [[ ! "${#@}" == "2" ]]; then
|
||||
log --error "Unexpected argument count: ${#@}, expected: 2"
|
||||
if [[ ! ${#@} -ge 2 ]]; then
|
||||
log --error "Unexpected argument count: ${#@}, expected at least: 2"
|
||||
usage && exit 1
|
||||
fi
|
||||
|
||||
@@ -50,6 +51,16 @@ elif [[ $mode == "window" ]]; then
|
||||
hyprctl clients -j | jq -C ".[] | select(.address == \"$arg\")"
|
||||
elif [[ $mode == "workspace" ]]; then
|
||||
hyprctl workspaces -j | jq -C ".[] | select(.id == $arg)"
|
||||
elif [[ $mode == "utils" ]]; then
|
||||
config="${3//\'/}"
|
||||
if [[ ! -f $config ]]; then
|
||||
log --error "No utility-launcher config found: $config"
|
||||
exit 1
|
||||
fi
|
||||
desc=$(jq -C ".[] | select(.name == \"$arg\") | .description" $config)
|
||||
exec=$(jq -C ".[] | select(.name == \"$arg\") | .exec" $config)
|
||||
echo -e "\n${desc[@]}\n\n"
|
||||
echo -e "\e[31mEXEC:\e[0m $exec\n"
|
||||
else
|
||||
log --error "Unexpected mode: $mode"
|
||||
usage && exit 1
|
||||
|
||||
14
env/.local/scripts/hypr/utils-launcher
vendored
14
env/.local/scripts/hypr/utils-launcher
vendored
@@ -77,7 +77,7 @@ generate_rows() {
|
||||
|
||||
# Setup logging file and label.
|
||||
source "$SCRIPTS/hypr/logging"
|
||||
setup-logging "/tmp/$THIS.log" "$THIS"
|
||||
setup-logging "$THIS"
|
||||
|
||||
if [[ -z $XDG_CONFIG_HOME ]]; then
|
||||
log "XDG_CONFIG_HOME not set"
|
||||
@@ -91,12 +91,6 @@ if [[ -z $config_file ]]; then
|
||||
config_file="$XDG_CONFIG_HOME/utils-launcher/config.json"
|
||||
fi
|
||||
|
||||
if [[ -z $SCRIPTS ]]; then
|
||||
log "SCRIPTS not set"
|
||||
log "using ~/.local/scripts"
|
||||
SCRIPTS=$HOME/.local/scripts
|
||||
fi
|
||||
|
||||
if [[ $launch_flag == "1" ]]; then
|
||||
launch && exit 0
|
||||
fi
|
||||
@@ -108,14 +102,16 @@ fi
|
||||
file_data=$(cat $config_file)
|
||||
|
||||
# Setup colors before calling fzf.
|
||||
[[ -f $SCRIPTS/catppuccin-colors ]] && source $SCRIPTS/catppuccin-colors
|
||||
[[ -z ${FZF_DEFAULT_OPTS} ]] &&
|
||||
[[ -f $SCRIPTS/catppuccin-colors ]] &&
|
||||
source $SCRIPTS/catppuccin-colors
|
||||
|
||||
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}"'
|
||||
--preview="$SCRIPTS/hypr/preview-stats utils {2} $config_file"
|
||||
)
|
||||
|
||||
log "Selection: $sel"
|
||||
|
||||
@@ -25,7 +25,6 @@ OPTIONS:
|
||||
-s | --silent-move: Move the selected window to another workspace and remain on current workspace.
|
||||
-t | --to-workspace: Used with one of the move options to set which workspace to move to. If not supplied
|
||||
then we will prompt for a workspace to move to.
|
||||
--show-window-class: Include window class in the table.
|
||||
-h | --help: Show this page.
|
||||
|
||||
NOTES:
|
||||
@@ -37,7 +36,7 @@ launched terminal, allowing you to launch with a specific mode turned on, any fl
|
||||
EOF
|
||||
}
|
||||
|
||||
window_class="com.ghostty.window-table"
|
||||
window_class="com.ghostty.$THIS"
|
||||
window_padding_x="10"
|
||||
|
||||
clipboard_flag="0"
|
||||
@@ -48,7 +47,6 @@ launch_flag="0"
|
||||
move_flag="0"
|
||||
move_silent_flag="0"
|
||||
move_to_workspace_name=""
|
||||
show_window_class_flag="0"
|
||||
|
||||
launch_args=()
|
||||
selected_value=""
|
||||
@@ -79,8 +77,6 @@ while [[ $# -gt 0 ]]; do
|
||||
move_to_workspace_name=$1
|
||||
elif [[ $1 =~ ^--launch ]]; then
|
||||
launch_flag="1"
|
||||
elif [[ $1 =~ ^--show-window-class ]]; then
|
||||
show_window_class_flag="1"
|
||||
fi
|
||||
fi
|
||||
shift
|
||||
@@ -100,27 +96,23 @@ log() {
|
||||
logging log --source "$THIS_FILE" "$@"
|
||||
}
|
||||
|
||||
show_table_return_choice() {
|
||||
local opts=()
|
||||
if [[ $show_window_class_flag == "1" ]]; then
|
||||
opts+=("--show-window-class")
|
||||
fi
|
||||
echo $("$SCRIPTS/hypr/window-picker" "${opts[@]}")
|
||||
}
|
||||
|
||||
ask_what_to_do_with_selection() {
|
||||
local choices=(
|
||||
"Focus window"
|
||||
"Close window"
|
||||
"Move to workspace"
|
||||
"Move to workspace - silent"
|
||||
"Copy to clipboard"
|
||||
"Refresh window list"
|
||||
"Quit"
|
||||
"Focus the selected window.:Focus window"
|
||||
"Close the selected window.:Close window"
|
||||
"Move the selected window to another workspace, focusing the window.\n\nA workspace picker will be presented to choose which workspace to move to.:Move to workspace"
|
||||
"Move the selected window to another workspace, without focusing the window.\n\nA workspace picker will be presented to choose which workspace to move to.:Move to workspace - silent"
|
||||
"Copy the window address to the system clipboard:Copy to clipboard"
|
||||
"Move back to window picker and reload windows.:Back"
|
||||
"Quit:Quit"
|
||||
)
|
||||
choice=$(
|
||||
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)" \
|
||||
--delimiter=':' --with-nth=2 \
|
||||
--header="What should we do with the selected window?" \
|
||||
--preview-label="[ Description ]" \
|
||||
--preview='echo -e {1}'
|
||||
)
|
||||
log "Choice: $choice"
|
||||
if [[ $choice == "Quit" ]]; then
|
||||
@@ -226,7 +218,7 @@ else
|
||||
[[ -f $SCRIPTS/catppuccin-colors ]] &&
|
||||
source $SCRIPTS/catppuccin-colors
|
||||
|
||||
selected_value=$(show_table_return_choice)
|
||||
selected_value=$("$SCRIPTS/hypr/window-picker")
|
||||
if [[ -n $selected_value ]]; then
|
||||
handle_selected_value
|
||||
# If we got here then no flag was passed in initially on how to handle the
|
||||
Reference in New Issue
Block a user