Files
moltenbar/mod/bspwm_pager
T

55 lines
1.1 KiB
Ruby
Raw Normal View History

2016-09-27 04:18:43 +03:00
# vim: ft=ruby
2016-09-28 23:30:07 +03:00
class BspwmPager < Worker
def mainloop()
2016-10-23 02:08:29 +03:00
IO.popen("bspc subscribe") do |pipe|
2016-09-27 13:03:14 +03:00
pipe.each do |line|
2017-05-22 21:38:46 +03:00
self.write parse_data(line)
2016-09-27 04:18:43 +03:00
end
end
end
def parse_data(string)
# Example: WMDVI-I-1:o1:o2:f3:f4:O5:f6:f7:f8:f9:fh:LT:TF:G
out = []
2017-05-22 19:46:44 +03:00
string[1..-1].split(":").each do |part|
2016-09-27 04:18:43 +03:00
n = part[1..-1]
2016-10-04 15:34:25 +03:00
if @my_config['blacklist'] != nil
if @my_config['blacklist'].include? n
2016-09-27 04:18:43 +03:00
next
end
end
2017-05-22 21:38:46 +03:00
2016-09-27 04:18:43 +03:00
case part
2017-05-22 19:46:44 +03:00
when /^M.+/
out << "%{B#{@config['colours']['mon_focused']}} #{n} %{B-}"
when /^m.+/
out << " #{n} "
2016-09-27 04:18:43 +03:00
when /^(O|F|U).+/
2016-09-28 23:30:07 +03:00
out << "%{B#{@config['colours']['bg_focused']}} #{n} %{B-}"
2016-09-27 04:18:43 +03:00
when /^u.+/
out << "%{A:bspc desktop -f #{n}:}%{R} #{n} %{R}%{A}"
when /^o.+/
out << "%{A:bspc desktop -f #{n}:} #{n} %{A}"
when /^f.+/
2016-10-04 15:34:25 +03:00
if @my_config['show_empty_desktops']
2016-09-27 04:18:43 +03:00
out << " #{n} "
end
when /^L.+/
2017-05-22 21:38:46 +03:00
case n
when "T"
out << " t "
when "M"
out << " m "
end
2016-09-27 04:18:43 +03:00
end
end
return out.join.chomp
end
end
2016-09-28 23:30:07 +03:00
Modules.add("bspwm_pager", "BspwmPager")