mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-15 06:32:40 +00:00
feat: Renames window-table to windowctl, adds preview data to utils-launcher and windowctl actions.
This commit is contained in:
15
env/.config/utils-launcher/config.json
vendored
15
env/.config/utils-launcher/config.json
vendored
@@ -1,38 +1,47 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "App - install web app",
|
"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"
|
"exec": "$SCRIPTS/hypr/install-webapp"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "App - uninstall desktop app",
|
"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"
|
"exec": "$SCRIPTS/hypr/uninstall-desktop-app"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Clipboard - clear history",
|
"name": "Clipboard - clear history",
|
||||||
|
"description": "Clear the clipboard history file.",
|
||||||
"exec": "$SCRIPTS/hypr/clear-clipboard-history && echo Done"
|
"exec": "$SCRIPTS/hypr/clear-clipboard-history && echo Done"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Monitors - stats / picker",
|
"name": "Monitors - stats / picker",
|
||||||
|
"description": "View information from hyprctl about currently connected monitors.",
|
||||||
"exec": "$SCRIPTS/hypr/monitor-picker"
|
"exec": "$SCRIPTS/hypr/monitor-picker"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Waybar - restart",
|
"name": "Waybar - restart",
|
||||||
|
"description": "Restart the menu bar application, useful when making changes to the configuration.",
|
||||||
"exec": "$SCRIPTS/hypr/waybarctl --restart"
|
"exec": "$SCRIPTS/hypr/waybarctl --restart"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Waybar - toggle",
|
"name": "Waybar - toggle",
|
||||||
|
"description": "Toggle the visibility of the menu bar.",
|
||||||
"exec": "$SCRIPTS/hypr/waybarctl --toggle"
|
"exec": "$SCRIPTS/hypr/waybarctl --toggle"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Windows - window stats / picker",
|
"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"
|
"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"
|
"exec": "$SCRIPTS/hypr/close-windows --all"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
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:
|
USAGE:
|
||||||
|
|
||||||
$ $THIS <mode> <arg>
|
$ $THIS [MODE] [ARG...]
|
||||||
|
|
||||||
MODES:
|
MODES:
|
||||||
|
|
||||||
monitor: Get monitor data, arg is the monitor id.
|
monitor <id>: Get monitor data.
|
||||||
window: Get window data, arg is the window address.
|
window <address>: Get window data.
|
||||||
workspace: Get workspace data, arg is the workspace id.
|
workspace <id>: Get workspace data.
|
||||||
|
utlis <name> <config>: Get utils-launcher data.
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
@@ -35,8 +36,8 @@ log() {
|
|||||||
source "$SCRIPTS/hypr/logging"
|
source "$SCRIPTS/hypr/logging"
|
||||||
setup-logging "$THIS"
|
setup-logging "$THIS"
|
||||||
|
|
||||||
if [[ ! "${#@}" == "2" ]]; then
|
if [[ ! ${#@} -ge 2 ]]; then
|
||||||
log --error "Unexpected argument count: ${#@}, expected: 2"
|
log --error "Unexpected argument count: ${#@}, expected at least: 2"
|
||||||
usage && exit 1
|
usage && exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -50,6 +51,16 @@ elif [[ $mode == "window" ]]; then
|
|||||||
hyprctl clients -j | jq -C ".[] | select(.address == \"$arg\")"
|
hyprctl clients -j | jq -C ".[] | select(.address == \"$arg\")"
|
||||||
elif [[ $mode == "workspace" ]]; then
|
elif [[ $mode == "workspace" ]]; then
|
||||||
hyprctl workspaces -j | jq -C ".[] | select(.id == $arg)"
|
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
|
else
|
||||||
log --error "Unexpected mode: $mode"
|
log --error "Unexpected mode: $mode"
|
||||||
usage && exit 1
|
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.
|
# Setup logging file and label.
|
||||||
source "$SCRIPTS/hypr/logging"
|
source "$SCRIPTS/hypr/logging"
|
||||||
setup-logging "/tmp/$THIS.log" "$THIS"
|
setup-logging "$THIS"
|
||||||
|
|
||||||
if [[ -z $XDG_CONFIG_HOME ]]; then
|
if [[ -z $XDG_CONFIG_HOME ]]; then
|
||||||
log "XDG_CONFIG_HOME not set"
|
log "XDG_CONFIG_HOME not set"
|
||||||
@@ -91,12 +91,6 @@ if [[ -z $config_file ]]; then
|
|||||||
config_file="$XDG_CONFIG_HOME/utils-launcher/config.json"
|
config_file="$XDG_CONFIG_HOME/utils-launcher/config.json"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $SCRIPTS ]]; then
|
|
||||||
log "SCRIPTS not set"
|
|
||||||
log "using ~/.local/scripts"
|
|
||||||
SCRIPTS=$HOME/.local/scripts
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $launch_flag == "1" ]]; then
|
if [[ $launch_flag == "1" ]]; then
|
||||||
launch && exit 0
|
launch && exit 0
|
||||||
fi
|
fi
|
||||||
@@ -108,14 +102,16 @@ 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
|
[[ -z ${FZF_DEFAULT_OPTS} ]] &&
|
||||||
|
[[ -f $SCRIPTS/catppuccin-colors ]] &&
|
||||||
|
source $SCRIPTS/catppuccin-colors
|
||||||
|
|
||||||
generate_rows "$file_data"
|
generate_rows "$file_data"
|
||||||
sel=$(
|
sel=$(
|
||||||
printf "%s\n" "${rows[@]}" |
|
printf "%s\n" "${rows[@]}" |
|
||||||
fzf --style=full --footer="$(footer)" --with-nth=2 --delimiter='|' \
|
fzf --style=full --footer="$(footer)" --with-nth=2 --delimiter='|' \
|
||||||
--preview-label='[ Command ]' \
|
--preview-label='[ Command ]' \
|
||||||
--preview='printf "\nName: {2}\nExec: {1}"'
|
--preview="$SCRIPTS/hypr/preview-stats utils {2} $config_file"
|
||||||
)
|
)
|
||||||
|
|
||||||
log "Selection: $sel"
|
log "Selection: $sel"
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ OPTIONS:
|
|||||||
-s | --silent-move: Move the selected window to another workspace and remain on current workspace.
|
-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
|
-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.
|
then we will prompt for a workspace to move to.
|
||||||
--show-window-class: Include window class in the table.
|
|
||||||
-h | --help: Show this page.
|
-h | --help: Show this page.
|
||||||
|
|
||||||
NOTES:
|
NOTES:
|
||||||
@@ -37,7 +36,7 @@ launched terminal, allowing you to launch with a specific mode turned on, any fl
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
window_class="com.ghostty.window-table"
|
window_class="com.ghostty.$THIS"
|
||||||
window_padding_x="10"
|
window_padding_x="10"
|
||||||
|
|
||||||
clipboard_flag="0"
|
clipboard_flag="0"
|
||||||
@@ -48,7 +47,6 @@ launch_flag="0"
|
|||||||
move_flag="0"
|
move_flag="0"
|
||||||
move_silent_flag="0"
|
move_silent_flag="0"
|
||||||
move_to_workspace_name=""
|
move_to_workspace_name=""
|
||||||
show_window_class_flag="0"
|
|
||||||
|
|
||||||
launch_args=()
|
launch_args=()
|
||||||
selected_value=""
|
selected_value=""
|
||||||
@@ -79,8 +77,6 @@ while [[ $# -gt 0 ]]; do
|
|||||||
move_to_workspace_name=$1
|
move_to_workspace_name=$1
|
||||||
elif [[ $1 =~ ^--launch ]]; then
|
elif [[ $1 =~ ^--launch ]]; then
|
||||||
launch_flag="1"
|
launch_flag="1"
|
||||||
elif [[ $1 =~ ^--show-window-class ]]; then
|
|
||||||
show_window_class_flag="1"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
shift
|
shift
|
||||||
@@ -100,27 +96,23 @@ log() {
|
|||||||
logging log --source "$THIS_FILE" "$@"
|
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() {
|
ask_what_to_do_with_selection() {
|
||||||
local choices=(
|
local choices=(
|
||||||
"Focus window"
|
"Focus the selected window.:Focus window"
|
||||||
"Close window"
|
"Close the selected window.:Close window"
|
||||||
"Move to workspace"
|
"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 to workspace - silent"
|
"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 to clipboard"
|
"Copy the window address to the system clipboard:Copy to clipboard"
|
||||||
"Refresh window list"
|
"Move back to window picker and reload windows.:Back"
|
||||||
"Quit"
|
"Quit:Quit"
|
||||||
)
|
)
|
||||||
choice=$(
|
choice=$(
|
||||||
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)" \
|
||||||
|
--delimiter=':' --with-nth=2 \
|
||||||
|
--header="What should we do with the selected window?" \
|
||||||
|
--preview-label="[ Description ]" \
|
||||||
|
--preview='echo -e {1}'
|
||||||
)
|
)
|
||||||
log "Choice: $choice"
|
log "Choice: $choice"
|
||||||
if [[ $choice == "Quit" ]]; then
|
if [[ $choice == "Quit" ]]; then
|
||||||
@@ -226,7 +218,7 @@ else
|
|||||||
[[ -f $SCRIPTS/catppuccin-colors ]] &&
|
[[ -f $SCRIPTS/catppuccin-colors ]] &&
|
||||||
source $SCRIPTS/catppuccin-colors
|
source $SCRIPTS/catppuccin-colors
|
||||||
|
|
||||||
selected_value=$(show_table_return_choice)
|
selected_value=$("$SCRIPTS/hypr/window-picker")
|
||||||
if [[ -n $selected_value ]]; then
|
if [[ -n $selected_value ]]; then
|
||||||
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
|
||||||
Reference in New Issue
Block a user