This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

sway: numbered screen switching with per-slot marks (mod4+F1-F9)

+64 -55
+64 -55
2configs/desktops/sway/default.nix
··· 23 23 ''; 24 24 }; 25 25 26 + # Switch screens by number. mod+F<n> focuses the screen bound to slot n: 27 + # the output assigned via mod+ctrl+F<n> while one exists (so a bound 28 + # screen stays reachable after hot-plug renumbering), else the nth 29 + # output by position (1 = primary, 2 = first secondary, ...). 30 + # mod+ctrl+F<n> binds the currently focused screen to slot n. 31 + screenSwitch = pkgs.writeShellApplication { 32 + name = "sway-screen-switch"; 33 + runtimeInputs = [ 34 + pkgs.sway 35 + pkgs.jq 36 + pkgs.coreutils 37 + pkgs.libnotify 38 + ]; 39 + text = '' 40 + MARKS="$HOME/.config/sway-screen-marks" 41 + mkdir -p "$MARKS" 42 + 43 + if [ "$1" = "mark" ]; then 44 + SLOT="$2" 45 + CURRENT=$(swaymsg -r -t get_outputs | jq -r '.[] | select(.focused == true) | .name') 46 + if [ -n "$CURRENT" ]; then 47 + echo "$CURRENT" > "$MARKS/$SLOT" 48 + notify-send "Screen" "F$SLOT -> $CURRENT" 2>/dev/null 49 + fi 50 + exit 0 51 + fi 52 + 53 + MARKED=$(cat "$MARKS/$1" 2>/dev/null || true) 54 + 55 + if [ -n "$MARKED" ]; then 56 + swaymsg focus output "$MARKED" 57 + exit 0 58 + fi 59 + 60 + swaymsg -r -t get_outputs | jq -r 'sort_by(.x, .y) | .[].name' | sed -n "''${1}p" | while read -r TARGET; do 61 + [ -n "$TARGET" ] && swaymsg focus output "$TARGET" 62 + done 63 + ''; 64 + }; 65 + 66 + # mod+F<n> = switch to screen slot n, mod+ctrl+F<n> = bind current screen to slot n. 67 + screenBindings = lib.concatStringsSep "\n" ( 68 + lib.map 69 + (n: '' 70 + bindsym $mod+F${toString n} exec ${lib.getExe screenSwitch} ${toString n} 71 + bindsym $mod+ctrl+F${toString n} exec ${lib.getExe screenSwitch} mark ${toString n} 72 + '') 73 + [ 74 + 1 75 + 2 76 + 3 77 + 4 78 + 5 79 + 6 80 + 7 81 + 8 82 + 9 83 + ] 84 + ); 85 + 26 86 in 27 87 { 28 88 # Make goto-workspace available system-wide for workspace switching ··· 361 421 bindsym $mod+Tab exec ${pkgs.sway-overfocus}/bin/sway-overfocus split-rw group-rw split-dw group-dw 362 422 bindsym $mod+Escape workspace back_and_forth 363 423 364 - # Focus primary output 365 - bindsym $mod+F1 exec ${ 366 - lib.getExe ( 367 - pkgs.writeShellApplication { 368 - name = "focus-primary-output"; 369 - runtimeInputs = [ 370 - pkgs.sway 371 - pkgs.jq 372 - ]; 373 - text = '' 374 - PRIMARY=$(swaymsg -r -t get_outputs | jq -r 'sort_by(.x, .y) | .[0].name') 375 - swaymsg focus output "$PRIMARY" 376 - ''; 377 - } 378 - ) 379 - } 380 - 381 - # Cycle through secondary outputs 382 - bindsym $mod+F2 exec ${ 383 - lib.getExe ( 384 - pkgs.writeShellApplication { 385 - name = "cycle-secondary-outputs"; 386 - runtimeInputs = [ 387 - pkgs.sway 388 - pkgs.jq 389 - pkgs.gnugrep 390 - pkgs.coreutils 391 - ]; 392 - text = '' 393 - OUTPUTS=$(swaymsg -r -t get_outputs | jq -r 'sort_by(.x, .y)') 394 - PRIMARY=$(echo "$OUTPUTS" | jq -r '.[0].name') 395 - CURRENT=$(echo "$OUTPUTS" | jq -r '.[] | select(.focused == true).name') 396 - SECONDARIES=$(echo "$OUTPUTS" | jq -r '.[1:] | .[].name') 397 - 398 - if [ -z "$SECONDARIES" ]; then 399 - exit 0 400 - fi 401 - 402 - if [ "$CURRENT" = "$PRIMARY" ]; then 403 - # Focus first secondary 404 - NEXT=$(echo "$SECONDARIES" | head -n1) 405 - else 406 - # Find next secondary in the list 407 - NEXT=$(echo "$SECONDARIES" | grep -A1 "^$CURRENT$" | tail -n1) 408 - # If we're at the end, wrap to first secondary 409 - if [ "$NEXT" = "$CURRENT" ]; then 410 - NEXT=$(echo "$SECONDARIES" | head -n1) 411 - fi 412 - fi 413 - 414 - swaymsg focus output "$NEXT" 415 - ''; 416 - } 417 - ) 418 - } 424 + # Screen switching: mod+F<n> jumps to screen n (1 = primary, 2 = first 425 + # secondary, ...), mod+ctrl+F<n> marks the current screen as the target. 426 + # While a mark exists, any mod+F<n> jumps to the marked screen. 427 + ${screenBindings} 419 428 420 429 # screenlock (random live video/image from ~/wallpaper via swaylock-plugin) 421 430 bindsym $mod+F11 exec ${lib.getExe' pkgs.systemd "systemctl"} --user start lock.target