aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/Makefile.am13
-rw-r--r--util/fluxbox-update_configs.cc19
-rw-r--r--util/update_keys.lua48
3 files changed, 74 insertions, 6 deletions
diff --git a/util/Makefile.am b/util/Makefile.am
index f5495e9..c2bbe74 100644
--- a/util/Makefile.am
+++ b/util/Makefile.am
@@ -6,7 +6,7 @@ bin_PROGRAMS= fbsetroot fluxbox-update_configs fluxbox-remote
6fbsetroot_SOURCES= fbsetroot.cc fbsetroot.hh 6fbsetroot_SOURCES= fbsetroot.cc fbsetroot.hh
7fbsetroot_LDADD=../src/FbRootWindow.o ../src/FbAtoms.o \ 7fbsetroot_LDADD=../src/FbRootWindow.o ../src/FbAtoms.o \
8 ../src/FbTk/libFbTk.a 8 ../src/FbTk/libFbTk.a
9fluxbox_update_configs_SOURCES= fluxbox-update_configs.cc 9fluxbox_update_configs_SOURCES= fluxbox-update_configs.cc update_keys-lua.cc
10fluxbox_update_configs_LDADD= ../src/defaults.o ../src/Resources.o \ 10fluxbox_update_configs_LDADD= ../src/defaults.o ../src/Resources.o \
11 ../src/FbTk/libFbTk.a ../libs/lua/src/liblua.a 11 ../src/FbTk/libFbTk.a ../libs/lua/src/liblua.a
12fluxbox_remote_SOURCES= fluxbox-remote.cc 12fluxbox_remote_SOURCES= fluxbox-remote.cc
@@ -49,11 +49,14 @@ fluxbox-generate_menu: fluxbox-generate_menu.in
49 > fluxbox-generate_menu 49 > fluxbox-generate_menu
50 -chmod 755 fluxbox-generate_menu 50 -chmod 755 fluxbox-generate_menu
51 51
52../src/FbRootWindow.o:
53 cd ../src && ${MAKE} FbRootWindow.o
54../src/FbAtoms.o:
55 cd ../src && ${MAKE} FbAtoms.o
56../src/defaults.o: 52../src/defaults.o:
57 cd ../src && ${MAKE} defaults.o 53 cd ../src && ${MAKE} defaults.o
58../src/Resources.o: 54../src/Resources.o:
59 cd ../src && ${MAKE} Resources.o 55 cd ../src && ${MAKE} Resources.o
56
57%.luac: %.lua Makefile
58 $(top_builddir)/libs/lua/src/luac -o $@ $<
59
60
61%-lua.cc: %.luac $(top_srcdir)/luatoc.sh Makefile
62 $(top_srcdir)/luatoc.sh $< $@ $(<:.luac=)
diff --git a/util/fluxbox-update_configs.cc b/util/fluxbox-update_configs.cc
index 233bdbb..883d864 100644
--- a/util/fluxbox-update_configs.cc
+++ b/util/fluxbox-update_configs.cc
@@ -724,6 +724,22 @@ update_move_slitlist_to_init_file(std::auto_ptr<FbTk::ResourceManager_base>& rm,
724 rc_slitlist->push_back(line); 724 rc_slitlist->push_back(line);
725} 725}
726 726
727void update_keys_for_lua(std::auto_ptr<FbTk::ResourceManager_base>& rm, FbTk::Lua &l) {
728 extern const char update_keys[];
729 extern const unsigned int update_keys_size;
730
731 l.checkstack(2);
732 lua::stack_sentry s(l);
733
734 FbTk::StringResource &rc_keyfile = rm->getResource<string, FbTk::StringTraits>("keyFile");
735
736 l.loadstring(update_keys, update_keys_size);
737 l.pushstring(read_file(FbTk::StringUtil::expandFilename(*rc_keyfile)));
738 l.call(1, 1);
739 *rc_keyfile = string(*rc_keyfile) + ".lua";
740 write_file(FbTk::StringUtil::expandFilename(*rc_keyfile), l.tostring(-1));
741}
742
727/*------------------------------------------------------------------*\ 743/*------------------------------------------------------------------*\
728\*------------------------------------------------------------------*/ 744\*------------------------------------------------------------------*/
729 745
@@ -747,7 +763,8 @@ const Update UPDATES[] = {
747 { 12, update_keys_for_activetab }, 763 { 12, update_keys_for_activetab },
748 { 13, update_limit_nextwindow_to_current_workspace }, 764 { 13, update_limit_nextwindow_to_current_workspace },
749 { 14, update_lua_resource_manager }, 765 { 14, update_lua_resource_manager },
750 { 15, update_move_slitlist_to_init_file } 766 { 15, update_move_slitlist_to_init_file },
767 { 16, update_keys_for_lua }
751}; 768};
752 769
753/*------------------------------------------------------------------*\ 770/*------------------------------------------------------------------*\
diff --git a/util/update_keys.lua b/util/update_keys.lua
new file mode 100644
index 0000000..5edab2c
--- /dev/null
+++ b/util/update_keys.lua
@@ -0,0 +1,48 @@
1local file = ...;
2local keymodes = {};
3local failed = false;
4
5local function process_line(line)
6 if string.match(line, '^%s*$') ~= nil then
7 return line;
8 end;
9 local comment = string.match(line, '^%s*[#!](.*)$');
10 if comment ~= nil then
11 return '--' .. comment;
12 end;
13
14 local mode, key, cmd = string.match(line, '^%s*(%a%w*):%s*([^:]-)%s*:(.*)$');
15 if key == nil then
16 key, cmd = string.match(line, '^%s*([^:]*):(.*)$');
17 end;
18
19 if mode == nil or mode == 'default' then
20 mode = 'default_keymode';
21 else
22 keymodes[mode] = true;
23 end;
24
25 if key ~= nil then
26 return string.format('%s[%q] = %q', mode, key, cmd);
27 else
28 failed = true;
29 return '-- FBCV16 ' .. line;
30 end;
31end;
32
33file = string.gsub(file, '[^\n]*', process_line);
34
35local decls = '';
36for k, v in pairs(keymodes) do
37 decls = decls .. k .. ' = newKeyMode();\n';
38end;
39
40if failed == true then
41 decls = [[
42--fluxbox-update_configs could not convert some of the lines into the new format.
43--These lines are marked with FBCV16 and you will have to convert them yourself.
44
45]] .. decls;
46end;
47
48return decls .. '\n' .. file;