diff --git a/arch-user/bin/ai b/arch-user/bin/ai index b69d718..9442ad9 100755 --- a/arch-user/bin/ai +++ b/arch-user/bin/ai @@ -3,12 +3,12 @@ role="$1" shift +session_ts="$(date +%s)" if [ -n "$1" ]; then - aichat --role "$role" "$@" -else - session_ts="$(date +%s)" - while true; do - read -e -r -p "> " input - aichat --save-session --session "$session_ts" --role "$role" "$input" - done + aichat --save-session --session "$session_ts" --role "$role" "$@" fi + +while true; do + read -e -r -p "> " input + aichat --save-session --session "$session_ts" --role "$role" "$input" +done diff --git a/arch-user/bin/sway/focus-cousin.sh b/arch-user/bin/sway/focus-cousin.sh new file mode 100755 index 0000000..62bd5fb --- /dev/null +++ b/arch-user/bin/sway/focus-cousin.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +parent_has_sibl=$(swaymsg -t get_tree | jq ' +def find_focused_path: + if .focused then [.] + elif .nodes then + [.] + (.nodes[] | find_focused_path | select(length > 0)) + else empty + end; +find_focused_path | if length >= 3 and .[-2].type=="con" then 1 else 0 end +') + +if [ "$parent_has_sibl" = 1 ]; then + swaymsg "focus parent; focus $1 sibling; focus child" +else + swaymsg "focus $1 sibling; focus child" +fi diff --git a/arch-user/bin/sway/search-mode.sh b/arch-user/bin/sway/search-mode.sh new file mode 100755 index 0000000..41c41cc --- /dev/null +++ b/arch-user/bin/sway/search-mode.sh @@ -0,0 +1,60 @@ +MAX_TITLE_LENGTH=600 + +get_windows_with_workspace() { + swaymsg -t get_tree | jq -r --arg max_len "$MAX_TITLE_LENGTH" ' + def get_workspace_name(node): + if node.type == "workspace" then node.name + elif node.parent then get_workspace_name(node.parent) + else "Unknown" end; + + def get_windows(workspace_name): + if .type == "con" and .pid != null and (.name // "") != "" then + { + id: .id, + name: .name, + app_id: (.app_id // .window_properties.class // "Unknown"), + workspace: workspace_name, + focused: .focused + } + else empty end, + (.nodes[]? | get_windows(workspace_name)), + (.floating_nodes[]? | get_windows(workspace_name)); + + def get_workspaces: + if .type == "workspace" then + . as $ws | .name as $ws_name | get_windows($ws_name) + else empty end, + (.nodes[]? | get_workspaces); + + get_workspaces | + "\(.id)|\(.app_id)|\(.name)|\(.workspace)|\(.focused)" + ' +} +window_list=$(get_windows_with_workspace) + +formatted_list=$(echo "$window_list" | while IFS='|' read -r id app_id name workspace focused; do + if [ ${#name} -gt $MAX_TITLE_LENGTH ]; then + truncated_name="${name:0:$((MAX_TITLE_LENGTH-3))}..." + else + truncated_name="$name" + fi + if [ "$focused" = "true" ]; then + indicator="> " + else + indicator=" " + fi + + printf "[%s/%s]%s %s: %s\n" "$workspace" "$id" "$indicator" "$app_id" "$truncated_name" +done) + +selection=$(echo "$formatted_list" | bemenu --prompt "/" --index "$(echo "$formatted_list" | awk '/]>/ {print NR-1 ":" $0}')" ) +[ -z "$selection" ] && exit 0 + +window_id=$(echo "$selection" | sed 's/.*\/\([^]]*\)].*/\1/') + +if [ -n "$window_id" ]; then + swaymsg "[con_id=\"$window_id\"] focus" +else + echo "Failed to extract window ID." + exit 1 +fi diff --git a/arch-user/config/sway/config.tmpl b/arch-user/config/sway/config.tmpl index 904d680..e3f9496 100644 --- a/arch-user/config/sway/config.tmpl +++ b/arch-user/config/sway/config.tmpl @@ -16,6 +16,7 @@ default_border pixel 2 gaps inner 4 smart_borders on smart_gaps on +show_marks on title_align center font pango:{{ .theme.font.name_regular }} {{ .theme.font.size_base_pt }} output * bg #{{ .theme.color.bg }} solid_color @@ -74,6 +75,11 @@ bindgesture swipe:left workspace next ############################################ ############### containers ################# +# numeric row +bindsym --to-code { + $mod+Minus opacity minus 0.05 + $altmod+Minus opacity plus 0.05 +} # top row - layouts bindsym --to-code { $mod+p layout splitv @@ -91,12 +97,12 @@ bindsym --to-code { } # mid row - focus, movement bindsym --to-code { - $mod+$fwd focus child + $mod+$fwd exec ~/.local/bin/sway/focus-cousin.sh prev $mod+$left focus left $mod+$up focus up $mod+$down focus down $mod+$right focus right - $mod+$bwd focus parent + $mod+$bwd exec ~/.local/bin/sway/focus-cousin.sh next $altmod+$left move left 40px $altmod+$up move up 40px $altmod+$down move down 40px @@ -110,17 +116,14 @@ bindsym --to-code { bindsym --to-code { $mod+d scratchpad show $altmod+d sticky enable; move scratchpad - $mod+z focus tiling - $altmod+z focus floating; floating disable; sticky disable - $mod+h focus floating - $altmod+h floating enable; sticky enable - $mod+k focus prev sibling - $mod+Comma opacity minus 0.05 - $mod+Period opacity plus 0.05 - $mod+slash focus next sibling + $mod+k focus floating + $altmod+k floating enable; sticky enable + $mod+h focus tiling + $altmod+h focus floating; floating disable; sticky disable $mod+x exec wtype -M ctrl x -m ctrl $mod+c exec wtype -M ctrl c -m ctrl $mod+v exec wtype -M ctrl v -m ctrl + $mod+Slash exec ~/.local/bin/sway/search-mode.sh } floating_modifier $mod normal ############################################