feat: Renames window-table to windowctl, adds preview data to utils-launcher and windowctl actions.

This commit is contained in:
2025-10-06 10:26:25 -04:00
parent 6721b2a8c5
commit b1fb505ac5
4 changed files with 48 additions and 40 deletions

View File

@@ -1,38 +1,47 @@
[
{
"name": "App - install web app",
"description": "Install a new website as a desktop application that can be launched by an application launcher.",
"exec": "$SCRIPTS/hypr/install-webapp"
},
{
"name": "App - uninstall desktop app",
"description": "Uninstalls desktop applications and their icon, generally used for web\napplications.\n\nIf the app was installed through a package manager, then you should\nuse the package manager to uninstall the applciation.",
"exec": "$SCRIPTS/hypr/uninstall-desktop-app"
},
{
"name": "Clipboard - clear history",
"description": "Clear the clipboard history file.",
"exec": "$SCRIPTS/hypr/clear-clipboard-history && echo Done"
},
{
"name": "Monitors - stats / picker",
"description": "View information from hyprctl about currently connected monitors.",
"exec": "$SCRIPTS/hypr/monitor-picker"
},
{
"name": "Waybar - restart",
"description": "Restart the menu bar application, useful when making changes to the configuration.",
"exec": "$SCRIPTS/hypr/waybarctl --restart"
},
{
"name": "Waybar - toggle",
"description": "Toggle the visibility of the menu bar.",
"exec": "$SCRIPTS/hypr/waybarctl --toggle"
},
{
"name": "Windows - window stats / picker",
"exec": "$SCRIPTS/hypr/window-table"
"description": "View information from hyprctl about all the current windows.\n\nAllows you to choose an action you would like to perform on the selected window.",
"exec": "$SCRIPTS/hypr/windowctl"
},
{
"name": "Windows - close ALL in active workspace",
"name": "Windows - close in active workspace",
"description": "Close all windows in the currently active workspace.",
"exec": "$SCRIPTS/hypr/close-windows --active-workspace"
},
{
"name": "Windows - close ALL in all workspaces",
"name": "Windows - close ALL",
"description": "Close all windows in all workspaces.",
"exec": "$SCRIPTS/hypr/close-windows --all"
}
]

View File

@@ -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

View File

@@ -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"

View File

@@ -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