This repository has no description
0

Configure Feed

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

sway: per-slot window marks (mod+<digit>)

+109
+109
2configs/desktops/sway/default.nix
··· 83 83 ] 84 84 ); 85 85 86 + # Mark a window and jump to it later, per slot. mod+ctrl+<digit> marks 87 + # the focused window (by container id) into that slot. mod+<digit> jumps 88 + # to the marked window: if its workspace is hidden it is moved to the 89 + # current screen, if it is shown on another screen focus switches there. 90 + # mod+shift+<digit> always brings the marked window's workspace to the 91 + # current screen. A stale mark (window closed) is dropped with a note. 92 + windowMark = pkgs.writeShellApplication { 93 + name = "sway-window-mark"; 94 + runtimeInputs = [ 95 + pkgs.sway 96 + pkgs.jq 97 + pkgs.coreutils 98 + pkgs.libnotify 99 + ]; 100 + text = '' 101 + MARKS="$HOME/.config/sway-window-marks" 102 + mkdir -p "$MARKS" 103 + 104 + if [ "$1" = "mark" ]; then 105 + SLOT="$2" 106 + INFO=$(swaymsg -r -t get_tree | jq -r ' 107 + [ .. | objects | select(.type == "con" and .focused == true) ] 108 + | .[0] // empty 109 + | [ .id, (.name // "unknown") ] | @tsv') 110 + if [ -z "$INFO" ]; then 111 + notify-send "Window" "no window focused" 2>/dev/null 112 + exit 0 113 + fi 114 + IFS=$'\t' read -r ID NAME <<< "$INFO" 115 + echo "$ID" > "$MARKS/$SLOT" 116 + notify-send "Window" "slot $SLOT: $NAME" 2>/dev/null 117 + exit 0 118 + fi 119 + 120 + SLOT="$1" 121 + ID=$(cat "$MARKS/$SLOT" 2>/dev/null || true) 122 + if [ -z "$ID" ]; then 123 + notify-send "Window" "no window in slot $SLOT" 2>/dev/null 124 + exit 0 125 + fi 126 + 127 + # Workspace that currently contains the marked window (empty if it died). 128 + WS=$(swaymsg -r -t get_tree | jq -r --argjson id "$ID" ' 129 + . as $t 130 + | [ path(.. | objects | select(.id == $id)) ] | .[0] as $p 131 + | if $p == null then empty 132 + else [ range(1; ($p | length) + 1) as $i 133 + | $t | getpath($p[0:$i]) 134 + | objects | select(.type == "workspace") | .name 135 + ] | .[0] // empty 136 + end') 137 + if [ -z "$WS" ]; then 138 + rm -f "$MARKS/$SLOT" 139 + notify-send "Window" "slot $SLOT: marked window is gone" 2>/dev/null 140 + exit 0 141 + fi 142 + 143 + # Screen the user is typing on, captured BEFORE the switch: switching 144 + # a workspace moves seat focus to the target's output, so the 145 + # focused output after the switch would be the wrong answer. 146 + CUR=$(swaymsg -r -t get_outputs | jq -r '.[] | select(.focused == true) | .name') 147 + # Shown on any output? A plain jump only brings the workspace when 148 + # it is hidden; "bring" always moves it here. 149 + SHOWN=$(swaymsg -r -t get_workspaces | jq -r --arg ws "$WS" '[.[] | select(.name == $ws) | .visible] | any') 150 + MOVE=false 151 + if [ $# -gt 1 ] && [ "$2" = "bring" ]; then 152 + MOVE=true 153 + elif [ "$SHOWN" != "true" ]; then 154 + MOVE=true 155 + fi 156 + swaymsg workspace "$WS" 157 + # Sway 1.12: nameless "move workspace to output <out>" moves the 158 + # focused (just-switched) workspace. A named first argument is 159 + # parsed as a container move to a workspace literally named 160 + # "<ws> to output <out>". 161 + if [ "$MOVE" = "true" ]; then 162 + swaymsg move workspace to output "$CUR" 163 + fi 164 + swaymsg "[con_id=$ID] focus" 165 + ''; 166 + }; 167 + 168 + # mod+<digit> = jump to window slot, mod+shift+<digit> = bring its 169 + # workspace here, mod+ctrl+<digit> = mark focused window into slot. 170 + windowBindings = lib.concatStringsSep "\n" ( 171 + lib.map 172 + (n: '' 173 + bindsym $mod+${toString n} exec ${lib.getExe windowMark} ${toString n} 174 + bindsym $mod+shift+${toString n} exec ${lib.getExe windowMark} ${toString n} bring 175 + bindsym $mod+ctrl+${toString n} exec ${lib.getExe windowMark} mark ${toString n} 176 + '') 177 + [ 178 + 1 179 + 2 180 + 3 181 + 4 182 + 5 183 + 6 184 + 7 185 + 8 186 + 9 187 + ] 188 + ); 189 + 86 190 in 87 191 { 88 192 # Make goto-workspace available system-wide for workspace switching ··· 425 529 # secondary, ...), mod+ctrl+F<n> marks the current screen as the target. 426 530 # While a mark exists, any mod+F<n> jumps to the marked screen. 427 531 ${screenBindings} 532 + 533 + # Window marks: mod+<digit> jumps to the window marked into that slot, 534 + # mod+shift+<digit> brings its workspace to the current screen, 535 + # mod+ctrl+<digit> marks the focused window into that slot. 536 + ${windowBindings} 428 537 429 538 # screenlock (random live video/image from ~/wallpaper via swaylock-plugin) 430 539 bindsym $mod+F11 exec ${lib.getExe' pkgs.systemd "systemctl"} --user start lock.target