mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 06:12:34 +00:00
feat: Moves launch or focus script and makes it so that it can also close a window based on pattern. Updates keybinds that use it.
This commit is contained in:
13
env/.config/hypr/keybinds.conf
vendored
13
env/.config/hypr/keybinds.conf
vendored
@@ -4,8 +4,7 @@
|
||||
|
||||
# See https://wiki.hyprland.org/Configuring/Keywords/
|
||||
$mainMod = SUPER # "Command/Windows" key as main modifier
|
||||
# TODO: Use 'ALT' as window mod, need to change some tmux keybinds to do so.
|
||||
$windowMod = ALT # Control + Option for window controls.
|
||||
$windowMod = ALT # Option for window controls.
|
||||
$HYPER = ALT SHIFT SUPER CTRL
|
||||
|
||||
# See https://wiki.hyprland.org/Configuring/Keywords/
|
||||
@@ -18,7 +17,7 @@ $menu = uwsm app -- walker
|
||||
$scripts = ~/.local/scripts
|
||||
$pwa = $scripts/launch-webapp
|
||||
$tmuxSessionator = $scripts/tmux-sessionator
|
||||
$clipboardHistory = $terminal --class=com.ghostty.clipse -e clipse
|
||||
$clipboardHistory = com.ghostty.clipse $terminal --class=com.ghostty.clipse -e clipse
|
||||
$uninstallDesktop = $terminal --class=com.ghostty.float -e $scripts/uninstall-desktop-app
|
||||
$housecallPro = https://pro.housecallpro.com/app/calendar_new
|
||||
|
||||
@@ -36,8 +35,8 @@ bindd = $mainMod, SPACE, Application launcher, exec,
|
||||
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, workspace, previous
|
||||
bindd = $mainMod, A, Chat-gpt [a]i - launch / focus, exec, $pwa --focus "https://chatgpt.com"
|
||||
bindd = $mainMod SHIFT, A, Chat-gpt [a]i - new window, exec, $pwa "https://chatgpt.com"
|
||||
bindd = $mainMod, A, [A]i - launch / focus, exec, $pwa --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
|
||||
bindd = $mainMod SHIFT, B, New private [b]rowser, exec, $browser --private-window
|
||||
bindd = $mainMod, C, [C]alendar, exec, $pwa --focus "https://www.icloud.com/calendar"
|
||||
@@ -45,7 +44,7 @@ bindd = $mainMod SHIFT, C, [C]onfig folder in tmux session, exec,
|
||||
bindd = $mainMod, D, [D]ispatch app - special workspace, exec, $pwa --special dispatch $housecallPro
|
||||
bindd = $mainMod SHIFT, D, [D]ispatch app - new window, exec, $pwa $housecallPro
|
||||
bindd = $mainMod, E, [E]mail - personal, exec, $pwa --focus "https://mail.proton.me"
|
||||
bindd = $mainMod SHIFT, E, [E]mail - work, exec, $scripts/launch-or-focus thunderbird uwsm app -- thunderbird
|
||||
bindd = $mainMod SHIFT, E, [E]mail - work, exec, $scripts/launch-or --focus thunderbird uwsm app -- thunderbird
|
||||
bindd = $mainMod, F, [F]ile manager - terminal, exec, $fileManager
|
||||
bindd = $mainMod SHIFT, F, [F]ile manager - application, exec, $fileBrowser
|
||||
bindd = $mainMod, G, [G]itea, exec, $pwa "https://git.housh.dev"
|
||||
@@ -64,7 +63,7 @@ bindd = $mainMod, S, Toggle [s]pecial workspace, toggle
|
||||
bindd = $mainMod, Y, [Y]ouTube, exec, $pwa --focus "https://youtube.com"
|
||||
bindd = $mainMod, U, [U]nifi, exec, $pwa "https://unifi.ui.com"
|
||||
bindd = $mainMod SHIFT, U, [U]ninstall desktop app, exec, $uninstallDesktop
|
||||
bindd = $mainMod, V, Clipboard history, exec, $clipboardHistory
|
||||
bindd = $mainMod, V, Clipboard history, exec, $scripts/launch-or --close $clipboardHistory
|
||||
bindd = $mainMod, W, Close current window, killactive,
|
||||
bindd = $mainMod SHIFT, W, Close all windows in active workspace, exec, $scripts/close-windows --active-workspace
|
||||
|
||||
|
||||
61
env/.local/scripts/launch-or
vendored
Executable file
61
env/.local/scripts/launch-or
vendored
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
|
||||
Launch or focus / close a window based on pattern contained within the window
|
||||
class name. (Default is to focus the window).
|
||||
|
||||
USAGE:
|
||||
|
||||
$ $(basename ${BASH_SOURCE[0]}) [OPTIONS] PATTERN [LAUNCH_CMD...]
|
||||
|
||||
OPTIONS:
|
||||
|
||||
-f | --focus: Focus the window matching the pattern, if it exists.
|
||||
-c | --close: Close the window matching the pattern, if it exists.
|
||||
-h | --help: Show this help page.
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
action="focuswindow"
|
||||
pattern=""
|
||||
launch_cmd=()
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ $1 == "-c" ]] || [[ $1 == "--close" ]]; then
|
||||
action="closewindow"
|
||||
elif [[ $1 == "-f" ]] || [[ $1 == "--focus" ]]; then
|
||||
action="focuswindow"
|
||||
elif [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
|
||||
usage && exit 0
|
||||
elif [[ -z $pattern ]]; then
|
||||
pattern=$1
|
||||
else
|
||||
launch_cmd+=("$1")
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ -z $pattern ]]; then
|
||||
echo "[ERROR]: Must supply a pattern to match the window class."
|
||||
usage && exit 1
|
||||
elif [[ -z $launch_cmd ]]; then
|
||||
echo "[ERROR]: Must supply a launch command to match the window class."
|
||||
usage && exit 1
|
||||
fi
|
||||
|
||||
address=$(hyprctl clients -j | jq -r ".[] | select(.class | contains(\"$pattern\")) | .address")
|
||||
|
||||
echo "Pattern: $pattern"
|
||||
echo "Address: $address"
|
||||
|
||||
if [[ -n $address ]]; then
|
||||
echo "Found window, dispatching action: $action"
|
||||
hyprctl dispatch $action "address:$address"
|
||||
else
|
||||
echo "Launching..."
|
||||
echo "'${launch_cmd[@]}'"
|
||||
eval exec ${launch_cmd[@]}
|
||||
fi
|
||||
28
env/.local/scripts/launch-or-focus
vendored
28
env/.local/scripts/launch-or-focus
vendored
@@ -1,28 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Launch or focus a window based on a pattern contained within the
|
||||
# window class name.
|
||||
|
||||
pattern=$1
|
||||
launchCmd=${@:2}
|
||||
|
||||
if [[ -z $pattern ]]; then
|
||||
echo "Error: Must supply a pattern to match the window class."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z $launchCmd ]]; then
|
||||
echo "Error: Must supply a launch command to match the window class."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
address=$(hyprctl clients -j | jq -r ".[] | select(.class | contains(\"$pattern\")) | .address")
|
||||
|
||||
echo "Pattern: $pattern"
|
||||
echo "Address: $address"
|
||||
|
||||
if [[ -n $address ]]; then
|
||||
hyprctl dispatch focuswindow "address:$address"
|
||||
else
|
||||
eval exec $launchCmd
|
||||
fi
|
||||
5
env/.local/scripts/window-table
vendored
5
env/.local/scripts/window-table
vendored
@@ -29,7 +29,7 @@ launched terminal, allowing you to launch with a specific mode turned on, any fl
|
||||
EOF
|
||||
}
|
||||
|
||||
window_class="com.ghostty.$(basename ${BASH_SOURCE[0]})"
|
||||
window_class="com.ghostty.window-table"
|
||||
window_padding_x="10"
|
||||
|
||||
clipboard_flag="0"
|
||||
@@ -94,7 +94,8 @@ show_table_return_choice() {
|
||||
fi
|
||||
local ret=$(
|
||||
printf '%s\n' "${rows[@]}" |
|
||||
gum table --columns "$columns" --return-column $ret_column
|
||||
fzf --footer="Workspace - Title - Address" --footer-label-pos=center
|
||||
# gum table --columns "$columns" --return-column $ret_column
|
||||
|
||||
)
|
||||
# remove spaces and quotes from result.
|
||||
|
||||
2
env/.zshenv
vendored
2
env/.zshenv
vendored
@@ -67,7 +67,7 @@ export VAULT_ADDR="https://vault.housh.dev"
|
||||
export CARGO_HOME="$XDG_DATA_HOME/cargo"
|
||||
|
||||
# Tmux-Sessionator path.
|
||||
export TMUX_SESSIONATOR_PATH="$HOME:$SCRIPTS"
|
||||
export TMUX_SESSIONATOR_PATH="$HOME:$SCRIPTS:$HOME/personal:$HOME/dev"
|
||||
|
||||
# Password-store
|
||||
export PASSWORD_STORE_DIR="$XDG_DATA_HOME/gopass/stores/root"
|
||||
|
||||
Reference in New Issue
Block a user