Skip to content

Commit

Permalink
Fix bspwm issues
Browse files Browse the repository at this point in the history
  • Loading branch information
OkayDave committed Oct 27, 2016
1 parent 1de1f4e commit e265e23
Show file tree
Hide file tree
Showing 5 changed files with 993 additions and 1,641 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
[#]*[#]
.\#*
.swp
barr-*.gem
Binary file removed barr-0.3.0.gem
Binary file not shown.
15 changes: 7 additions & 8 deletions lib/barr/blocks/bspwm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(" ")
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions spec/blocks/bspwm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -59,15 +59,15 @@
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

describe "#unfocused_desktop" do
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
Expand Down
Loading

0 comments on commit e265e23

Please sign in to comment.