summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouie Shprung <lshprung@tutanota.com>2024-08-14 16:32:54 -0400
committerLouie Shprung <lshprung@tutanota.com>2024-08-14 16:32:54 -0400
commit243853cd1692c56cae8642dd6bb35c3c75ff54f7 (patch)
treef65f7d49e022168db9b2f3d5c5272f869e6ace4a
parentf00cf908fdcdff676e95e563b2a93e2d4af05bc7 (diff)
Working support for setting launcher
-rw-r--r--src/group.c2
-rw-r--r--src/include/group.h2
-rw-r--r--src/read_cfg.c14
3 files changed, 14 insertions, 4 deletions
diff --git a/src/group.c b/src/group.c
index 1d1ebd2..e5c3373 100644
--- a/src/group.c
+++ b/src/group.c
@@ -44,7 +44,7 @@ char *get_gprog(GROUP *g){
return g->program;
}
-void set_gprog(GROUP *g, char *p){
+void set_gprog(GROUP *g, const char *p){
assert(g != NULL);
strcpy(g->program, p);
return;
diff --git a/src/include/group.h b/src/include/group.h
index 89a8422..751b629 100644
--- a/src/include/group.h
+++ b/src/include/group.h
@@ -13,7 +13,7 @@ char *get_gname(GROUP *g);
char *get_gprog(GROUP *g);
-void set_gprog(GROUP *g, char *p);
+void set_gprog(GROUP *g, const char *p);
char *get_gflags(GROUP *g);
diff --git a/src/read_cfg.c b/src/read_cfg.c
index 97a76ff..d9491bb 100644
--- a/src/read_cfg.c
+++ b/src/read_cfg.c
@@ -147,7 +147,8 @@ int get_entry_count(lua_State *L, int table_stack_index) {
void add_groups(lua_State *L, int table_stack_index, GROUP ***g) {
const char *group_name;
- int entry_table_stack_index;
+ int group_table_index; // index of Groups.TABLE_NAME
+ int entry_table_stack_index; // index of Groups.TABLE_NAME.Entries
int entry_count;
int i;
@@ -158,12 +159,13 @@ void add_groups(lua_State *L, int table_stack_index, GROUP ***g) {
// looking at Groups.TABLE_NAME
if(lua_type(L, -2) == LUA_TSTRING && lua_type(L, -1) == LUA_TTABLE) {
group_name = lua_tostring(L, -2);
+ group_table_index = lua_gettop(L);
if(group_name != NULL) {
// push the Entries table on the stack (to get entry information)
lua_pushstring(L, "Entries");
// get table Groups.TABLE_NAME.Entries
- lua_gettable(L, -2);
+ lua_gettable(L, group_table_index);
entry_table_stack_index = lua_gettop(L);
// check that 'Entries' is a table
@@ -182,6 +184,14 @@ void add_groups(lua_State *L, int table_stack_index, GROUP ***g) {
// add entries to this group
add_entries(L, entry_table_stack_index, (*g)[i]);
}
+
+ // set the launcher, if applicable
+ lua_pushstring(L, "Launcher");
+ lua_gettable(L, group_table_index);
+ printf("Found launcher: %s\n", lua_tostring(L, -1));
+ if(lua_type(L, -1) == LUA_TSTRING) {
+ set_gprog((*g)[i], lua_tostring(L, -1));
+ }
}
}
// pop the top of the stack down to the key of the group