From 6bf779a68e9c2ae240dd3c1503ffe7cbd9a37e74 Mon Sep 17 00:00:00 2001 From: Yuri Zamyatin Date: Fri, 26 Sep 2025 05:08:39 +0000 Subject: [PATCH] fixes --- arch-user/bin/sway/focus-cousin.sh | 16 ++++++++----- arch-user/bin/sway/search-mode.sh | 38 +++++++++++++----------------- arch-user/config/git/config | 4 ++++ arch-user/config/sway/config.tmpl | 8 +++---- linux-compat/home/.inputrc | 6 +++++ linux-compat/home/.vimrc | 4 ++-- 6 files changed, 42 insertions(+), 34 deletions(-) diff --git a/arch-user/bin/sway/focus-cousin.sh b/arch-user/bin/sway/focus-cousin.sh index 62bd5fb..1f22afc 100755 --- a/arch-user/bin/sway/focus-cousin.sh +++ b/arch-user/bin/sway/focus-cousin.sh @@ -1,15 +1,19 @@ #!/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 +def check_focused(parent; grandparent): + if .focused then + if grandparent and (grandparent.type == "con" or grandparent.type == "workspace") and (grandparent.nodes | length) > 1 then 1 else 0 end + else + . as $current | + ((.nodes[]? | check_focused($current; parent)), + (.floating_nodes[]? | check_focused($current; parent))) end; -find_focused_path | if length >= 3 and .[-2].type=="con" then 1 else 0 end + +first(check_focused(null; null) // 0) ') +#echo "$parent_has_sibl" if [ "$parent_has_sibl" = 1 ]; then swaymsg "focus parent; focus $1 sibling; focus child" else diff --git a/arch-user/bin/sway/search-mode.sh b/arch-user/bin/sway/search-mode.sh index 41c41cc..db1d898 100755 --- a/arch-user/bin/sway/search-mode.sh +++ b/arch-user/bin/sway/search-mode.sh @@ -1,18 +1,17 @@ -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; + swaymsg -t get_tree | jq -r ' + def calc_ws_name(ws_name): + if ws_name == "__i3_scratch" then "_" + elif (ws_name | test("^[0-9]+:")) then (ws_name | sub("^[0-9]+:"; "")) + else ws_name + end; def get_windows(workspace_name): - if .type == "con" and .pid != null and (.name // "") != "" then + if (.type == "con" or .type == "floating_con") and .pid != null and (.name // "") != "" then { id: .id, - name: .name, - app_id: (.app_id // .window_properties.class // "Unknown"), + name: .name | ascii_downcase, + app_id: (.app_id // .window_properties.class // "unknown") | ascii_downcase, workspace: workspace_name, focused: .focused } @@ -20,37 +19,32 @@ get_windows_with_workspace() { (.nodes[]? | get_windows(workspace_name)), (.floating_nodes[]? | get_windows(workspace_name)); - def get_workspaces: + def traverse_all: if .type == "workspace" then - . as $ws | .name as $ws_name | get_windows($ws_name) + . as $ws | (.name | calc_ws_name(.)) as $ws_name | get_windows($ws_name) else empty end, - (.nodes[]? | get_workspaces); + (.nodes[]? | traverse_all); - get_workspaces | + traverse_all | "\(.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" + printf "%s%s%s %s %s\n" "$workspace" "$indicator" "$id" "$app_id" "$name" done) -selection=$(echo "$formatted_list" | bemenu --prompt "/" --index "$(echo "$formatted_list" | awk '/]>/ {print NR-1 ":" $0}')" ) +selection=$(echo "$formatted_list" | bemenu --width-factor 100 --prompt "/" --index "$(echo "$formatted_list" | awk 'substr($0,2,1)==">" {print NR-1}')" ) [ -z "$selection" ] && exit 0 -window_id=$(echo "$selection" | sed 's/.*\/\([^]]*\)].*/\1/') +window_id=$(echo "$selection" | sed -E 's/^...([0-9]+).*/\1/') if [ -n "$window_id" ]; then swaymsg "[con_id=\"$window_id\"] focus" diff --git a/arch-user/config/git/config b/arch-user/config/git/config index 4ad2494..b88541d 100644 --- a/arch-user/config/git/config +++ b/arch-user/config/git/config @@ -5,3 +5,7 @@ defaultBranch = main [pull] rebase = false +[safe] + directory = * +[commit] + gpgsign = true diff --git a/arch-user/config/sway/config.tmpl b/arch-user/config/sway/config.tmpl index e3f9496..2b4ed3e 100644 --- a/arch-user/config/sway/config.tmpl +++ b/arch-user/config/sway/config.tmpl @@ -116,10 +116,10 @@ bindsym --to-code { bindsym --to-code { $mod+d scratchpad show $altmod+d sticky enable; move scratchpad - $mod+k focus floating - $altmod+k floating enable; sticky enable - $mod+h focus tiling - $altmod+h focus floating; floating disable; sticky disable + $mod+k focus tiling + $altmod+k focus floating; floating disable; sticky disable + $mod+h focus floating + $altmod+h floating enable; sticky enable $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 diff --git a/linux-compat/home/.inputrc b/linux-compat/home/.inputrc index 56c9753..e020474 100644 --- a/linux-compat/home/.inputrc +++ b/linux-compat/home/.inputrc @@ -63,3 +63,9 @@ set keymap vi-insert "\C-h":operate-and-get-next ################################# + +########### custom ############## +$if qalc +set show-mode-in-prompt off +$endif +################################# diff --git a/linux-compat/home/.vimrc b/linux-compat/home/.vimrc index b121b3f..32cfb53 100644 --- a/linux-compat/home/.vimrc +++ b/linux-compat/home/.vimrc @@ -93,7 +93,7 @@ noremap! " i -> k noremap i k noremap I K -noremap! +"noremap! " breaks tab " o -> l noremap o l noremap O L @@ -145,7 +145,7 @@ noremap! " i -> k noremap и к noremap И К -noremap! +"noremap! " breaks tab " o -> l noremap о л noremap О Л