@@ -22,32 +22,12 @@ static struct themes cursor_themes = { 0 };
22
22
static GSettings * settings ;
23
23
24
24
static void
25
- set_value ( GSettings * settings , const char * key , const char * value )
25
+ environment_set ( const char * key , const char * value )
26
26
{
27
- if (!value ) {
28
- fprintf (stderr , "warn: cannot set '%s' - no value specified\n" , key );
29
- return ;
30
- }
31
- g_settings_set_value (settings , key , g_variant_new ("s" , value ));
32
- }
33
-
34
-
35
- static void
36
- update (GtkWidget * widget , gpointer data )
37
- {
38
- /* labwc settings */
39
- xml_set_num ("cornerradius.theme" , gtk_spin_button_get_value (GTK_SPIN_BUTTON (corner_radius )));
40
- xml_set ("name.theme" , gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (openbox_theme_name )));
41
- xml_set ("naturalscroll.device.libinput" , gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (natural_scroll )));
42
- xml_save ();
43
-
44
- /* gtk settings */
45
- set_value (settings , "cursor-theme" , gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (cursor_theme_name )));
46
- set_value (settings , "gtk-theme" , gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (gtk_theme_name )));
47
- set_value (settings , "icon-theme" , gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (icon_theme_name )));
48
-
49
27
/* set cursor for labwc - should cover 'replace' or 'append' */
50
- char xcur [4096 ] = "XCURSOR_THEME=" ;
28
+ char xcur [4096 ] = {0 };
29
+ strcpy (xcur , key );
30
+ strcat (xcur , "=" );
51
31
char filename [PATH_MAX ];
52
32
char bufname [PATH_MAX ];
53
33
char * home = getenv ("HOME" );
@@ -68,13 +48,43 @@ update(GtkWidget *widget, gpointer data)
68
48
}
69
49
}
70
50
fclose (fe );
71
- char * s = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (cursor_theme_name ));
72
- if (s ) {
73
- fprintf (fw , "%s" , strcat (xcur , s ));
51
+ if (value ) {
52
+ fprintf (fw , "%s\n" , strcat (xcur , value ));
74
53
}
75
54
fclose (fw );
76
55
rename (bufname , filename );
56
+ }
57
+
58
+ static void
59
+ set_value (GSettings * settings , const char * key , const char * value )
60
+ {
61
+ if (!value ) {
62
+ fprintf (stderr , "warn: cannot set '%s' - no value specified\n" , key );
63
+ return ;
64
+ }
65
+ g_settings_set_value (settings , key , g_variant_new ("s" , value ));
66
+ }
67
+
68
+ #define COMBO_TEXT (w ) gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(w))
69
+ #define SPIN_BUTTON_VAL (w ) gtk_spin_button_get_value(GTK_SPIN_BUTTON(w))
70
+
71
+ static void
72
+ update (GtkWidget * widget , gpointer data )
73
+ {
74
+ /* ~/.config/labwc/rc.xml */
75
+ xml_set_num ("cornerradius.theme" , SPIN_BUTTON_VAL (corner_radius ));
76
+ xml_set ("name.theme" , COMBO_TEXT (openbox_theme_name ));
77
+ xml_set ("naturalscroll.device.libinput" , COMBO_TEXT (natural_scroll ));
78
+ xml_save ();
79
+
80
+ /* gsettings */
81
+ set_value (settings , "cursor-theme" , COMBO_TEXT (cursor_theme_name ));
82
+ set_value (settings , "gtk-theme" , COMBO_TEXT (gtk_theme_name ));
83
+ set_value (settings , "icon-theme" , COMBO_TEXT (icon_theme_name ));
77
84
85
+ /* ~/.config/labwc/environment */
86
+ environment_set ("XCURSOR_THEME" , COMBO_TEXT (cursor_theme_name ));
87
+
78
88
/* reconfigure labwc */
79
89
if (!fork ()) {
80
90
execl ("/bin/sh" , "/bin/sh" , "-c" , "killall -SIGHUP labwc" , (void * )NULL );
0 commit comments