Config et script pour focus app avec raccourcis

main
Gil Portenseigne 2026-09-25 16:53:32 +02:00
parent c647250db6
commit b9f53bd348
6 changed files with 120 additions and 55 deletions

View File

@ -0,0 +1,53 @@
#!/bin/sh
app="$1"
command="$2"
# Récupère les conteneurs correspondant à l'application.
windows=$(swaymsg -t get_tree | jq -r --arg app "$app" '
recurse(.nodes[], .floating_nodes[])
| select(
(.app_id == $app) or
(.window_properties.class == $app)
)
| .id
')
# Aucune fenêtre : lancer l'application
if [ -z "$windows" ]; then
swaymsg exec "$command"
exit 0
fi
# Récupère la fenêtre actuellement focalisée
focused=$(swaymsg -t get_tree | jq -r '
recurse(.nodes[], .floating_nodes[])
| select(.focused == true)
| .id
')
# Transforme la liste en tableau
set -- $windows
# Cherche la fenêtre suivante après celle qui est actuellement focus
next=""
found=0
for id in "$@"; do
if [ "$found" = 1 ]; then
next="$id"
break
fi
if [ "$id" = "$focused" ]; then
found=1
fi
done
# Si on était sur la dernière fenêtre, revenir à la première
if [ -z "$next" ]; then
next="$1"
fi
swaymsg "[con_id=$next] focus"

View File

@ -36,5 +36,5 @@
#}
# show/hide bar
bindsym $mad+b exec "swaymsg bar mode hide bar-0"
bindsym $mad+Shift+b exec "swaymsg bar mode dock bar-0"
#bindsym $mad+b exec "swaymsg bar mode hide bar-0"
#bindsym $mad+Shift+b exec "swaymsg bar mode dock bar-0"

View File

@ -4,7 +4,7 @@
# You can send windows there and get them back later.
# launch a terminal and move it to scratch at launch
exec --no-startup-id "sleep 10 && $term -t scratch -a scratch -m -e 'byobu'"
exec --no-startup-id "sleep 10 && $term -t scratch -a scratch -m -e byobu"
for_window [app_id="scratch"] floating enable, move absolute position center
for_window [app_id="scratch"] move scratchpad

View File

@ -11,9 +11,9 @@ bindsym $mod+ctrl+t exec $term
bindsym $mad+F1 exec "nakedhelp"
# infos system
bindsym $mad+m exec "$term --title=btop --app-id=btop btop"
bindsym $mad+i exec "$infosbox"
bindsym $mad+Shift+i exec "$infosystem"
#bindsym $mad+m exec "$term --title=btop --app-id=btop btop"
#bindsym $mad+i exec "$infosbox"
#bindsym $mad+Shift+i exec "$infosystem"
# lockscreen
bindsym $mad+Shift+l exec "$locker"
@ -31,8 +31,19 @@ bindsym $mad+Shift+x exec "$mailer"
bindsym $mad+w exec "$browser"
bindsym $mad+Shift+w exec "$browser"
# Applications
bindsym $mad+f exec ~/.config/sway/app-focus "firefox" "firefox"
bindsym $mad+m exec ~/.config/sway/app-focus "Mattermost.Desktop" "mattermost"
bindsym $mad+i exec ~/.config/sway/app-focus "jetbrains-idea" "idea"
bindsym $mad+j exec ~/.config/sway/app-focus "jitsi-meet" "jitsi-meet"
bindsym $mad+v exec ~/.config/sway/app-focus "freetube" "freetube"
bindsym $mad+s exec ~/.config/sway/app-focus "Spotify" "spotify"
bindsym $mad+d exec ~/.config/sway/app-focus "discord" "discord"
bindsym $mad+t exec ~/.config/sway/app-focus "foot" "foot"
bindsym $mad+b exec ~/.config/sway/app-focus "bruno" "bruno"
# audio bindings
bindsym $mad+v exec "$mixer"
#bindsym $mad+v exec "$mixer"
bindsym XF86AudioRaiseVolume exec --no-startup-id "amixer -q sset Master 5%+ unmute"
bindsym XF86AudioLowerVolume exec --no-startup-id "amixer -q sset Master 5%- unmute"
bindsym XF86AudioMute exec --no-startup-id "amixer set Master toggle"
@ -49,7 +60,7 @@ bindsym XF86AudioPlay exec --no-startup-id "mocp --toggle-pause"
bindsym XF86AudioNext exec --no-startup-id "mocp --next"
# start search
bindsym $mad+f exec "nakedlocate"
#bindsym $mad+f exec "nakedlocate"
# cleaner
bindsym $mad+Backspace exec "dotcleaner"
@ -78,3 +89,4 @@ bindsym $mod+comma exec $ipc settings-toggle
#bindsym --locked XF86AudioMute exec $ipc volume-mute
#bindsym --locked XF86MonBrightnessUp exec $ipc brightness-up
#bindsym --locked XF86MonBrightnessDown exec $ipc brightness-down

View File

@ -14,24 +14,24 @@
# Moving around:
# Move your focus around vim like
bindsym $mad+$left focus left
bindsym $mad+$down focus down
bindsym $mad+$up focus up
#bindsym $mad+$down focus down
#bindsym $mad+$up focus up
bindsym $mad+$right focus right
# Or use $mod+[up|down|left|right]
bindsym $mad+Left focus left
bindsym $mad+Down focus down
bindsym $mad+Up focus up
#bindsym $mad+Down focus down
#bindsym $mad+Up focus up
bindsym $mad+Right focus right
# Move the focused window with the same, but add Shift
bindsym $mod+Shift+$left move left
bindsym $mod+Shift+$down move down
bindsym $mod+Shift+$up move up
#bindsym $mod+Shift+$down move down
#bindsym $mod+Shift+$up move up
bindsym $mod+Shift+$right move right
# Ditto, with arrow keys
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
#bindsym $mod+Shift+Down move down
#bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right
# window switcher Alt+Tab
bindsym $mod+Tab workspace back_and_forth

View File

@ -1,42 +1,42 @@
# sway # modes
# Resizing containers:
set $mode_resize "<b>Resize</b>(<b>←↑↓→</b>) <b>Gaps</b>(<b>+/-</b>)"
mode --pango_markup $mode_resize {
# resize windows vimlike
bindsym $left resize shrink width 10px
bindsym $down resize grow height 10px
bindsym $up resize shrink height 10px
bindsym $right resize grow width 10px
# with arrow keys
bindsym Left resize shrink width 10px
bindsym Down resize grow height 10px
bindsym Up resize shrink height 10px
bindsym Right resize grow width 10px
# resize window Gaps with +/-
bindsym minus gaps inner current minus 5px
bindsym plus gaps inner current plus 5px
# Return to default mode
bindsym Return mode "default"
bindsym Escape mode "default"
}
# launch resize mode (Alt+r)
bindsym $mod+r mode $mode_resize
# Audio menu
set $mode_audio "<b>Audio</b>(<b>↑/↓/m</b>) <b>Micro</b>(<b>+/-/n</b>)"
mode --pango_markup $mode_audio {
# volume control
bindsym Up exec --no-startup-id "amixer -q sset Master 1%+ unmute"
bindsym Down exec --no-startup-id "amixer -q sset Master 1%- unmute"
bindsym m exec --no-startup-id "amixer set Master toggle"
# micro control
bindsym minus exec --no-startup-id "amixer -q sset Capture 1%- cap"
bindsym plus exec --no-startup-id "amixer -q sset Capture 1%+ cap"
bindsym n exec --no-startup-id "amixer set Capture toggle"
# Return to default mode
bindsym Return mode "default"
bindsym Escape mode "default"
}
# launch audio mode (Super+s)
bindsym $mad+s mode $mode_audio
#set $mode_resize "<b>Resize</b>(<b>←↑↓→</b>) <b>Gaps</b>(<b>+/-</b>)"
#mode --pango_markup $mode_resize {
# # resize windows vimlike
# bindsym $left resize shrink width 10px
# bindsym $down resize grow height 10px
# bindsym $up resize shrink height 10px
# bindsym $right resize grow width 10px
# # with arrow keys
# bindsym Left resize shrink width 10px
# bindsym Down resize grow height 10px
# bindsym Up resize shrink height 10px
# bindsym Right resize grow width 10px
# # resize window Gaps with +/-
# bindsym minus gaps inner current minus 5px
# bindsym plus gaps inner current plus 5px
# # Return to default mode
# bindsym Return mode "default"
# bindsym Escape mode "default"
#}
## launch resize mode (Alt+r)
#bindsym $mod+r mode $mode_resize
#
## Audio menu
#set $mode_audio "<b>Audio</b>(<b>↑/↓/m</b>) <b>Micro</b>(<b>+/-/n</b>)"
#mode --pango_markup $mode_audio {
# # volume control
# bindsym Up exec --no-startup-id "amixer -q sset Master 1%+ unmute"
# bindsym Down exec --no-startup-id "amixer -q sset Master 1%- unmute"
# bindsym m exec --no-startup-id "amixer set Master toggle"
# # micro control
# bindsym minus exec --no-startup-id "amixer -q sset Capture 1%- cap"
# bindsym plus exec --no-startup-id "amixer -q sset Capture 1%+ cap"
# bindsym n exec --no-startup-id "amixer set Capture toggle"
# # Return to default mode
# bindsym Return mode "default"
# bindsym Escape mode "default"
#}
## launch audio mode (Super+s)
#bindsym $mad+s mode $mode_audio