eh it works sorta maybe

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Jack L. Frost 2016-09-27 04:18:43 +03:00
parent 249870e00e
commit b01792ec1b
5 changed files with 171 additions and 0 deletions

57
mod/bspwm_pager Normal file
View File

@ -0,0 +1,57 @@
# vim: ft=ruby
class ModBspwmPager < ModBasic
@@mod_name = 'bspwm_pager'
def data_loop()
while true do
IO.popen("bspc subscribe").each do |line|
$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
$workers << ModBspwmPager.new.mainloop()

15
mod/date Normal file
View File

@ -0,0 +1,15 @@
# vim: ft=ruby
class ModDate < ModBasic
@@mod_name = 'date'
def data_loop()
while true do
$panel_data[@@mod_name.to_sym] = Time.now.strftime($config['mod']['date']['format'])
$queue << 1
sleep 1
end
end
end
$workers << ModDate.new.mainloop()

65
moltenbar Normal file → Executable file
View File

@ -1 +1,66 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
require 'yaml'
$queue = Queue.new
$workers = []
$panel_data = Hash.new("")
class ModBasic
def mainloop()
thread = Thread.new {
self.data_loop()
}
return thread
end
def data_loop()
while true do
t = Time.new
$panel_data[:dummy] = "#{t}: I am a dummy!"
$queue << 1
sleep(1)
end
end
end
argv = ARGV
while argv[0] != nil
case argv[0]
when "-h", "--help"
puts "HELP"
end
argv.shift()
end
$config = YAML.load_file('./rc.yaml')
load './rc'
Dir["./mod/*"].each do |file|
load file
end
lemonbar_cmd = [
"lemonbar",
"-g", $config['geometry'],
"-f", $config['fontspec'],
"-n", $config['window_name'],
"-a", $config['active_areas'],
"-F", $config['colours']['fg'],
"-B", $config['colours']['bg']
]
puts "Launching lemonbar as: " + lemonbar_cmd.join(" ")
trap("SIGINT") { exit 0 }
trap("SIGUSR1") { $queue << 1 }
IO.popen(lemonbar_cmd, "w") do |pipe|
while true do
data = $queue.pop
pipe.puts draw()
end
end

15
rc Normal file
View File

@ -0,0 +1,15 @@
# vim: ft=ruby
def draw()
bg_f = $config['colours']['bg_focused']
panel = [
$panel_data[:bspwm_pager],
"%{r}",
"%{F#{bg_f}}%{F-}%{B#{bg_f}} ",
$panel_data[:date],
" %{B-}"
]
return panel.join
end

19
rc.yaml Normal file
View File

@ -0,0 +1,19 @@
# vim: ft=yaml
geometry: '1902x14+9+9'
fontspec: '-*-terminesspowerline-medium-*-normal-*-14-*-*-*-*-*-iso10646-*'
window_name: 'moltenbar'
active_areas: '128'
colours:
fg: '#f9f9f9'
fg_focused: '#f9f9f9'
bg: '#29303A'
bg_focused: '#467EC2'
mod:
bspwm_pager:
colour_focused: '#f9f9f9'
show_empty_desktops: false
blacklist:
-h
date:
format: '%A, %Y.%m.%d %H:%M:%S'