forge
Explore
Log in

Don't you dare go Hollow

Log in on a plain workspace, not "code"

Browse files at this commit

0c8c81ea97aabcb388021cdc1707ef4e4fa377bfAhmet Kaan GümüşParent: 09f9724
  • feat
    • log in on a plain workspace, not "code"
Show full message
feat(niri): log in on a plain workspace, not "code"

The eight declared `workspace "name"` nodes are all created on the first
output niri connects (HDMI-A-1, 14ms before DP-1), and niri makes the
first declared one active there — so the second monitor logged in showing
"code".

workspace_startup.sh focuses the first plain workspace on every output,
then hands focus back to the focus-at-startup output.
`empty-workspace-above-first` puts that plain workspace at index 1 so it
sits above the named block and waybar labels it 1 rather than 9.

Both are needed. The option alone was tested by relogin and still comes
up on "code" — it creates the workspace but never focuses it. It also
shifts every Mod+<N> by one, which is accepted.
.config/niri/config.kdlmodified+18 -0
@@ -80,6 +80,18 @@ layout {
8080
8181 center-focused-column "never"
8282
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+
8395 // New windows take the whole working area — the closest thing to dwindle
8496 // handing a new window all the free space. 1.0 is in the preset cycle too,
8597 // 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
138150 spawn-at-startup "sh" "-c" "sleep 3 && wl-paste --type image --watch cliphist store"
139151 spawn-at-startup "sh" "-c" "sleep 4 && rfkill unblock bluetooth && bluetoothctl power on"
140152
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+
141159 screenshot-path "~/Pictures/Screenshots/Screenshot from %Y-%m-%d %H-%M-%S.png"
142160
143161 // 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