diff --git a/src/bin/main.c b/src/bin/main.c index 5e260ce7..b9b5f43c 100644 --- a/src/bin/main.c +++ b/src/bin/main.c @@ -1183,6 +1183,40 @@ _cb_popup_queue(void *data, Evas_Object *obj EINA_UNUSED, void *event) _popmedia_queue_add(term, src); } +static void +_set_alpha(Config *config, const char *val, Eina_Bool save) +{ + int opacity; + + if (!config || !val) return; + + config->temporary = !save; + + if (isdigit(*val)) + { + opacity = atoi(val); + if (opacity >= 100) + { + config->translucent = EINA_FALSE; + config->opacity = 100; + } + else if (opacity >= 0) + { + config->translucent = EINA_TRUE; + config->opacity = opacity; + } + } + else if ((!strcasecmp(val, "on")) || + (!strcasecmp(val, "true")) || + (!strcasecmp(val, "yes"))) + config->translucent = EINA_TRUE; + else + config->translucent = EINA_FALSE; + main_trans_update(config); + + if (save) config_save(config, NULL); +} + static void _cb_command(void *data, Evas_Object *obj EINA_UNUSED, void *event) { @@ -1235,40 +1269,9 @@ _cb_command(void *data, Evas_Object *obj EINA_UNUSED, void *event) else if (cmd[0] == 'a') // set alpha { if (cmd[1] == 't') // temporary - { - Config *config = termio_config_get(term->term); - - if (config) - { - config->temporary = EINA_TRUE; - if ((cmd[2] == '1') || - (!strcasecmp(cmd + 2, "on")) || - (!strcasecmp(cmd + 2, "true")) || - (!strcasecmp(cmd + 2, "yes"))) - config->translucent = EINA_TRUE; - else - config->translucent = EINA_FALSE; - main_trans_update(config); - } - } + _set_alpha(termio_config_get(term->term), cmd + 2, EINA_FALSE); else if (cmd[1] == 'p') // permanent - { - Config *config = termio_config_get(term->term); - - if (config) - { - config->temporary = EINA_FALSE; - if ((cmd[2] == '1') || - (!strcasecmp(cmd + 2, "on")) || - (!strcasecmp(cmd + 2, "true")) || - (!strcasecmp(cmd + 2, "yes"))) - config->translucent = EINA_TRUE; - else - config->translucent = EINA_FALSE; - main_trans_update(config); - config_save(config, NULL); - } - } + _set_alpha(termio_config_get(term->term), cmd + 2, EINA_TRUE); } } diff --git a/src/bin/tyalpha.c b/src/bin/tyalpha.c index d8e5f343..fe314bb8 100644 --- a/src/bin/tyalpha.c +++ b/src/bin/tyalpha.c @@ -8,11 +8,11 @@ int main(int argc, char **argv) { int i, perm = 0; - + if (!getenv("TERMINOLOGY")) return 0; if (argc <= 1) { - printf("Usage: %s [-p] on|off\n" + printf("Usage: %s [-p] on|off|\n" " Change the terminal transparency on or off\n" " -p Make change permanent (stored in config)\n" "\n", @@ -22,7 +22,7 @@ main(int argc, char **argv) for (i = 1; i < argc; i++) { char tbuf[PATH_MAX]; - + if (!strcmp(argv[i], "-p")) { perm = 1;