Some other shit

This commit is contained in:
Jack L. Frost 2016-09-27 13:03:14 +03:00
parent b97d52cce5
commit 33b6dca429
4 changed files with 65 additions and 8 deletions

View File

@ -5,7 +5,10 @@ class ModBspwmPager < ModBasic
def data_loop() def data_loop()
while true do while true do
IO.popen("bspc subscribe").each do |line| pipe = IO.popen("bspc subscribe")
$children << pipe.pid
pipe.each do |line|
$panel_data[@@mod_name.to_sym] = parse_data(line.chomp) $panel_data[@@mod_name.to_sym] = parse_data(line.chomp)
$queue << 1 $queue << 1
end end

View File

@ -5,8 +5,16 @@ class ModBspwmTaskbar < ModBasic
def data_loop() def data_loop()
while true do while true do
IO.popen("xtitle -s -f '%s'").each do |line| pipe = IO.popen("xtitle -s -f '%s'")
$panel_data[@@mod_name.to_sym] = line.chomp $children << pipe.pid
pipe.each do |line|
if line == "\n"
$panel_data[@@mod_name.to_sym] = ""
else
$panel_data[@@mod_name.to_sym] = $config['mod']['bspwm_taskbar']['begin'].erb + line.chomp + $config['mod']['bspwm_taskbar']['end'].erb
end
$queue << 1 $queue << 1
end end
end end

View File

@ -5,6 +5,7 @@ require 'erb'
$queue = Queue.new $queue = Queue.new
$panel_data = Hash.new("") $panel_data = Hash.new("")
$children = []
class ModBasic class ModBasic
def mainloop() def mainloop()
@ -25,6 +26,23 @@ class ModBasic
end end
end end
class ::String
def erb
return ERB.new(self).result
end
end
def get_x_dims
return `xrandr`.scan(/current (\d+) x (\d+)/).flatten
end
at_exit do
$children.each do |pid|
puts "Killing pid: #{pid}"
Process.kill("TERM", pid)
end
end
argv = ARGV argv = ARGV
while argv[0] != nil while argv[0] != nil
case argv[0] case argv[0]
@ -35,12 +53,35 @@ while argv[0] != nil
argv.shift() argv.shift()
end end
$config = YAML.load_file('./rc.yaml') if ENV["XDG_CONFIG_HOME"] == nil
conf_dir = ENV["HOME"] + "/.config/moltenbar"
else
conf_dir = ENV["XDG_CONFIG_HOME"] + "/moltenbar"
end
Dir["./mod/*"].each do |file| config_file = conf_dir + "/rc.yaml"
mod_dir = conf_dir + "/mod"
$config = YAML.load_file(config_file)
Dir["#{mod_dir}/*"].each do |file|
load file load file
end end
if $config['geometry'] == nil
$config['gap'] ||= 0
$config['height'] ||= 14
gap = $config['gap'].to_i
if $config['width'] == nil
y, x = get_x_dims()
$config['width'] = y.to_i - (gap * 2)
end
$config['geometry'] = "#{$config['width']}x#{$config['height']}+#{gap}+#{gap}"
end
lemonbar_cmd = [ lemonbar_cmd = [
"lemonbar", "lemonbar",
"-g", $config['geometry'], "-g", $config['geometry'],
@ -59,6 +100,6 @@ trap("SIGUSR1") { $queue << 1 }
IO.popen(lemonbar_cmd, "w") do |pipe| IO.popen(lemonbar_cmd, "w") do |pipe|
while true do while true do
data = $queue.pop data = $queue.pop
pipe.puts ERB.new($config['format']).result pipe.puts $config['format'].erb
end end
end end

View File

@ -1,10 +1,12 @@
# vim: ft=yaml sw=2 et # vim: ft=yaml sw=2 et
geometry: '1902x14+9+9' #geometry: '1902x14+9+9'
height: 14
gap: 9
fontspec: '-*-terminesspowerline-medium-*-normal-*-14-*-*-*-*-*-iso10646-*' fontspec: '-*-terminesspowerline-medium-*-normal-*-14-*-*-*-*-*-iso10646-*'
window_name: 'moltenbar' window_name: 'moltenbar'
active_areas: '128' active_areas: '128'
format: "<%= $panel_data[:bspwm_pager] %>%{F<%= $config['colours']['bg'] %>}%{B<%= $config['colours']['bg_focused'] %>}%{F-} <%= $panel_data[:bspwm_taskbar] %>%{F<%= $config['colours']['bg_focused'] %>} %{B-} %{r}%{F<%= $config['colours']['bg_focused'] %>}%{F-}%{B<%= $config['colours']['bg_focused'] %>} LA: <%= $panel_data[:load_average] %> Network: <%= $panel_data[:network] %> <%= $panel_data[:date] %> %{B-}" format: "<%= $panel_data[:bspwm_pager] %><%= $panel_data[:bspwm_taskbar] %>%{r}%{F<%= $config['colours']['bg_focused'] %>}%{F-}%{B<%= $config['colours']['bg_focused'] %>} LA: <%= $panel_data[:load_average] %> Network: <%= $panel_data[:network] %> <%= $panel_data[:date] %> %{B-}"
colours: colours:
fg: '#f9f9f9' fg: '#f9f9f9'
fg_focused: '#f9f9f9' fg_focused: '#f9f9f9'
@ -16,6 +18,9 @@ mod:
show_empty_desktops: false show_empty_desktops: false
blacklist: blacklist:
-h -h
bspwm_taskbar:
begin: "%{F<%= $config['colours']['bg'] %>}%{B<%= $config['colours']['bg_focused'] %>}%{F-} "
end: "%{F<%= $config['colours']['bg_focused'] %>} %{B-} "
date: date:
format: '%A, %Y.%m.%d %H:%M:%S' format: '%A, %Y.%m.%d %H:%M:%S'
load_average: load_average: