diff --git a/.gitignore b/.gitignore index 381affa..566793e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ [#]*[#] .\#* .swp +barr-*.gem diff --git a/barr-0.3.0.gem b/barr-0.3.0.gem deleted file mode 100644 index 19d1b0c..0000000 Binary files a/barr-0.3.0.gem and /dev/null differ diff --git a/lib/barr/blocks/bspwm.rb b/lib/barr/blocks/bspwm.rb index 8024363..5228ed1 100644 --- a/lib/barr/blocks/bspwm.rb +++ b/lib/barr/blocks/bspwm.rb @@ -19,18 +19,17 @@ def update! @tree = nil op = [] focused = "" - bsp_tree["monitors"].each do |monitor| - next if monitor["name"] != @monitor - focused = monitor["focusedDesktopName"] + next if (monitor["id"] != @monitor) && (monitor["name"] != @monitor) + focused = monitor["focusedDesktopId"] monitor["desktops"].each do |desktop| - if desktop["name"] == focused + if desktop["id"] == focused op << focused_desktop(desktop) else op << unfocused_desktop(desktop) end end - + end @output = op.join(" ") @@ -53,15 +52,15 @@ def focused_desktop desktop def unfocused_desktop desktop op = "" - op += "%{A:bspc desktop -f #{desktop["name"].gsub(":","\:")}:} " + op += "%{A:bspc desktop -f #{desktop["id"]}:} " op += "#{desktop["name"]}" op += " %{A}" return op end - + def first_monitor - bsp_tree["primaryMonitorName"] + bsp_tree["monitors"].first["id"] end def sys_cmd diff --git a/spec/blocks/bspwm_spec.rb b/spec/blocks/bspwm_spec.rb index 54600a5..04b2b86 100644 --- a/spec/blocks/bspwm_spec.rb +++ b/spec/blocks/bspwm_spec.rb @@ -17,7 +17,7 @@ end it "sets default monitor" do - expect(subject.monitor).to eq("DP-4") + expect(subject.monitor).to eq(2097153) end end @@ -30,8 +30,8 @@ end it "desktops" do - expect(subject.tree["monitors"].first["desktops"].count).to eq(10) - expect(subject.tree["monitors"].first["desktops"].first["name"]).to eq("I") + expect(subject.tree["monitors"].first["desktops"].count).to eq(6) + expect(subject.tree["monitors"].first["desktops"].first["name"]).to eq("web") end end @@ -40,7 +40,7 @@ before { subject.update! } it "renders output correctly" do - expect(subject.output).to eq("> I < %{A:bspc desktop -f II:} II %{A} %{A:bspc desktop -f III:} III %{A} %{A:bspc desktop -f IV:} IV %{A} %{A:bspc desktop -f V:} V %{A} %{A:bspc desktop -f VI:} VI %{A} %{A:bspc desktop -f VII:} VII %{A} %{A:bspc desktop -f VIII:} VIII %{A} %{A:bspc desktop -f IX:} IX %{A} %{A:bspc desktop -f X:} X %{A}") + expect(subject.output).to eq("> web < %{A:bspc desktop -f 2097156:} media %{A} %{A:bspc desktop -f 2097157:} web %{A} %{A:bspc desktop -f 2097158:} shell %{A} %{A:bspc desktop -f 2097159:} steam %{A} %{A:bspc desktop -f 2097160:} sys %{A}") end end @@ -59,7 +59,7 @@ before { @op = subject.focused_desktop(@fd) } it "renders in the correct format" do - expect(@op).to eq("%{R}> I <%{R}") + expect(@op).to eq("%{R}> web <%{R}") end end @@ -67,7 +67,7 @@ before { @op = subject.unfocused_desktop(@ud) } it "renders in the correct format" do - expect(@op).to eq("%{A:bspc desktop -f X:} X %{A}") + expect(@op).to eq("%{A:bspc desktop -f 2097160:} sys %{A}") end end end diff --git a/spec/mocks/bspwm.rb b/spec/mocks/bspwm.rb index 4e1ec37..df538b6 100644 --- a/spec/mocks/bspwm.rb +++ b/spec/mocks/bspwm.rb @@ -1,1630 +1,982 @@ - $bsp_json = <