mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
[Config] Allow all theme properties to be set from commandline
Bit hack solution, but `listview { scrollbar: false; }` can be reached by: -theme-listview-scrollbar false
This commit is contained in:
parent
f963b03ce6
commit
e3f41474fd
1 changed files with 58 additions and 23 deletions
|
@ -504,6 +504,25 @@ static void config_parse_cmd_option(XrmOption *option) {
|
||||||
g_free(key);
|
g_free(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean config_parser_form_rasi_format(GString *str, char **tokens,
|
||||||
|
int count, char *argv,
|
||||||
|
gboolean string) {
|
||||||
|
for (int j = 0; j < (count - 1); j++) {
|
||||||
|
g_string_append_printf(str, "%s { ", tokens[j]);
|
||||||
|
}
|
||||||
|
if (string) {
|
||||||
|
char *esc = g_strescape(argv, NULL);
|
||||||
|
g_string_append_printf(str, "%s: \"%s\";", tokens[count - 1], esc);
|
||||||
|
g_free(esc);
|
||||||
|
} else {
|
||||||
|
g_string_append_printf(str, "%s: %s;", tokens[count - 1], argv);
|
||||||
|
}
|
||||||
|
for (int j = 0; j < (count - 1); j++) {
|
||||||
|
g_string_append(str, " } ");
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
void config_parse_cmd_options(void) {
|
void config_parse_cmd_options(void) {
|
||||||
for (unsigned int i = 0; i < sizeof(xrmOptions) / sizeof(XrmOption); ++i) {
|
for (unsigned int i = 0; i < sizeof(xrmOptions) / sizeof(XrmOption); ++i) {
|
||||||
XrmOption *op = &(xrmOptions[i]);
|
XrmOption *op = &(xrmOptions[i]);
|
||||||
|
@ -526,35 +545,51 @@ void config_parse_cmd_options(void) {
|
||||||
for (int j = 1; tokens && tokens[j]; j++) {
|
for (int j = 1; tokens && tokens[j]; j++) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
if (count > 2 && g_strcmp0(tokens[1], "no") != 0) {
|
if (count > 2) {
|
||||||
GString *str = g_string_new("configuration { ");
|
if (g_strcmp0(tokens[1], "theme") == 0) {
|
||||||
for (int j = 1; j < (count - 1); j++) {
|
g_strfreev(tokens);
|
||||||
g_string_append_printf(str, "%s { ", tokens[j]);
|
tokens = g_strsplit(stored_argv[in], "-", 0);
|
||||||
}
|
count = g_strv_length(tokens);
|
||||||
g_string_append_printf(str, "%s: %s;", tokens[count - 1],
|
if (count > 3) {
|
||||||
stored_argv[in + 1]);
|
GString *str = g_string_new("");
|
||||||
for (int j = 0; j < (count - 1); j++) {
|
config_parser_form_rasi_format(str, &(tokens[2]), count - 2,
|
||||||
g_string_append(str, " } ");
|
stored_argv[in + 1], FALSE);
|
||||||
}
|
g_debug("theme: \"%s\"\n", str->str);
|
||||||
if (rofi_theme_parse_string(str->str) == 1) {
|
if (rofi_theme_parse_string(str->str) == 1) {
|
||||||
/** Failed to parse, try again as string. */
|
/** Failed to parse, try again as string. */
|
||||||
rofi_clear_error_messages();
|
rofi_clear_error_messages();
|
||||||
g_string_assign(str, "configuration { ");
|
g_string_assign(str, "");
|
||||||
for (int j = 1; j < (count - 1); j++) {
|
config_parser_form_rasi_format(str, &(tokens[2]), count - 2,
|
||||||
g_string_append_printf(str, "%s { ", tokens[j]);
|
stored_argv[in + 1], TRUE);
|
||||||
}
|
g_debug("theme: \"%s\"\n", str->str);
|
||||||
char *esc = g_strescape(stored_argv[in + 1], NULL);
|
if (rofi_theme_parse_string(str->str) == 1) {
|
||||||
g_string_append_printf(str, "%s: \"%s\";", tokens[count - 1], esc);
|
/** Failed to parse, try again as string. */
|
||||||
g_free(esc);
|
rofi_clear_error_messages();
|
||||||
for (int j = 0; j < (count - 1); j++) {
|
}
|
||||||
g_string_append(str, " } ");
|
}
|
||||||
|
g_string_free(str, TRUE);
|
||||||
}
|
}
|
||||||
|
} else if (g_strcmp0(tokens[1], "no") != 0) {
|
||||||
|
GString *str = g_string_new("configuration { ");
|
||||||
|
config_parser_form_rasi_format(str, &(tokens[1]), count - 1,
|
||||||
|
stored_argv[in + 1], FALSE);
|
||||||
|
g_string_append(str, "}");
|
||||||
|
g_debug("str: \"%s\"\n", str->str);
|
||||||
if (rofi_theme_parse_string(str->str) == 1) {
|
if (rofi_theme_parse_string(str->str) == 1) {
|
||||||
/** Failed to parse, try again as string. */
|
/** Failed to parse, try again as string. */
|
||||||
rofi_clear_error_messages();
|
rofi_clear_error_messages();
|
||||||
|
g_string_assign(str, "configuration { ");
|
||||||
|
config_parser_form_rasi_format(str, &(tokens[1]), count - 1,
|
||||||
|
stored_argv[in + 1], TRUE);
|
||||||
|
g_string_append(str, "}");
|
||||||
|
g_debug("str: \"%s\"\n", str->str);
|
||||||
|
if (rofi_theme_parse_string(str->str) == 1) {
|
||||||
|
/** Failed to parse, try again as string. */
|
||||||
|
rofi_clear_error_messages();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
g_string_free(str, TRUE);
|
||||||
}
|
}
|
||||||
g_string_free(str, TRUE);
|
|
||||||
in++;
|
in++;
|
||||||
}
|
}
|
||||||
g_strfreev(tokens);
|
g_strfreev(tokens);
|
||||||
|
|
Loading…
Reference in a new issue