#!/usr/bin/env ruby # ############################################################# # # file : random-flux-style.rb # author : mathias gumz # copyr : copyright (c) 2005 by m. gumz # license : see LICENSE # # start : Mi 20 Apr 2005 10:53:37 CEST # ############################################################# # # about : # ############################################################# # # # stylepath = [ ENV['HOME'] + '/.fluxbox/styles' ] stylepath.concat(ENV['STYLEPATH'].split(':')) if ENV['STYLEPATH'] stylepath.compact! stylepath.uniq! styles = [ ] stylepath.each { |sp| Dir.glob(sp + '/*').each { |s| styles << s } } initfile = !ENV['INITFILE'] ? ENV['HOME'] + '/.fluxbox/init' : ENV['INITFILE'] newinit = [ ] begin IO.foreach(initfile) { |l| if l =~ /session.styleFile:\s*(\S+)\s*$/ newinit << "session.styleFile: #{styles[rand(styles.size)]}\n" else newinit << l end } rescue puts "error, no such file: #{initfile}. exit." exit(1) end File.open(initfile, 'w') { |f| f.write(newinit) } # # # ############################################################# # # #############################################################