mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-16 23:22:37 +00:00
Compare commits
4 Commits
aec425c7d2
...
6332eafea5
| Author | SHA1 | Date | |
|---|---|---|---|
|
6332eafea5
|
|||
|
933ce337a1
|
|||
|
ae73074f6a
|
|||
|
63c8645051
|
22
env/.config/hypr/keybinds.conf
vendored
22
env/.config/hypr/keybinds.conf
vendored
@@ -35,7 +35,7 @@ $housecallPro = https://pro.housecallpro.com/app/calendar_new
|
||||
bindd = $mainMod, SPACE, Application launcher, exec, $menu
|
||||
bindd = $mainMod, RETURN, New terminal, exec, $terminal
|
||||
bindd = $mainMod SHIFT, RETURN, New floating terminal, exec, $terminal --class=com.ghostty.float
|
||||
bindd = $mainMod, TAB, Focus previous workspace, exec, $scripts/switch-to-workspace previous
|
||||
bindd = $mainMod, TAB, Focus previous workspace, exec, $scripts/workspacectl switch --to previous
|
||||
bindd = $mainMod, A, [A]i - launch / focus, exec, $pwa --or-focus "https://chatgpt.com"
|
||||
bindd = $mainMod SHIFT, A, [A]i - new window, exec, $pwa "https://chatgpt.com"
|
||||
bindd = $mainMod, B, New [b]rowser, exec, $browser
|
||||
@@ -71,16 +71,16 @@ bindd = $mainMod, W, Close current window, killac
|
||||
bindd = $mainMod SHIFT, W, Close all windows in active workspace, exec, $scripts/windowctl close --active-workspace
|
||||
|
||||
# Switch to workspaces with mainMod + [0-9]
|
||||
bindd = $mainMod, 1, Switch to workspace [1], exec, $scripts/switch-to-workspace 1
|
||||
bindd = $mainMod, 2, Switch to workspace [2], exec, $scripts/switch-to-workspace 2
|
||||
bindd = $mainMod, 3, Switch to workspace [3], exec, $scripts/switch-to-workspace 3
|
||||
bindd = $mainMod, 4, Switch to workspace [4], exec, $scripts/switch-to-workspace 4
|
||||
bindd = $mainMod, 5, Switch to workspace [5], exec, $scripts/switch-to-workspace 5
|
||||
bindd = $mainMod, 6, Switch to workspace [6], exec, $scripts/switch-to-workspace 6
|
||||
bindd = $mainMod, 7, Switch to workspace [7], exec, $scripts/switch-to-workspace 7
|
||||
bindd = $mainMod, 8, Switch to workspace [8], exec, $scripts/switch-to-workspace 8
|
||||
bindd = $mainMod, 9, Switch to workspace [9], exec, $scripts/switch-to-workspace 9
|
||||
bindd = $mainMod, 0, Switch to workspace 1[0], exec, $scripts/switch-to-workspace 10
|
||||
bindd = $mainMod, 1, Switch to workspace [1], exec, $scripts/workspacectl switch --to 1
|
||||
bindd = $mainMod, 2, Switch to workspace [2], exec, $scripts/workspacectl switch --to 2
|
||||
bindd = $mainMod, 3, Switch to workspace [3], exec, $scripts/workspacectl switch --to 3
|
||||
bindd = $mainMod, 4, Switch to workspace [4], exec, $scripts/workspacectl switch --to 4
|
||||
bindd = $mainMod, 5, Switch to workspace [5], exec, $scripts/workspacectl switch --to 5
|
||||
bindd = $mainMod, 6, Switch to workspace [6], exec, $scripts/workspacectl switch --to 6
|
||||
bindd = $mainMod, 7, Switch to workspace [7], exec, $scripts/workspacectl switch --to 7
|
||||
bindd = $mainMod, 8, Switch to workspace [8], exec, $scripts/workspacectl switch --to 8
|
||||
bindd = $mainMod, 9, Switch to workspace [9], exec, $scripts/workspacectl switch --to 9
|
||||
bindd = $mainMod, 0, Switch to workspace 1[0], exec, $scripts/workspacectl switch --to 10
|
||||
|
||||
# Move all workspaces to a monitor
|
||||
bindd = $mainMod SHIFT, 1, Switch all workspaces to monitor [1], exec, $scripts/mv-all-workspaces-to-monitor 1
|
||||
|
||||
5
env/.config/utils-launcher/config.json
vendored
5
env/.config/utils-launcher/config.json
vendored
@@ -43,5 +43,10 @@
|
||||
"name": "Windows - close ALL",
|
||||
"description": "Close all windows in all workspaces.",
|
||||
"exec": "$SCRIPTS/hypr/windowctl close --all"
|
||||
},
|
||||
{
|
||||
"name": "Workspaces - stats / picker",
|
||||
"description": "View information from hyprctl about currently available workspaces",
|
||||
"exec": "$SCRIPTS/hypr/workspacectl picker"
|
||||
}
|
||||
]
|
||||
|
||||
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
|
||||
@@ -33,34 +33,6 @@ address=""
|
||||
move_silent_flag="0"
|
||||
show_back_choice="0"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
|
||||
usage && exit 0
|
||||
elif [[ $1 == "-a" ]] || [[ $1 == "--active" ]]; then
|
||||
|
||||
class=$(hyprctl activewindow -j | jq -r '.class')
|
||||
if [[ $class == "com.ghostty.windowctl" ]]; then
|
||||
# Select the previously focused window if we were launched in a new terminal window.
|
||||
address=$(hyprctl clients -j | jq -r '.[] | select(.focusHistoryID == 1) | .address')
|
||||
else
|
||||
# Select the active address if not.
|
||||
address=$(hyprctl activewindow -j | jq -r '.address')
|
||||
fi
|
||||
|
||||
elif [[ $1 == "--show-back" ]]; then
|
||||
show_back_choice="1"
|
||||
else
|
||||
address=$1
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
# If an address not supplied then read from stdin, which allows us to pipe the address into
|
||||
# this command.
|
||||
if [[ -z $address ]]; then
|
||||
read -p "Window address: " address
|
||||
fi
|
||||
|
||||
# Logging utility function, use in place of echo.
|
||||
log() {
|
||||
logging log --source "$THIS_FILE" "$@"
|
||||
@@ -89,8 +61,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 +84,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 +148,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"
|
||||
}
|
||||
|
||||
@@ -225,6 +196,34 @@ handle_selection() {
|
||||
source "$SCRIPTS/hypr/logging"
|
||||
setup-logging "$LOG_FILE" "$LOG_LABEL"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
|
||||
usage && exit 0
|
||||
elif [[ $1 == "-a" ]] || [[ $1 == "--active" ]]; then
|
||||
|
||||
class=$(hyprctl activewindow -j | jq -r '.class')
|
||||
if [[ $class == "com.ghostty.windowctl" ]]; then
|
||||
# Select the previously focused window if we were launched in a new terminal window.
|
||||
address=$(hyprctl clients -j | jq -r '.[] | select(.focusHistoryID == 1) | .address')
|
||||
else
|
||||
# Select the active address if not.
|
||||
address=$(hyprctl activewindow -j | jq -r '.address')
|
||||
fi
|
||||
|
||||
elif [[ $1 == "--show-back" ]]; then
|
||||
show_back_choice="1"
|
||||
else
|
||||
address=$1
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
# If an address not supplied then read from stdin, which allows us to pipe the address into
|
||||
# this command.
|
||||
if [[ -z $address ]]; then
|
||||
read -p "Window address: " address
|
||||
fi
|
||||
|
||||
# Load colors if they haven't been loaded already.
|
||||
[[ -z ${FZF_DEFAULT_OPTS} ]] &&
|
||||
[[ -f $SCRIPTS/catppuccin-colors ]] &&
|
||||
@@ -237,4 +236,5 @@ fi
|
||||
|
||||
res=$(make_selection | handle_selection)
|
||||
log "Action result: $res"
|
||||
# Returns "done | back | back:close" for parent script to know how to handle.
|
||||
echo "$res"
|
||||
|
||||
@@ -5,7 +5,15 @@ set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
||||
THIS=${THIS:-$(basename ${BASH_SOURCE[0]})}
|
||||
THIS_FILE=${BASH_SOURCE[0]}
|
||||
LOG_LABEL=$(basename $THIS_FILE)
|
||||
THIS=${THIS:-$LOG_LABEL}
|
||||
LOG_FILE=${LOG_FILE:-/tmp/$LOG_LABEL.log}
|
||||
|
||||
uses_supplied_footer="0"
|
||||
fzf_opts=()
|
||||
rows=()
|
||||
workspace_id=""
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
@@ -17,7 +25,8 @@ USAGE:
|
||||
$ $THIS <flags> [FZF_OPTIONS]
|
||||
|
||||
FLAGS:
|
||||
-h | --help: Show this help page.
|
||||
-w | --workspace <id>: Only show windows for the given workspace.
|
||||
-h | --help: Show this help page.
|
||||
|
||||
NOTES:
|
||||
|
||||
@@ -27,11 +36,10 @@ Any other options or arguments are passed directly to 'fzf'.
|
||||
EOF
|
||||
}
|
||||
|
||||
uses_supplied_footer="0"
|
||||
|
||||
fzf_opts=()
|
||||
rows=()
|
||||
window_data=$(hyprctl clients -j | jq 'sort_by(.workspace.id)')
|
||||
# Logging utility function, use in place of echo.
|
||||
log() {
|
||||
logging log --source "$THIS_FILE" "$@"
|
||||
}
|
||||
|
||||
footer() {
|
||||
cat <<'EOF'
|
||||
@@ -43,13 +51,17 @@ EOF
|
||||
}
|
||||
|
||||
generate_rows() {
|
||||
local addresses=()
|
||||
|
||||
readarray -t addresses <<<"$(echo "$window_data" | jq -r '.[] | .address')"
|
||||
readarray -t titles <<<$(echo "$window_data" | jq -r '.[] | .title')
|
||||
if [[ -n $workspace_id ]]; then
|
||||
addresses=$(hyprctl clients -j | jq -r ".[] | select(.workspace.id == $workspace_id) | .address")
|
||||
else
|
||||
addresses=$(hyprctl clients -j | jq -r ".[] | .address")
|
||||
fi
|
||||
|
||||
# Zip into rows.
|
||||
for i in "${!addresses[@]}"; do
|
||||
rows+=("${addresses[i]}|${titles[i]}")
|
||||
for address in $addresses; do
|
||||
title=$(hyprctl clients -j | jq -r ".[] | select(.address == \"$address\") | .title")
|
||||
rows+=("$address|$title")
|
||||
done
|
||||
}
|
||||
|
||||
@@ -57,12 +69,19 @@ generate_rows() {
|
||||
# MAIN
|
||||
################################################################################
|
||||
|
||||
# Setup logging file and label.
|
||||
source "$SCRIPTS/hypr/logging"
|
||||
setup-logging "$LOG_FILE" "$LOG_LABEL"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ $1 =~ ^--footer ]]; then
|
||||
if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
|
||||
usage && exit 0
|
||||
elif [[ $1 =~ ^--footer ]]; then
|
||||
uses_supplied_footer="1"
|
||||
fzf_opts+=("$1")
|
||||
elif [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
|
||||
usage && exit 0
|
||||
elif [[ $1 == "-w" ]] || [[ $1 == "--workspace" ]]; then
|
||||
shift
|
||||
workspace_id=$1
|
||||
else
|
||||
fzf_opts+=("$1")
|
||||
fi
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
||||
THIS_FILE=${BASH_SOURCE[0]}
|
||||
LOG_LABEL=$(basename $THIS_FILE)
|
||||
LOG_FILE=${LOG_FILE:-/tmp/$LOG_LABEL.log}
|
||||
@@ -17,34 +18,49 @@ the workspace.
|
||||
|
||||
USAGE:
|
||||
|
||||
$ $THIS [OPTIONS] <workspace>
|
||||
|
||||
OPTIONS:
|
||||
$ $THIS <flags> <workspace>
|
||||
|
||||
-h | --help: Show this help page.
|
||||
FLAGS:
|
||||
-p | --previous: Switch to the previously active workspace.
|
||||
-t | --to <workspace>: Workspace to switch to.
|
||||
-h | --help: Show this help page.
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
log() {
|
||||
logging log --source "$THIS_FILE" "$@"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# MAIN
|
||||
################################################################################
|
||||
|
||||
# Setup logging file and label.
|
||||
source "$SCRIPTS/hypr/logging"
|
||||
setup-logging "$LOG_FILE" "$LOG_LABEL"
|
||||
|
||||
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
|
||||
usage && exit 0
|
||||
elif [[ $1 =~ ^-t ]] || [[ $1 =~ ^--to ]]; then
|
||||
target_workspace=$1
|
||||
elif [[ $1 =~ ^-p ]] || [[ $1 =~ ^--previous ]]; then
|
||||
target_workspace="previous"
|
||||
else
|
||||
target_workspace=$1
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
log() {
|
||||
logging log --source "$THIS_FILE" "$@"
|
||||
}
|
||||
|
||||
source "$SCRIPTS/hypr/logging"
|
||||
setup-logging "$LOG_FILE" "$LOG_LABEL"
|
||||
# Read from stdin if no workspace was supplied.
|
||||
if [[ -z $target_workspace ]]; then
|
||||
read -p "Workspace: " target_workspace
|
||||
fi
|
||||
|
||||
if [[ -z target_workspace ]]; then
|
||||
log --error "Must supply a workpsace to switch to."
|
||||
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"
|
||||
6
env/.local/scripts/hypr/workspacectl
vendored
6
env/.local/scripts/hypr/workspacectl
vendored
@@ -20,6 +20,7 @@ USAGE:
|
||||
COMMANDS:
|
||||
launch: Launches in a new terminal window.
|
||||
picker: Shows a picker / stats about active workspaces.
|
||||
switch: Switch to another workspace, handling special workspaces.
|
||||
toggle: Toggle visibility of all windows on a workspace.
|
||||
|
||||
FLAGS:
|
||||
@@ -54,6 +55,11 @@ while [[ $# -gt 0 ]]; do
|
||||
shift
|
||||
THIS="$THIS picker" "$SCRIPTS/hypr/utils/workspaces/workspace-picker" "$@"
|
||||
exit $?
|
||||
|
||||
elif [[ $1 == "switch" ]]; then
|
||||
shift
|
||||
THIS="$THIS switch" "$SCRIPTS/hypr/utils/workspaces/switch-to-workspace" "$@"
|
||||
exit $?
|
||||
elif [[ $1 == "toggle" ]]; then
|
||||
shift
|
||||
THIS="$THIS toggle" "$SCRIPTS/hypr/utils/workspaces/workspace-toggle" "$@"
|
||||
|
||||
Reference in New Issue
Block a user