e alert - in case of crash use e system in new alert mode

this forces all ddc/backlight devices to max when discovered so you
can always see the alert.
This commit is contained in:
Carsten Haitzler 2020-04-21 03:01:54 +01:00
parent 5d6424e3bc
commit bd97c74492
7 changed files with 53 additions and 7 deletions

View File

@ -243,7 +243,6 @@ main(int argc, char **argv)
else if (i == 3) exit_gdb = atoi(argv[i]);
else if (i == 4) backtrace_str = argv[i];
}
fprintf(stderr, "exit_gdb: %i\n", exit_gdb);
s = getenv("E_TAINTED");
@ -252,7 +251,20 @@ main(int argc, char **argv)
ecore_app_no_system_modules();
elm_init(argc, argv);
if (setup_display()) elm_run();
if (setup_display())
{
s = getenv("E_ALERT_SYSTEM_BIN");
if (s && s[0])
{
putenv("E_ALERT_BACKLIGHT_RESET=1");
ecore_exe_pipe_run
(s, ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_WRITE |
ECORE_EXE_NOT_LEADER | ECORE_EXE_TERM_WITH_PARENT, NULL);
}
elm_run();
}
return ret;
}

View File

@ -343,7 +343,10 @@ main(int argc, char **argv)
e_util_env_set("E_RESTART_OK", NULL);
e_util_env_set("PANTS", "ON");
e_util_env_set("DESKTOP", "Enlightenment");
if (getenv("E_ALERT_FONT_DIR"))
e_util_env_set("E_ALERT_FONT_DIR", NULL);
if (getenv("E_ALERT_SYSTEM_BIN"))
e_util_env_set("E_ALERT_SYSTEM_BIN", NULL);
strshare = eina_stringshare_printf("%s/enlightenment_askpass",
e_prefix_bin_get());
if (strshare)

View File

@ -576,7 +576,7 @@ main(int argc, char **argv)
int i, valgrind_mode = 0;
int valgrind_tool = 0;
int valgrind_gdbserver = 0;
char buf[8192], buf2[4096], **args, *home;
char buf[8192], buf2[4096], buf3[4096], **args, *home;
char valgrind_path[PATH_MAX] = "";
const char *valgrind_log = NULL;
const char *bindir;
@ -709,6 +709,9 @@ main(int argc, char **argv)
snprintf(buf2, sizeof(buf2),
"E_ALERT_FONT_DIR=%s/data/fonts", eina_prefix_data_get(pfx));
putenv(buf2);
snprintf(buf3, sizeof(buf3),
"E_ALERT_SYSTEM_BIN=%s/enlightenment/utils/enlightenment_system", eina_prefix_lib_get(pfx));
putenv(buf3);
if ((valgrind_mode || valgrind_tool) &&
!find_valgrind(valgrind_path, sizeof(valgrind_path)))

View File

@ -96,6 +96,8 @@ void *alloca (size_t);
#define ERR(args...) do { fprintf(stderr, "E_SYSTEM_ERR: "); fprintf(stderr, ##args); } while (0)
extern Eina_Bool alert_backlight_reset;
extern uid_t uid;
extern gid_t gid;

View File

@ -160,6 +160,14 @@ _light_add(const char *dev)
lig->max = 100;
#endif
_devices = eina_list_append(_devices, lig);
if (alert_backlight_reset)
{ // set brightness to max if alert mode is on
eina_lock_take(&_devices_lock);
lig->val_set = lig->max;
lig->set = EINA_TRUE;
eina_semaphore_release(&_worker_sem, 1);
eina_lock_release(&_devices_lock);
}
}
#ifdef HAVE_EEZE
@ -176,7 +184,7 @@ _light_device_include(const char *dev)
#endif
static void
_light_refresh_devices(void)
_light_refresh_devices()
{
Light *lig;
@ -260,9 +268,12 @@ _cb_bklight_list(void *data EINA_UNUSED, const char *params EINA_UNUSED)
static void
_cb_bklight_refresh(void *data EINA_UNUSED, const char *params EINA_UNUSED)
{
Eina_Bool tmp = alert_backlight_reset;
alert_backlight_reset = EINA_FALSE;
eina_lock_take(&_devices_lock);
_light_refresh_devices();
eina_lock_release(&_devices_lock);
alert_backlight_reset = tmp;
}
static void
@ -302,9 +313,9 @@ done:
void
e_system_backlight_init(void)
{
_light_refresh_devices();
eina_lock_new(&_devices_lock);
eina_semaphore_new(&_worker_sem, 0);
_light_refresh_devices();
ecore_thread_feedback_run(_cb_worker, _cb_worker_message,
_cb_worker_end, _cb_worker_cancel,
NULL, EINA_TRUE);

View File

@ -279,12 +279,17 @@ _ddc_probe(void)
if (d->edid)
{
for (j = 0; j < 128; j++)
snprintf(&(d->edid[j * 2]), 3, "%02x", dinfo->edid_bytes[j]);
snprintf(&(d->edid[j * 2]), 3, "%02x", dinfo->edid_bytes[j]);
d->edid[j * 2] = 0;
d->screen = i;
eina_lock_take(&_devices_lock);
_devices = eina_list_append(_devices, d);
eina_lock_release(&_devices_lock);
if (alert_backlight_reset)
{ // set brightness to max if alert mode is on
ddc_func.ddca_set_non_table_vcp_value
(ddc_dh[i], 0x10, 0, 100);
}
}
else free(d);
}

View File

@ -1,5 +1,7 @@
#include "e_system.h"
Eina_Bool alert_backlight_reset = EINA_FALSE;
uid_t uid = -1; // uid of person running me
gid_t gid = -1; // gid of person running me
@ -275,6 +277,14 @@ _cb_idle_enterer(void *data EINA_UNUSED)
int
main(int argc EINA_UNUSED, const char **argv EINA_UNUSED)
{
const char *s;
// special mode to reset all newly found bl devices to max on
// discovery because we were run by the e alert crash handler and
// the user needs to see it...
s = getenv("E_ALERT_BACKLIGHT_RESET");
if ((s) && (s[0] == '1')) alert_backlight_reset = EINA_TRUE;
setuid_setup();
ecore_app_no_system_modules();