From a4ee9d5e19c0613719d2979f353c5ced66d568e7 Mon Sep 17 00:00:00 2001 From: Greg Date: Wed, 23 Oct 2024 19:31:58 +0300 Subject: [PATCH] new switcher --- .config/sway/config | 7 ++++--- .scripts/kitty_shell.fish | 3 +++ .scripts/switcher.fish | 14 +++++++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100755 .scripts/kitty_shell.fish diff --git a/.config/sway/config b/.config/sway/config index 4da367e..1c06a7a 100644 --- a/.config/sway/config +++ b/.config/sway/config @@ -17,7 +17,7 @@ titlebar_padding 1 titlebar_border_thickness 1 smart_borders off gaps inner 10 - +for_window [app_id="kitty_shell"] floating enable, resize set 700 700, move center ### Variables # @@ -30,7 +30,7 @@ set $right l set $term kitty set $browser firefox set $menu fish -c 'rofi -show run -terminal $term' -set $switcher rofi -show window +set $switcher ~/.scripts/kitty_shell.fish ~/.scripts/switcher.fish set $laptop eDP-1 set $external DP-1 @@ -105,6 +105,7 @@ input "type:keyboard" { bindsym $mod+Return exec $term bindsym $mod+Shift+q kill bindsym $mod+Space exec $menu + bindsym $mod+Tab exec $switcher bindsym $mod+Backspace exec ~/.config/sway/power.fish bindsym $mod+grave exec ~/.config/sway/shot.fish bindsym $mod+backslash exec ~/.config/sway/search.fish @@ -125,7 +126,7 @@ input "type:keyboard" { # Moving around: # # Move your focus around - bindsym $mod+Tab focus next + #bindsym $mod+Tab focus next bindsym $mod+$left focus left bindsym $mod+$down focus down bindsym $mod+$up focus up diff --git a/.scripts/kitty_shell.fish b/.scripts/kitty_shell.fish new file mode 100755 index 0000000..c22f9dd --- /dev/null +++ b/.scripts/kitty_shell.fish @@ -0,0 +1,3 @@ +#!/usr/bin/fish + +kitty --class "kitty_shell" $argv diff --git a/.scripts/switcher.fish b/.scripts/switcher.fish index e42baae..a4ada33 100755 --- a/.scripts/switcher.fish +++ b/.scripts/switcher.fish @@ -1,4 +1,16 @@ #!/usr/bin/fish -swaymsg -t get_tree -r | jq -r '.. | select(.app_id?) | (.pid|tostring) + " " + .app_id + " " + .name' | fzf --with-nth 2.. | awk '{print $1}' | xargs printf "[pid=%d] focus" | xargs swaymsg +set lock /tmp/window_switcher_lock +test -e $lock && exit + +touch $lock + +set windows (swaymsg -t get_tree -r) +set query '.. | select(.app_id?) | (.pid|tostring) + " " + .app_id + " " + .name' +set fzf_options --with-nth 2.. +set id (echo $windows | jq -r $query | fzf $fzf_options | awk '{print $1}') + +swaymsg "[pid=$id]" focus + +rm $lock