8
8
#include "auth.h"
9
9
#include "window.h"
10
10
#include "gtklock.h"
11
+ #include "config.h"
11
12
#include "module.h"
12
13
#include "xdg.h"
13
14
@@ -19,16 +20,25 @@ static gboolean no_input_inhibit = FALSE;
19
20
20
21
static char * gtk_theme = NULL ;
21
22
23
+ static char * config_path = NULL ;
22
24
static char * style_path = NULL ;
23
25
static char * module_path = NULL ;
24
26
25
- static GOptionEntry entries [] = {
27
+ static GOptionEntry main_entries [] = {
26
28
{ "daemonize" , 'd' , 0 , G_OPTION_ARG_NONE , & should_daemonize , "Detach from the controlling terminal after locking" , NULL },
27
- { "no-layer-shell" , 'l' , 0 , G_OPTION_ARG_NONE , & no_layer_shell , "Don't use wlr-layer-shell" , NULL },
28
- { "no-input-inhibit" , 'i' , 0 , G_OPTION_ARG_NONE , & no_input_inhibit , "Don't use wlr-input-inhibitor" , NULL },
29
+ { "config" , 'c' , 0 , G_OPTION_ARG_FILENAME , & config_path , "Load config file" , NULL },
30
+ { NULL },
31
+ };
32
+
33
+ static GOptionEntry config_entries [] = {
29
34
{ "gtk-theme" , 'g' , 0 , G_OPTION_ARG_STRING , & gtk_theme , "Set GTK theme" , NULL },
30
35
{ "style" , 's' , 0 , G_OPTION_ARG_FILENAME , & style_path , "Load CSS style file" , NULL },
31
36
{ "module" , 'm' , 0 , G_OPTION_ARG_FILENAME , & module_path , "Load gtklock module" , NULL },
37
+ };
38
+
39
+ static GOptionEntry debug_entries [] = {
40
+ { "no-layer-shell" , 'l' , 0 , G_OPTION_ARG_NONE , & no_layer_shell , "Don't use wlr-layer-shell" , NULL },
41
+ { "no-input-inhibit" , 'i' , 0 , G_OPTION_ARG_NONE , & no_input_inhibit , "Don't use wlr-input-inhibitor" , NULL },
32
42
{ NULL },
33
43
};
34
44
@@ -146,13 +156,26 @@ static void daemonize(void) {
146
156
int main (int argc , char * * argv ) {
147
157
GError * error = NULL ;
148
158
GOptionContext * option_context = g_option_context_new ("- GTK-based lockscreen for sway" );
149
- g_option_context_add_main_entries (option_context , entries , NULL );
159
+ g_option_context_add_main_entries (option_context , main_entries , NULL );
150
160
g_option_context_set_help_enabled (option_context , FALSE);
151
161
g_option_context_set_ignore_unknown_options (option_context , TRUE);
152
162
g_option_context_parse (option_context , & argc , & argv , & error );
153
163
164
+ if (config_path == NULL ) config_path = xdg_get_config_path ("config.ini" );
165
+ if (config_path ) config_load (config_path , config_entries );
166
+
154
167
if (should_daemonize ) daemonize ();
155
168
169
+ GOptionGroup * config_group =
170
+ g_option_group_new ("config" , "Config options" , "Show options available in the config" , NULL , NULL );
171
+ GOptionGroup * debug_group =
172
+ g_option_group_new ("debug" , "Debug options" , "Show options for debugging and styling" , NULL , NULL );
173
+
174
+ g_option_group_add_entries (config_group , config_entries );
175
+ g_option_group_add_entries (debug_group , debug_entries );
176
+ g_option_context_add_group (option_context , config_group );
177
+ g_option_context_add_group (option_context , debug_group );
178
+
156
179
g_option_context_add_group (option_context , gtk_get_option_group (TRUE));
157
180
g_option_context_set_help_enabled (option_context , TRUE);
158
181
g_option_context_set_ignore_unknown_options (option_context , FALSE);
0 commit comments