dev: automated commit - 2025-11-16 11:58:51
This commit is contained in:
parent
7dbe7f4685
commit
9dca029a62
5 changed files with 102 additions and 178 deletions
|
|
@ -5,7 +5,7 @@ set -euo pipefail
|
||||||
CACHE_MAX_AGE=300
|
CACHE_MAX_AGE=300
|
||||||
MRU_SIZE=20
|
MRU_SIZE=20
|
||||||
|
|
||||||
# Debug logging (set DEBUG=1 to enable)
|
# Debug logging (set DEBUG=1 to enable via environment variable)
|
||||||
DEBUG="${DEBUG:-0}"
|
DEBUG="${DEBUG:-0}"
|
||||||
|
|
||||||
debug() {
|
debug() {
|
||||||
|
|
@ -200,9 +200,9 @@ debug "Class name: $CLASS_NAME"
|
||||||
debug "Launching ghostty with launch-or-focus..."
|
debug "Launching ghostty with launch-or-focus..."
|
||||||
|
|
||||||
launch-or-focus ghostty \
|
launch-or-focus ghostty \
|
||||||
|
--class "$CLASS_NAME" \
|
||||||
|
--title "$PROJECT_NAME" \
|
||||||
--working-directory="$SELECTED" \
|
--working-directory="$SELECTED" \
|
||||||
--title="$PROJECT_NAME" \
|
|
||||||
--class="$CLASS_NAME" \
|
|
||||||
-e bash -c "if tmux has-session -t '$SESSION_NAME' 2>/dev/null; then \
|
-e bash -c "if tmux has-session -t '$SESSION_NAME' 2>/dev/null; then \
|
||||||
tmux attach -t '$SESSION_NAME'; \
|
tmux attach -t '$SESSION_NAME'; \
|
||||||
else \
|
else \
|
||||||
|
|
|
||||||
|
|
@ -1,167 +1,96 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# Script to launch an application or focus it if already running in sway
|
# Simple script to launch an application or focus it if already running in sway
|
||||||
# Usage: launch-or-focus <command> [args...]
|
# Usage: launch-or-focus <command> [--class CLASS] [--title TITLE] [args...]
|
||||||
# Set DEBUG=1 to enable debug logging
|
#
|
||||||
|
# Examples:
|
||||||
|
# launch-or-focus firefox
|
||||||
|
# launch-or-focus code --class Code --title "My Project"
|
||||||
|
# launch-or-focus kitty --class kitty
|
||||||
|
|
||||||
DEBUG="${DEBUG:-0}"
|
CLASS=""
|
||||||
|
TITLE=""
|
||||||
|
ARGS=()
|
||||||
|
|
||||||
debug() {
|
# Parse arguments
|
||||||
[ "$DEBUG" = "1" ] && echo "[DEBUG] $*" >&2 || true
|
while [[ $# -gt 0 ]]; do
|
||||||
}
|
case $1 in
|
||||||
|
--class)
|
||||||
|
CLASS="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--title)
|
||||||
|
TITLE="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
ARGS+=("$1")
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
if [ $# -eq 0 ]; then
|
if [ ${#ARGS[@]} -eq 0 ]; then
|
||||||
echo "Usage: $0 <command> [args...]" >&2
|
echo "Usage: $0 <command> [--class CLASS] [--title TITLE] [args...]" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
COMMAND="$1"
|
COMMAND="${ARGS[0]}"
|
||||||
shift
|
|
||||||
ARGS=("$@")
|
|
||||||
|
|
||||||
APP_NAME=$(basename "$COMMAND")
|
APP_NAME=$(basename "$COMMAND")
|
||||||
debug "Command: $COMMAND"
|
unset 'ARGS[0]'
|
||||||
debug "App name: $APP_NAME"
|
ARGS=("${ARGS[@]}")
|
||||||
debug "Args: ${ARGS[*]}"
|
|
||||||
|
|
||||||
# Extract --class and --title values from args if present
|
# If class/title were provided as flags, add them to command args (for apps that support them)
|
||||||
# Handle both --class VALUE and --class=VALUE formats
|
if [ -n "$CLASS" ]; then
|
||||||
CLASS_NAME=""
|
ARGS=("--class=$CLASS" "${ARGS[@]}")
|
||||||
TITLE_NAME=""
|
fi
|
||||||
for i in "${!ARGS[@]}"; do
|
if [ -n "$TITLE" ]; then
|
||||||
if [[ "${ARGS[$i]}" =~ ^--class=(.+)$ ]]; then
|
ARGS=("--title=$TITLE" "${ARGS[@]}")
|
||||||
CLASS_NAME="${BASH_REMATCH[1]}"
|
|
||||||
debug "Found class (format --class=VALUE): $CLASS_NAME"
|
|
||||||
elif [ "${ARGS[$i]}" = "--class" ] && [ $((i+1)) -lt ${#ARGS[@]} ]; then
|
|
||||||
CLASS_NAME="${ARGS[$((i+1))]}"
|
|
||||||
debug "Found class (format --class VALUE): $CLASS_NAME"
|
|
||||||
elif [[ "${ARGS[$i]}" =~ ^--title=(.+)$ ]]; then
|
|
||||||
TITLE_NAME="${BASH_REMATCH[1]}"
|
|
||||||
debug "Found title (format --title=VALUE): $TITLE_NAME"
|
|
||||||
elif [ "${ARGS[$i]}" = "--title" ] && [ $((i+1)) -lt ${#ARGS[@]} ]; then
|
|
||||||
TITLE_NAME="${ARGS[$((i+1))]}"
|
|
||||||
debug "Found title (format --title VALUE): $TITLE_NAME"
|
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
debug "Extracted CLASS_NAME: '$CLASS_NAME'"
|
|
||||||
debug "Extracted TITLE_NAME: '$TITLE_NAME'"
|
|
||||||
|
|
||||||
find_window_by_class() {
|
# Find window by app_id (sway uses app_id), title, or app name
|
||||||
|
find_window() {
|
||||||
local class="$1"
|
local class="$1"
|
||||||
debug "Searching for window by class: $class"
|
local title="$2"
|
||||||
local result
|
local app="$3"
|
||||||
result=$(swaymsg -t get_tree | jq -r --arg class "$class" '
|
|
||||||
|
# If class provided, search by app_id first (sway uses app_id)
|
||||||
|
if [ -n "$class" ]; then
|
||||||
|
swaymsg -t get_tree | jq -r --arg class "$class" '
|
||||||
recurse(.nodes[]?, .floating_nodes[]?) |
|
recurse(.nodes[]?, .floating_nodes[]?) |
|
||||||
select(
|
select((.app_id | type) == "string" and .app_id == $class) |
|
||||||
((.window_properties.class | type) == "string" and .window_properties.class == $class) or
|
|
||||||
((.app_id | type) == "string" and .app_id == $class)
|
|
||||||
) |
|
|
||||||
.id
|
.id
|
||||||
' | head -n 1)
|
' | head -n 1
|
||||||
debug "find_window_by_class result: '$result'"
|
return
|
||||||
echo "$result"
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
find_window_by_title() {
|
# If only title provided, search by title
|
||||||
local title="$1"
|
if [ -n "$title" ]; then
|
||||||
local app="$2"
|
swaymsg -t get_tree | jq -r --arg title "$title" '
|
||||||
local result
|
|
||||||
|
|
||||||
debug "Searching for window by title: '$title' and app: '$app'"
|
|
||||||
|
|
||||||
# Search for windows matching both app and title (most specific)
|
|
||||||
result=$(swaymsg -t get_tree | jq -r --arg title "$title" --arg app "$app" '
|
|
||||||
recurse(.nodes[]?, .floating_nodes[]?) |
|
|
||||||
select(
|
|
||||||
(
|
|
||||||
((.app_id | type) == "string" and (.app_id == $app or (.app_id | test($app; "i")))) or
|
|
||||||
((.window_properties.class | type) == "string" and (.window_properties.class == $app or (.window_properties.class | test($app; "i"))))
|
|
||||||
) and
|
|
||||||
((.name | type) == "string" and .name == $title)
|
|
||||||
) |
|
|
||||||
.id
|
|
||||||
' | head -n 1)
|
|
||||||
|
|
||||||
debug "find_window_by_title (app+title) result: '$result'"
|
|
||||||
[ -n "$result" ] && [ "$result" != "null" ] && echo "$result" && return
|
|
||||||
|
|
||||||
# Fall back to title-only exact match
|
|
||||||
debug "Falling back to title-only exact match"
|
|
||||||
result=$(swaymsg -t get_tree | jq -r --arg title "$title" '
|
|
||||||
recurse(.nodes[]?, .floating_nodes[]?) |
|
recurse(.nodes[]?, .floating_nodes[]?) |
|
||||||
select((.name | type) == "string" and .name == $title) |
|
select((.name | type) == "string" and .name == $title) |
|
||||||
.id
|
.id
|
||||||
' | head -n 1)
|
' | head -n 1
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
debug "find_window_by_title (title only) result: '$result'"
|
# Fallback to app name (search by app_id)
|
||||||
[ -n "$result" ] && [ "$result" != "null" ] && echo "$result" && return
|
swaymsg -t get_tree | jq -r --arg app "$app" '
|
||||||
|
|
||||||
# Final fallback: title-only case-insensitive match
|
|
||||||
debug "Falling back to title-only case-insensitive match"
|
|
||||||
result=$(swaymsg -t get_tree | jq -r --arg title "$title" '
|
|
||||||
recurse(.nodes[]?, .floating_nodes[]?) |
|
recurse(.nodes[]?, .floating_nodes[]?) |
|
||||||
select((.name | type) == "string" and (.name | test($title; "i"))) |
|
select((.app_id | type) == "string" and .app_id == $app) |
|
||||||
.id
|
.id
|
||||||
' | head -n 1)
|
' | head -n 1
|
||||||
debug "find_window_by_title (case-insensitive) result: '$result'"
|
|
||||||
echo "$result"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
find_window() {
|
# Try to find existing window
|
||||||
local app_name="$1"
|
WINDOW_ID=$(find_window "$CLASS" "$TITLE" "$APP_NAME")
|
||||||
debug "Searching for window by app name: $app_name"
|
|
||||||
local result
|
|
||||||
result=$(swaymsg -t get_tree | jq -r --arg app "$app_name" '
|
|
||||||
recurse(.nodes[]?, .floating_nodes[]?) |
|
|
||||||
select(
|
|
||||||
((.app_id | type) == "string" and (.app_id == $app or (.app_id | test($app; "i")))) or
|
|
||||||
((.window_properties.class | type) == "string" and (.window_properties.class == $app or (.window_properties.class | test($app; "i")))) or
|
|
||||||
((.name | type) == "string" and (.name | test($app; "i")))
|
|
||||||
) |
|
|
||||||
.id
|
|
||||||
' | head -n 1)
|
|
||||||
debug "find_window result: '$result'"
|
|
||||||
echo "$result"
|
|
||||||
}
|
|
||||||
|
|
||||||
focus_window() {
|
# Focus if found, otherwise launch
|
||||||
local window_id="$1"
|
if [ -n "$WINDOW_ID" ] && [ "$WINDOW_ID" != "null" ]; then
|
||||||
debug "Focusing window ID: $window_id"
|
swaymsg "[con_id=$WINDOW_ID]" focus
|
||||||
swaymsg "[con_id=$window_id]" focus
|
else
|
||||||
}
|
|
||||||
|
|
||||||
WINDOW_ID=""
|
|
||||||
|
|
||||||
debug "Starting window search..."
|
|
||||||
# Only search by class/title if provided - don't fall back to generic app search
|
|
||||||
# This prevents matching the wrong window
|
|
||||||
if [ -n "$CLASS_NAME" ]; then
|
|
||||||
WINDOW_ID=$(find_window_by_class "$CLASS_NAME")
|
|
||||||
debug "After class search: WINDOW_ID='$WINDOW_ID'"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ([ -z "$WINDOW_ID" ] || [ "$WINDOW_ID" = "null" ]) && [ -n "$TITLE_NAME" ]; then
|
|
||||||
WINDOW_ID=$(find_window_by_title "$TITLE_NAME" "$APP_NAME")
|
|
||||||
debug "After title search: WINDOW_ID='$WINDOW_ID'"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Only fall back to generic app search if we don't have class or title
|
|
||||||
# This means the user wants to focus any instance of the app
|
|
||||||
if ([ -z "$WINDOW_ID" ] || [ "$WINDOW_ID" = "null" ]) && [ -z "$CLASS_NAME" ] && [ -z "$TITLE_NAME" ]; then
|
|
||||||
WINDOW_ID=$(find_window "$APP_NAME")
|
|
||||||
debug "After app name search (no class/title): WINDOW_ID='$WINDOW_ID'"
|
|
||||||
|
|
||||||
([ -z "$WINDOW_ID" ] || [ "$WINDOW_ID" = "null" ]) && WINDOW_ID=$(find_window "${APP_NAME,,}")
|
|
||||||
debug "After lowercase app name search: WINDOW_ID='$WINDOW_ID'"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$WINDOW_ID" ] && [ "$WINDOW_ID" != "null" ] && [ "$WINDOW_ID" -eq "$WINDOW_ID" ] 2>/dev/null; then
|
|
||||||
debug "Window found! Focusing window ID: $WINDOW_ID"
|
|
||||||
focus_window "$WINDOW_ID"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
debug "No matching window found, launching new instance"
|
|
||||||
"$COMMAND" "${ARGS[@]}" >/dev/null 2>&1 &
|
"$COMMAND" "${ARGS[@]}" >/dev/null 2>&1 &
|
||||||
disown
|
disown
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
BIN
ssh/.ssh/config
BIN
ssh/.ssh/config
Binary file not shown.
|
|
@ -5,29 +5,28 @@ exec {
|
||||||
$(nix-locate -w polkit-gnome-authentication-agent-1 | awk '{print $NF}')
|
$(nix-locate -w polkit-gnome-authentication-agent-1 | awk '{print $NF}')
|
||||||
blueman-applet
|
blueman-applet
|
||||||
nm-applet
|
nm-applet
|
||||||
# swaync
|
# wlsunset -l -34.9 -L -56.2 -t 4500 -g 0.9
|
||||||
wlsunset -l -34.9 -L -56.2 -t 4500 -g 0.9
|
|
||||||
easyeffects --gapplication-service
|
easyeffects --gapplication-service
|
||||||
clapboard --record
|
clapboard --record
|
||||||
}
|
}
|
||||||
#
|
|
||||||
# # User Interface
|
# # User Interface
|
||||||
exec {
|
exec {
|
||||||
noctalia-shell
|
noctalia-shell
|
||||||
# ~/.local/bin/randwall
|
|
||||||
# ~/.local/bin/waybar.sh
|
|
||||||
}
|
}
|
||||||
#
|
|
||||||
# Applications
|
# Applications
|
||||||
exec {
|
exec {
|
||||||
$term --class="uy.com.mzunino"
|
$term --class="uy.com.mzunino"
|
||||||
slack
|
zen-twilight
|
||||||
davmail
|
|
||||||
thunderbird
|
thunderbird
|
||||||
zen
|
|
||||||
obsidian
|
obsidian
|
||||||
localsend_app
|
|
||||||
vesktop
|
vesktop
|
||||||
|
}
|
||||||
|
|
||||||
|
# Work Shit
|
||||||
|
exec {
|
||||||
|
slack
|
||||||
gtk-launch com.microsoft.Edge.flextop.msedge-cifhbcnohmdccbgoicgdjpfamggdegmo-Default
|
gtk-launch com.microsoft.Edge.flextop.msedge-cifhbcnohmdccbgoicgdjpfamggdegmo-Default
|
||||||
gtk-launch com.microsoft.Edge.flextop.msedge-faolnafnngnfdaknnbpnkhgohbobgegn-Default
|
gtk-launch com.microsoft.Edge.flextop.msedge-faolnafnngnfdaknnbpnkhgohbobgegn-Default
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
# System Controls
|
# System Controls
|
||||||
bindsym {
|
bindsym {
|
||||||
$mod+Shift+r exec swaymsg reload && notify-send "Reloaded sway config"
|
$mod+Shift+r exec swaymsg reload && notify-send "Reloaded sway config"
|
||||||
$mod+Shift+e exec --no-startup-id wlogout
|
$mod+Shift+e exec --no-startup-id noctalia-shell ipc call sessionMenu toggle
|
||||||
$mod+Escape exec ~/.local/bin/lock.sh
|
$mod+Escape exec ~/.local/bin/lock.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ bindsym {
|
||||||
$mod+n exec ~/.local/bin/sdm-ui.sh dmenu
|
$mod+n exec ~/.local/bin/sdm-ui.sh dmenu
|
||||||
$mod+o exec ~/.local/bin/launch-or-focus obsidian "cd /home/forbi/Documents/Vault && $term --class obsidian nvim"
|
$mod+o exec ~/.local/bin/launch-or-focus obsidian "cd /home/forbi/Documents/Vault && $term --class obsidian nvim"
|
||||||
$mod+e exec ~/.local/bin/launch-or-focus thunar
|
$mod+e exec ~/.local/bin/launch-or-focus thunar
|
||||||
$mod+y exec clapboard
|
$mod+y exec noctalia-shell ipc call launcher clipboard
|
||||||
$mod+b exec rofi-rbw --action copy
|
$mod+b exec rofi-rbw --action copy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,29 +91,25 @@ bindsym {
|
||||||
bindsym {
|
bindsym {
|
||||||
$mod+Shift+minus move scratchpad
|
$mod+Shift+minus move scratchpad
|
||||||
$mod+minus scratchpad show
|
$mod+minus scratchpad show
|
||||||
$mod+u [instance="claude.ai"] move scratchpad; [app_id="uy.com.mzunino"] scratchpad show, move position center, fullscreen disable, resize set 1366 768
|
$mod+u [app_id="uy.com.mzunino"] scratchpad show, move position center, fullscreen disable, resize set 1366 768
|
||||||
$mod+g [app_id="uy.com.mzunino"] move scratchpad; [instance="claude.ai"] scratchpad show, move position center, fullscreen disable, resize set 1366 768
|
|
||||||
$mod+Shift+u exec --no-startup-id $term --class="uy.com.mzunino"
|
$mod+Shift+u exec --no-startup-id $term --class="uy.com.mzunino"
|
||||||
$mod+shift+g exec chromium --new-window --app="https://claude.ai"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Special Functions
|
# Special Functions
|
||||||
bindsym {
|
bindsym {
|
||||||
F4 exec switch-windows
|
$mod+r exec --no-startup-id noctalia-shell ipc call screenRecorder toggle
|
||||||
$mod+r exec --no-startup-id ~/.local/bin/record.sh
|
|
||||||
$mod+p exec --no-startup-id grim -g "$(slurp -d)" - | swappy -f -
|
$mod+p exec --no-startup-id grim -g "$(slurp -d)" - | swappy -f -
|
||||||
$mod+shift+p exec --no-startup-id ~/.local/bin/screenshot-upload
|
$mod+shift+p exec --no-startup-id ~/.local/bin/screenshot-upload
|
||||||
$mod+F5 exec --no-startup-id ~/.local/bin/pause-notifications
|
$mod+F5 exec --no-startup-id ~/.local/bin/pause-notifications
|
||||||
$mod+shift+d exec ~/.local/bin/satty-window
|
$mod+shift+d exec ~/.local/bin/satty-window
|
||||||
}
|
}
|
||||||
|
|
||||||
# Multimedia Keys
|
|
||||||
bindsym {
|
bindsym {
|
||||||
XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 +2%
|
XF86AudioRaiseVolume exec --no-startup-id noctalia-shell ipc call volume increase
|
||||||
XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -2%
|
XF86AudioLowerVolume exec --no-startup-id noctalia-shell ipc call volume decrease
|
||||||
XF86AudioMute exec --no-startup-id pactl set-sink-mute 0 toggle
|
XF86AudioMute exec --no-startup-id noctalia-shell ipc call volume mute
|
||||||
XF86MonBrightnessUp exec --no-startup-id brightnessctl set +5%
|
XF86MonBrightnessUp exec --no-startup-id noctalia-shell ipc call brightness increase
|
||||||
XF86MonBrightnessDown exec --no-startup-id brightnessctl set 5%-
|
XF86MonBrightnessDown exec --no-startup-id noctalia-shell ipc call brightness decrease
|
||||||
}
|
}
|
||||||
|
|
||||||
# Mouse Bindings
|
# Mouse Bindings
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue