mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-13 22:02:34 +00:00
fix: Fixes window action picker not returning proper choice, removes scripts that are now in the '*ctl' commands.
This commit is contained in:
29
env/.local/scripts/hypr/toggle-desktop
vendored
29
env/.local/scripts/hypr/toggle-desktop
vendored
@@ -1,29 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Workspace to hide everything in
|
||||
HIDE_WS="special:hidden"
|
||||
|
||||
# File to store original workspace ID
|
||||
STATE_FILE="/tmp/hypr_hide_state"
|
||||
|
||||
# Get current workspace ID
|
||||
CUR_WS=$(hyprctl -j activeworkspace | jq -r '.id')
|
||||
|
||||
# Check if we're currently hidden
|
||||
if [[ -f "$STATE_FILE" ]]; then
|
||||
# Restore windows
|
||||
ORIG_WS=$(cat "$STATE_FILE")
|
||||
for win in $(hyprctl -j clients | jq -r ".[] | select(.workspace.name | contains(\"$HIDE_WS\")) | .address"); do
|
||||
hyprctl dispatch movetoworkspace "$ORIG_WS,address:$win"
|
||||
hyprctl dispatch workspace "$ORIG_WS"
|
||||
done
|
||||
rm "$STATE_FILE"
|
||||
else
|
||||
# Hide all windows (move to special hidden workspace)
|
||||
for win in $(hyprctl -j clients | jq -r ".[] | select(.workspace.id == $CUR_WS) | .address"); do
|
||||
hyprctl dispatch movetoworkspace "$HIDE_WS,address:$win"
|
||||
hyprctl dispatch togglespecialworkspace "$HIDE_WS"
|
||||
done
|
||||
rm "$STATE_FILE"
|
||||
echo "$CUR_WS" >"$STATE_FILE"
|
||||
fi
|
||||
@@ -89,8 +89,7 @@ parse_workspace_id() {
|
||||
log "Parsing selected workspace name: $workspace_name"
|
||||
|
||||
if [[ -z $workspace_name ]]; then
|
||||
log --error "No workspace set to move window to."
|
||||
exit 1
|
||||
log --error "No workspace set to move window to." && exit 1
|
||||
fi
|
||||
|
||||
if [[ $workspace_name =~ ^special ]]; then
|
||||
@@ -113,7 +112,7 @@ move_to_workspace() {
|
||||
action="movetoworkspacesilent"
|
||||
fi
|
||||
|
||||
$SCRIPTS/hypr/workspace-picker --return-name-if-special --header="Select a workspace to move window to:" |
|
||||
$SCRIPTS/hypr/workspacectl picker --return-name-if-special --header="Select a workspace to move window to:" |
|
||||
parse_workspace_id |
|
||||
xargs -I{} hyprctl dispatch "$action" "{},address:$address" >/dev/null 2>&1
|
||||
|
||||
@@ -177,7 +176,7 @@ make_selection() {
|
||||
# Exit if non-zero code returned from making selection.
|
||||
[[ $? -gt 0 ]] && log --error "Unexpected fzf status: $?" && exit $?
|
||||
# Set choice to just the action portion.
|
||||
choice="${choice#*:}"
|
||||
choice="${choice##*:}"
|
||||
echo "$choice"
|
||||
}
|
||||
|
||||
|
||||
109
env/.local/scripts/hypr/workspace-picker
vendored
109
env/.local/scripts/hypr/workspace-picker
vendored
@@ -1,109 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
THIS=$(basename ${BASH_SOURCE[0]})
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
|
||||
Select from currently available workspaces.
|
||||
|
||||
If no options are specified, then the default behavior is to return the selected workspace id.
|
||||
|
||||
USAGE:
|
||||
|
||||
$ $THIS [OPTIONS] [ARGS...]
|
||||
|
||||
OPTIONS:
|
||||
|
||||
-n | --return-name: Return workspace name instead of id.
|
||||
|
||||
-s | --return-name-if-special: Return name if a special workspace, otherwise return the id.
|
||||
This option is useful when moving a workspace using 'hyprctl' with
|
||||
the selection.
|
||||
|
||||
NOTES:
|
||||
|
||||
By default, we show a footer and header unless specifically passed in as extra arguments / options.
|
||||
Any other options or arguments are passed directly to 'fzf'.
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
return_name_if_special_flag="0"
|
||||
return_name_flag="0"
|
||||
uses_supplied_footer="0"
|
||||
|
||||
fzf_opts=()
|
||||
rows=()
|
||||
workspaces=$(hyprctl workspaces -j | jq 'sort_by(.id)')
|
||||
SCRIPTS=${SCRIPTS}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ $1 == "-n" ]] || [[ $1 == "--return-name" ]]; then
|
||||
return_name_flag="1"
|
||||
elif [[ $1 == "-s" ]] || [[ $1 == "--return-name-if-special" ]]; then
|
||||
return_name_if_special_flag="1"
|
||||
elif [[ $1 =~ ^--footer ]]; then
|
||||
uses_supplied_footer="1"
|
||||
fzf_opts+=("$1")
|
||||
else
|
||||
fzf_opts+=("$1")
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ -z $SCRIPTS ]]; then
|
||||
SCRIPTS=$HOME/.local/scripts
|
||||
fi
|
||||
|
||||
footer() {
|
||||
cat <<'EOF'
|
||||
_ __ __
|
||||
| | /| / /__ ____/ /__ ___ ___ ___ ________ ___
|
||||
| |/ |/ / _ \/ __/ '_/(_-</ _ \/ _ `/ __/ -_|_-<
|
||||
|__/|__/\___/_/ /_/\_\/___/ .__/\_,_/\__/\__/___/
|
||||
/_/
|
||||
EOF
|
||||
}
|
||||
|
||||
generate_rows() {
|
||||
readarray -t names <<<"$(echo "$workspaces" | jq -r '.[] | .name')"
|
||||
readarray -t ids <<<"$(echo "$workspaces" | jq -r '.[] | .id')"
|
||||
|
||||
for i in "${!names[@]}"; do
|
||||
rows+=("${ids[i]}|${names[i]}")
|
||||
done
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# MAIN
|
||||
################################################################################
|
||||
|
||||
[[ -z ${FZF_DEFAULT_OPTS} ]] &&
|
||||
[[ -f $SCRIPTS/catppuccin-colors ]] &&
|
||||
source $SCRIPTS/catppuccin-colors
|
||||
|
||||
generate_rows
|
||||
|
||||
if [[ $uses_supplied_footer == "0" ]]; then
|
||||
fzf_opts+=("--footer=$(footer)")
|
||||
fi
|
||||
|
||||
sel=$(
|
||||
printf "%s\n" "${rows[@]}" |
|
||||
fzf --style=full "${fzf_opts[@]}" --delimiter='|' --with-nth=2 \
|
||||
--preview-label='[ Workspace Stats ]' \
|
||||
--preview="$SCRIPTS/hypr/utils/fzf/preview-stats workspace {1}"
|
||||
)
|
||||
|
||||
[[ -z $sel ]] && exit 1
|
||||
|
||||
name=${sel##*\|}
|
||||
id=${sel%%\|*}
|
||||
|
||||
if [[ $return_name_flag == "1" ]] ||
|
||||
([[ $return_name_if_special_flag == "1" ]] && [[ $name =~ ^special ]]); then
|
||||
echo "$name" && exit 0
|
||||
fi
|
||||
|
||||
echo "$id"
|
||||
Reference in New Issue
Block a user