Log in on a plain workspace, not "code"
Browse files at this commit0c8c81ea97aabcb388021cdc1707ef4e4fa377bfParent: 09f9724- feat
- log in on a plain workspace, not "code"
2 changed files +47 -0
.config/niri/config.kdlmodified+18 -0
| @@ -80,6 +80,18 @@ layout { | ||
| 80 | 80 | |
| 81 | 81 | center-focused-column "never" |
| 82 | 82 | |
| 83 | + // Puts a plain workspace at index 1 on every output, above the declared | |
| 84 | + // named block — so the workspace waybar labels on HDMI-A-1 is 1, not 9. | |
| 85 | + // | |
| 86 | + // This is NOT a replacement for workspace_startup.sh, which was tested: | |
| 87 | + // alone it still logs in with the first NAMED workspace active, because it | |
| 88 | + // only creates the workspace, it never focuses it. The two go together — | |
| 89 | + // this one supplies index 1, the script focuses it. | |
| 90 | + // | |
| 91 | + // Cost, accepted knowingly: every Mod+<N> shifts by one, since | |
| 92 | + // workspace_nav.sh indexes plain workspaces and this adds one at the top. | |
| 93 | + empty-workspace-above-first | |
| 94 | + | |
| 83 | 95 | // New windows take the whole working area — the closest thing to dwindle |
| 84 | 96 | // handing a new window all the free space. 1.0 is in the preset cycle too, |
| 85 | 97 | // otherwise one Mod+R drops a window to 1/3 with no way back to full. |
| @@ -138,6 +150,12 @@ spawn-at-startup "sh" "-c" "sleep 3 && wl-paste --type text --watch cliphist sto | ||
| 138 | 150 | spawn-at-startup "sh" "-c" "sleep 3 && wl-paste --type image --watch cliphist store" |
| 139 | 151 | spawn-at-startup "sh" "-c" "sleep 4 && rfkill unblock bluetooth && bluetoothctl power on" |
| 140 | 152 | |
| 153 | +// The declared app workspaces below all get created on the first output niri | |
| 154 | +// connects (HDMI-A-1), so that monitor logs in showing "code". This puts every | |
| 155 | +// output back on a plain workspace. Early on purpose: it must finish before the | |
| 156 | +// sleep-3/sleep-4 apps map their windows, or one lands on the wrong monitor. | |
| 157 | +spawn-at-startup "sh" "-c" "sleep 1 && bash ~/.config/scripts/niri/workspace_startup.sh" | |
| 158 | + | |
| 141 | 159 | screenshot-path "~/Pictures/Screenshots/Screenshot from %Y-%m-%d %H-%M-%S.png" |
| 142 | 160 | |
| 143 | 161 | // Animations stay at niri's defaults (on), unlike Hyprland where they were off. |
.config/scripts/niri/workspace_startup.shadded+29 -0
| @@ -0,0 +1,29 @@ | ||
| 1 | +#!/usr/bin/env bash | |
| 2 | +# Put every output on a plain (unnamed) workspace at login. | |
| 3 | +# | |
| 4 | +# The app workspaces are declared in config.kdl, so niri creates them all on one | |
| 5 | +# output at startup and that output comes up showing "code" — the first declared | |
| 6 | +# one — instead of an empty workspace. Nothing else moves them until their | |
| 7 | +# Alt+<letter> bind runs, so the fix is a one-shot nudge: focus the first plain | |
| 8 | +# workspace on each output, then hand focus back to the output that had it | |
| 9 | +# (the one with `focus-at-startup`). | |
| 10 | +# | |
| 11 | +# focus-workspace takes an index into the FOCUSED output's list, hence the | |
| 12 | +# focus-monitor before each one — same reason workspace_nav.sh scopes by output. | |
| 13 | +set -euo pipefail | |
| 14 | + | |
| 15 | +ws=$(niri msg -j workspaces) | |
| 16 | +home=$(jq -r '.[] | select(.is_focused == true) | .output' <<<"$ws") | |
| 17 | + | |
| 18 | +while read -r out; do | |
| 19 | + idx=$(jq -r --arg o "$out" ' | |
| 20 | + [ .[] | select(.output == $o and .name == null) ] | sort_by(.idx) | .[0].idx // empty | |
| 21 | + ' <<<"$ws") | |
| 22 | + [ -n "$idx" ] || continue | |
| 23 | + niri msg action focus-monitor "$out" >/dev/null | |
| 24 | + niri msg action focus-workspace "$idx" >/dev/null | |
| 25 | +done < <(jq -r '[ .[].output ] | unique | .[]' <<<"$ws") | |
| 26 | + | |
| 27 | +if [ -n "$home" ]; then | |
| 28 | + niri msg action focus-monitor "$home" >/dev/null | |
| 29 | +fi |