Fix background call hangup and end calls on screen lock or lid close
This commit is contained in:
1 parent
c7cdde6734
commit
0c352f0a10
55 files changed
+391
-120
No files matched your search
+21
-29
@@ -1637,6 +1637,8 @@ handle_t9_keypress(int key_id)
|
||||
drawmenu();
|
||||
}
|
||||
|
||||
static int has_tracked_calls(void);
|
||||
|
||||
static void
|
||||
keypress(XKeyEvent *ev)
|
||||
{
|
||||
@@ -1780,6 +1782,16 @@ insert:
|
||||
cancel_session();
|
||||
return;
|
||||
case XF86XK_PowerOff:
|
||||
if (has_tracked_calls()) {
|
||||
int cfd = open("/tmp/dwm_plugin_callscreen.fifo",
|
||||
O_WRONLY | O_NONBLOCK | O_CLOEXEC);
|
||||
if (cfd >= 0) {
|
||||
(void)write(cfd, "HANGUP\n", 7);
|
||||
close(cfd);
|
||||
}
|
||||
cancel_session();
|
||||
return;
|
||||
}
|
||||
if (daemon_mode &&
|
||||
(menu_mode != MODE_BUILTIN || strcmp(current_builtin_menu, "power") != 0)) {
|
||||
if (active_client_fd >= 0)
|
||||
@@ -2154,6 +2166,9 @@ count_notifications(void)
|
||||
static int
|
||||
has_tracked_calls(void)
|
||||
{
|
||||
if (access("/tmp/sxmo_call_ringing", F_OK) == 0 ||
|
||||
access("/tmp/sxmo_active_call", F_OK) == 0)
|
||||
return 1;
|
||||
const char *rdir = getenv("XDG_RUNTIME_DIR");
|
||||
char cdir[256];
|
||||
snprintf(cdir, sizeof(cdir), "%s/sxmo_calls", (rdir && rdir[0]) ? rdir : "/run/user/10000");
|
||||
@@ -2266,35 +2281,12 @@ append_active_call_entries(void)
|
||||
{
|
||||
if (!has_tracked_calls())
|
||||
return;
|
||||
FILE *fp = popen("sxmo_modemcall.sh list_active_calls 2>/dev/null", "r");
|
||||
if (!fp)
|
||||
return;
|
||||
char line[512];
|
||||
int shown_incall = 0;
|
||||
while (fgets(line, sizeof(line), fp)) {
|
||||
char *nl = strpbrk(line, "\r\n");
|
||||
if (nl)
|
||||
*nl = '\0';
|
||||
if (!line[0])
|
||||
continue;
|
||||
if (strstr(line, "(ringing-in)")) {
|
||||
char callid[64] = "";
|
||||
char *sp = strchr(line, ' ');
|
||||
if (sp)
|
||||
*sp = '\0';
|
||||
char *slash = strrchr(line, '/');
|
||||
snprintf(callid, sizeof(callid), "%s", slash ? (slash + 1) : line);
|
||||
char label[256];
|
||||
snprintf(label, sizeof(label), "%s Incoming call %s", ICON_PHN, callid);
|
||||
add_menu_item(label, "@plugin:callscreen", 0);
|
||||
} else if (!shown_incall) {
|
||||
shown_incall = 1;
|
||||
char label[128];
|
||||
snprintf(label, sizeof(label), "%s Call Screen", ICON_PHN);
|
||||
add_menu_item(label, "@plugin:callscreen", 0);
|
||||
}
|
||||
}
|
||||
pclose(fp);
|
||||
char label[128];
|
||||
if (access("/tmp/sxmo_call_ringing", F_OK) == 0)
|
||||
snprintf(label, sizeof(label), "%s Incoming Call", ICON_PHN);
|
||||
else
|
||||
snprintf(label, sizeof(label), "%s Call Screen", ICON_PHN);
|
||||
add_menu_item(label, "@plugin:callscreen", 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in new issue
Block a user