rewrote mod_bspwm_pager
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
717dbfb8bd
commit
71940157c7
|
@ -12,38 +12,68 @@ class BspwmPager < Worker
|
|||
def parse_data(string)
|
||||
# Example: WMDVI-I-1:o1:o2:f3:f4:O5:f6:f7:f8:f9:fh:LT:TF:G
|
||||
out = []
|
||||
monitor = ""
|
||||
state = {
|
||||
monitors: {},
|
||||
layout: ""
|
||||
}
|
||||
|
||||
string[1..-1].split(":").each do |part|
|
||||
string.chomp[1..-1].split(":").each do |part|
|
||||
n = part[1..-1]
|
||||
|
||||
if @my_config['blacklist'] != nil
|
||||
if @my_config['blacklist'].include? n
|
||||
next
|
||||
if part[0] =~ /^[Mm]$/
|
||||
monitor = n
|
||||
state[:monitors][monitor] = {
|
||||
desktops: {}
|
||||
}
|
||||
|
||||
state[:monitors][monitor][:focused] = true if part[0] == "M"
|
||||
elsif part[0] =~ /^[OFUofu]$/
|
||||
d_focused = true if part[0] =~ /[OFU]/
|
||||
d_occupied = true if part[0] =~ /[Oo]/
|
||||
d_urgent = true if part[0] =~ /[Uu]/
|
||||
|
||||
state[:monitors][monitor][:desktops][n] = {
|
||||
focused: d_focused,
|
||||
occupied: d_occupied,
|
||||
urgent: d_urgent
|
||||
}
|
||||
elsif part[0] == "L"
|
||||
state[:layout] = n
|
||||
end
|
||||
end
|
||||
|
||||
state[:monitors].each do |m_name, m|
|
||||
if @my_config['monitors'] != nil
|
||||
next unless @my_config['monitors'].include?(m_name)
|
||||
end
|
||||
|
||||
if state[:monitors].count > 2 or @my_config['show_single_monitor']
|
||||
if m[:focused]
|
||||
out << "%{B#{@config['colours']['mon_focused']}} #{m_name} %{B-}"
|
||||
else
|
||||
out << " #{m_name} "
|
||||
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.+/
|
||||
m[:desktops].each do |d_name, d|
|
||||
if d[:focused]
|
||||
out << "%{B#{@config['colours']['bg_focused']}} #{d_name} %{B-}"
|
||||
elsif d[:urgent]
|
||||
out << "%{A:bspc desktop -f #{d_name}:}%{R} #{d_name} %{R}%{A}"
|
||||
elsif d[:occupied]
|
||||
out << "%{A:bspc desktop -f #{d_name}:} #{d_name} %{A}"
|
||||
else
|
||||
if @my_config['show_empty_desktops']
|
||||
out << " #{n} "
|
||||
end
|
||||
when /^L.+/
|
||||
case n
|
||||
when "T"
|
||||
out << " t "
|
||||
when "M"
|
||||
out << " m "
|
||||
out << " #{d_name} "
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if state[:layout] == "T"
|
||||
out << " t "
|
||||
elsif state[:layout] == "M"
|
||||
out << " m "
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user