commit 7d0a8acd042393b6b50c090bacdf7a24d825dc69
parent f9c30d89f26b7406ecc704f8b9149eb8d6f0b6be
Author: Suraj N. Kurapati <sunaku@gmail.com>
Date: Mon, 11 May 2009 22:53:54 -0700
add 'reload' action to reload the configuration (idea by wabu)
add reload_config() and rename load_config_file() to load_config()
Diffstat:
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/config.rb b/config.rb
@@ -206,7 +206,7 @@ require 'yaml'
##
# Loads the given YAML configuration file.
#
-def load_config_file config_file
+def load_config config_file
config_data = YAML.load_file(config_file)
Object.const_set :CONFIG, config_data
@@ -294,3 +294,11 @@ def load_config_file config_file
eval CONFIG['script'], TOPLEVEL_BINDING, "#{config_file}:script"
end
+
+##
+# Reloads the entire wmii configuration.
+#
+def reload_config
+ LOG.info 'reload'
+ exec $0
+end
diff --git a/config.yaml b/config.yaml
@@ -717,6 +717,9 @@ control:
# <action name>: <Ruby code to execute>
#
action:
+ reload: | # reload this wmii configuration
+ reload_config
+
rehash: | # scan for available programs and actions
@program_menu = find_programs(ENV['PATH'].squeeze(':').split(':'))
@action_menu = find_programs(File.dirname(__FILE__))
diff --git a/wmiirc b/wmiirc
@@ -39,7 +39,7 @@ begin
end
# apply user configuration
- load_config_file config_file
+ load_config config_file
# setup tag bar (buttons that correspond to views)
fs.lbar.clear
@@ -74,7 +74,7 @@ rescue Exception => e
f.close_write
if f.read.chomp == 'Recover'
- system $0 + ' &'
+ reload_config
end
end