2016-09-27 01:18:43 +00:00
|
|
|
# vim: ft=ruby
|
|
|
|
|
|
|
|
class ModBspwmPager < ModBasic
|
|
|
|
@@mod_name = 'bspwm_pager'
|
|
|
|
|
|
|
|
def data_loop()
|
|
|
|
while true do
|
2016-09-27 10:03:14 +00:00
|
|
|
pipe = IO.popen("bspc subscribe")
|
|
|
|
$children << pipe.pid
|
|
|
|
|
|
|
|
pipe.each do |line|
|
2016-09-27 01:18:43 +00:00
|
|
|
$panel_data[@@mod_name.to_sym] = parse_data(line.chomp)
|
|
|
|
$queue << 1
|
|
|
|
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 = []
|
|
|
|
|
|
|
|
string.split(":").each do |part|
|
|
|
|
n = part[1..-1]
|
|
|
|
|
|
|
|
if $config['mod']['bspwm_pager']['blacklist'] != nil
|
|
|
|
if $config['mod']['bspwm_pager']['blacklist'].include? n
|
|
|
|
next
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
case part
|
|
|
|
when /^(O|F|U).+/
|
|
|
|
out << "%{B#{$config['colours']['bg_focused']}} #{n} %{B-}"
|
|
|
|
when /^u.+/
|
|
|
|
out << "%{A:bspc desktop -f #{n}:}%{R} #{n} %{R}%{A}"
|
|
|
|
when /^o.+/
|
|
|
|
out << "%{A:bspc desktop -f #{n}:} #{n} %{A}"
|
|
|
|
when /^f.+/
|
|
|
|
if $config['mod']['bspwm_pager']['show_empty_desktops']
|
|
|
|
out << " #{n} "
|
|
|
|
end
|
|
|
|
when /^L.+/
|
|
|
|
@layout = n
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
case @layout
|
|
|
|
when "T"
|
|
|
|
layout_flag = "t"
|
|
|
|
when "M"
|
|
|
|
layout_flag = "m"
|
|
|
|
end
|
|
|
|
|
|
|
|
out << " #{layout_flag} "
|
|
|
|
|
|
|
|
return out.join.chomp
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-09-27 07:27:52 +00:00
|
|
|
ModBspwmPager.new.mainloop()
|