~funcrab


#18 Window Class Specification: switch-to-app-or-urgent-or-lru-window 2 years ago

Comment by ~funcrab on ~tsdh/swayr

I set it up like this. It is convenient. Thanks.

https://paste.sr.ht/~funcrab/24f22b2136f9a54e6f6de82a018ba3017499e5a3

#18 Window Class Specification: switch-to-app-or-urgent-or-lru-window 3 years ago

Comment by ~funcrab on ~tsdh/swayr

Done. After doing the following, $mod+ctrl+1 switches alternately between the window marked 1 and the current window. Convenient! You work fast!

$ grep ^source ~/.cache/paru/clone/swayr-git/PKGBUILD
source=("${pkgname%-*}::git+https://git.sr.ht/~tsdh/swayr#commit=90a0bd7cb9445e9afe0932cb77cab375b46cf36c")
$
$ paru -Qs swayr-git
local/swayr-git r260.90a0bd7-1
    Swayr is a window switcher (and more) for sway
$ pgrep swayr
$ 
$ which swayr swayrd
/usr/bin/swayr
/usr/bin/swayrd
$ swayrd &
[1] 798549
$

~/.config/sway/config

# window switch setting
bindsym $mod+alt+0 mark 0
bindsym $mod+alt+1 mark 1
bindsym $mod+alt+2 mark 2
bindsym $mod+alt+3 mark 3
bindsym $mod+alt+4 mark 4
bindsym $mod+alt+5 mark 5
bindsym $mod+alt+6 mark 6
bindsym $mod+alt+7 mark 7
bindsym $mod+alt+8 mark 8
bindsym $mod+alt+9 mark 9
bindsym $mod+ctrl+0 exec swayr switch-to-mark-or-urgent-or-lru-window 0
bindsym $mod+ctrl+1 exec swayr switch-to-mark-or-urgent-or-lru-window 1
bindsym $mod+ctrl+2 exec swayr switch-to-mark-or-urgent-or-lru-window 2
bindsym $mod+ctrl+3 exec swayr switch-to-mark-or-urgent-or-lru-window 3
bindsym $mod+ctrl+4 exec swayr switch-to-mark-or-urgent-or-lru-window 4
bindsym $mod+ctrl+5 exec swayr switch-to-mark-or-urgent-or-lru-window 5
bindsym $mod+ctrl+6 exec swayr switch-to-mark-or-urgent-or-lru-window 6
bindsym $mod+ctrl+7 exec swayr switch-to-mark-or-urgent-or-lru-window 7
bindsym $mod+ctrl+8 exec swayr switch-to-mark-or-urgent-or-lru-window 8
bindsym $mod+ctrl+9 exec swayr switch-to-mark-or-urgent-or-lru-window 9

Thank you

#18 Window Class Specification: switch-to-app-or-urgent-or-lru-window 3 years ago

Comment by ~funcrab on ~tsdh/swayr

So the windows class was for specifying the name of the application in X? I was mistaken. Wanting to memorize the window is the same as what I mentioned above, the concept of mark. It is good to know that this is feasible with the standard sway functionality. My apologies.

I think you suggest having another switch-to-mark-or-urgent-or-lru-window command which you can call like swayr switch-to-mark-or-urgent-or-lru-window 2 which would switch to the window with mark 2, or if that doesn't exist or is already focused, switch to the last recently used window?

Yeah, Looks good👍

#18 Window Class Specification: switch-to-app-or-urgent-or-lru-window 3 years ago

Comment by ~funcrab on ~tsdh/swayr

I have been able to memorize and switch the switch target by the following with the help of sway's irc people through trial and error. There seems to be a concept called mark.

~/.config/sway/config

##################################
# window switch setting
set $mode_set_switch_window "set_switch_window: [0]-[9]"
mode $mode_set_switch_window {
    bindsym 1 mark 1; mode "default"
    bindsym 2 mark 2; mode "default"
    bindsym 3 mark 3; mode "default"
    bindsym 4 mark 4; mode "default"
    bindsym 5 mark 5; mode "default"
    bindsym 6 mark 6; mode "default"
    bindsym 7 mark 7; mode "default"
    bindsym 8 mark 8; mode "default"
    bindsym 9 mark 9; mode "default"
    bindsym 0 mark 0; mode "default"
    bindsym Return mode "default"
    bindsym Escape mode "default"
}
bindsym $mod+ctrl+t mode $mode_set_switch_window
set $mode_switch_window "switch_window: [0]-[9]"
mode $mode_switch_window {
    bindsym 1 [con_mark="1"] focus; mode "default"
    bindsym 2 [con_mark="2"] focus; mode "default"
    bindsym 3 [con_mark="3"] focus; mode "default"
    bindsym 4 [con_mark="4"] focus; mode "default"
    bindsym 5 [con_mark="5"] focus; mode "default"
    bindsym 6 [con_mark="6"] focus; mode "default"
    bindsym 7 [con_mark="7"] focus; mode "default"
    bindsym 8 [con_mark="8"] focus; mode "default"
    bindsym 9 [con_mark="9"] focus; mode "default"
    bindsym 0 [con_mark="0"] focus; mode "default"
    bindsym t mode $mode_set_switch_window
    bindsym Return mode "default"
    bindsym Escape mode "default"
}
bindsym $mod+t mode $mode_switch_window

It would be useful if this mark could be the target of switch-to-urgent-or-lru-window, but what do you think? I imagine that this would allow for the task1 and task2 functions you mentioned in Ticket #13.

#18 Window Class Specification: switch-to-app-or-urgent-or-lru-window 3 years ago

Comment by ~funcrab on ~tsdh/swayr

I'm sorry. The title was wrong. I can't seem to edit it from me, so please change it below if you can.

Window Class Specification: switch-to-app-or-urgent-or-lru-window

#18 Window Class Specification: switch-to-app-or-urgent-or-lru-window 3 years ago

Ticket created by ~funcrab on ~tsdh/swayr

Hello.

The description of switch-to-app-or-urgent-or-lru-window is as follows

switch-to-app-or-urgent-or-lru-window
    Switch to the given app (given by app_id or window class) if that's not currently focused.  If it is, switch to the next urgent window (if any) or to last recently used window

I am wondering if it is possible to memorize this window class and make it the target for focus switching.

Is the window class here the same as the one obtained with the following command?

swaymsg -t get_tree | jq -r '..|try select(.focused == true)'

I am trying to achieve the following, but I am having trouble switching focus.

~/.config/sway/config

bindsym $mod+alt+ctrl+1 exec ~/.config/sway/window_id_set_or_switch.sh 1 set
bindsym $mod+alt+1      exec ~/.config/sway/window_id_set_or_switch.sh 1 switch

~/.config/sway/window_id_set_or_switch.sh

#!/bin/bash
KEY=$1
COMMAND=$2

if [ "$COMMAND" = "set" ] ; then
    swaymsg -t get_tree | jq -r '..|try select(.focused == true) .id' > /tmp/sway-window-id_$KEY
elif [ "$COMMAND" = "switch" ] ; then
    WINDOW_ID=$(cat /tmp/sway-window-id_$KEYNUM)
    echo $WINDOW_ID
    swayr switch-to-app-or-urgent-or-lru-window $WINDOW_ID
fi

Am I misunderstanding something?

#16 LRU with specific application 3 years ago

Comment by ~funcrab on ~tsdh/swayr

It's done! Very comfortable. Thank you!

#16 LRU with specific application 3 years ago

Comment by ~funcrab on ~tsdh/swayr

The following had the same result

$ swayr -- switch_to_app_or_urgent_or_lru_window org.qutebrowser.qutebrowser
$ swayr -- switch_to_app_or_urgent_or_lru_window qutebrowser
$ swayr -- switch_to_app_or_urgent_or_lru_window

#16 LRU with specific application 3 years ago

Comment by ~funcrab on ~tsdh/swayr

Thanks. I was able to build it.

I can't get execution to work. Am I writing the command incorrectly?

$ paru -Qs swayr-git
local/swayr-git r255.2702a69-1
    Swayr is a window switcher (and more) for sway
$ pgrep swayr
$ 
$ which swayr swayrd
/usr/bin/swayr
/usr/bin/swayrd
$ swayrd &
 23794
$ swayr switch_to_app_or_urgent_or_lru_window org.qutebrowser.qutebrowser
error: The subcommand 'switch_to_app_or_urgent_or_lru_window' wasn't recognized

	Did you mean 'switch-window' or 'switch-workspace' or 'switch-output' or 'switch-workspace-or-window' or 'switch-workspace-container-or-window' or 'switch-to' or 'switch-to-urgent-or-lru-window' or 'switch-to-app-or-urgent-or-lru-window'?

If you believe you received this message in error, try re-running with 'swayr -- switch_to_app_or_urgent_or_lru_window'

USAGE:
    swayr <SUBCOMMAND>

For more information try --help
$ pgrep -l qute
3289 qutebrowser
$ 

#16 LRU with specific application 3 years ago

Comment by ~funcrab on ~tsdh/swayr

Sorry I'm tripping over the basics, where is the address of the source? I rewrote the following PKGBUILD for swayr-git on Arch Linux, but I can't makepkg -is

#source=("${pkgname%-*}::git+https://git.sr.ht/~tsdh/swayr/")
#source=("${pkgname%-*}::git+https://git.sr.ht/~tsdh/swayr/next/")
#source=("${pkgname%-*}::git+https://git.sr.ht/~tsdh/swayr/tree/next/")
source=("${pkgname%-*}::git+https://git.sr.ht/~tsdh/swayr/commit/2702a69925da82aff2acc563a882a62a0f3bd3ce")