63 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			63 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
# vim: ft=ruby
 | 
						|
 | 
						|
class BspwmPager < Worker
 | 
						|
	def mainloop()
 | 
						|
		IO.popen("bspc subscribe") do |pipe|
 | 
						|
			pipe.each do |line|
 | 
						|
				monitor = line.split(":")[0]
 | 
						|
 | 
						|
				if @my_config.has_key?("monitors") == false || @my_config['monitors'].include?(monitor)
 | 
						|
					self.write parse_data(line)
 | 
						|
				end
 | 
						|
			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[1..-1].split(":").each do |part|
 | 
						|
			n = part[1..-1]
 | 
						|
 | 
						|
			if @my_config['blacklist'] != nil
 | 
						|
				if @my_config['blacklist'].include? n
 | 
						|
					next
 | 
						|
				end
 | 
						|
			end
 | 
						|
				
 | 
						|
			case part
 | 
						|
				when /^M.+/
 | 
						|
					out << "%{B#{@config['colours']['mon_focused']}} #{n} %{B-}"
 | 
						|
				when /^m.+/
 | 
						|
					out << " #{n} "
 | 
						|
				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 @my_config['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
 | 
						|
 | 
						|
Modules.add("bspwm_pager", "BspwmPager")
 |