Fix background call hangup and end calls on screen lock or lid close

This commit is contained in:
Luxferre committed 2026-11-04 17:59:19 +02:00
1 parent c7cdde6734
commit 0c352f0a10
55 files changed
+391 -120

No files matched your search

+173 -63
View File
@@ -452,6 +452,22 @@ int callscreen_run_main(int argc, char** argv) {
int selectedRow = 0;
auto hasBtAudioCard = []() -> bool {
bool hciConnected = false;
DIR* bd = ::opendir("/sys/class/bluetooth");
if (bd) {
struct dirent* ent;
while ((ent = ::readdir(bd)) != nullptr) {
if (std::strncmp(ent->d_name, "hci", 3) == 0 &&
std::strchr(ent->d_name, ':') != nullptr) {
hciConnected = true;
break;
}
}
::closedir(bd);
}
if (!hciConnected) {
return false;
}
FILE* fp = ::popen("pactl list short cards 2>/dev/null", "r");
if (!fp) return false;
char line[256];
@@ -1421,7 +1437,35 @@ int callscreen_run_main(int argc, char** argv) {
render();
};
auto hangupCall = [&]() {
int missingModemPolls = 0;
auto resetToIdleAndClose = [&]() {
stopRecording();
if (micMuted) {
setMicMuted(false);
}
stopRingingJobs();
btAudioOn = false;
dtmfMode = false;
ringMuted = false;
sipZrtpSas.clear();
callState = CallState::Idle;
callId.clear();
callNumber.clear();
contactName.clear();
endedAtMs = 0;
missingModemPolls = 0;
writeActiveStateFiles();
hideWindow(false);
runAsyncCmd("sxmo_jobs.sh stop ringing >/dev/null 2>&1; "
"pkill -TERM -f sxmo_hook_ring.sh >/dev/null 2>&1; "
"pkill -TERM -f 'pw-play.*ring' >/dev/null 2>&1; "
"pkill -TERM -f 'mpv.*ring' >/dev/null 2>&1; "
"pkill -TERM -x sxmo_vibrate >/dev/null 2>&1; "
"sxmo_modemaudio.sh disable_call_audio_mode >/dev/null 2>&1");
};
auto hangupCall = [&](bool closeImmediately = false) {
std::string cid = resolveActiveModemCallId();
bool wasIncoming = (callState == CallState::Incoming);
stopRingingJobs();
@@ -1432,9 +1476,16 @@ int callscreen_run_main(int argc, char** argv) {
} else if (!cid.empty() && cid != "-" && cid != "sim" && cid != "test") {
runAsyncArgv("sxmo_modemcall.sh", "hangup", cid.c_str());
} else {
runAsyncCmd("mmcli -m any --voice-hangup-all >/dev/null 2>&1");
runAsyncArgv("sxmo_modemcall.sh", "hangup", "all");
sendPluginCommand("sip", "CALL_HANGUP");
sendPluginCommand("tox", "CALL_HANGUP");
}
if (closeImmediately || !visible || callState == CallState::Idle ||
callState == CallState::SelectSim || callState == CallState::Ended) {
resetToIdleAndClose();
} else {
transitionToEnded(wasIncoming ? "CALL REJECTED" : "CALL ENDED");
}
transitionToEnded(wasIncoming ? "CALL REJECTED" : "CALL ENDED");
};
auto sendDtmfTone = [&](char ch) {
@@ -1527,6 +1578,7 @@ int callscreen_run_main(int argc, char** argv) {
}
SockAddrQrtr vSq { kAfQipcrtr, vNode, vPort };
bool gotValidReply = false;
for (int sub : {1, 0}) {
int sfd = ::socket(kAfQipcrtr, SOCK_DGRAM | SOCK_CLOEXEC, 0);
if (sfd < 0) continue;
@@ -1537,21 +1589,35 @@ int callscreen_run_main(int argc, char** argv) {
::sendto(sfd, bindReq, sizeof(bindReq), 0,
reinterpret_cast<const struct sockaddr*>(&vSq), sizeof(vSq));
struct pollfd pfd { sfd, POLLIN, 0 };
if (::poll(&pfd, 1, 40) > 0) {
uint8_t tmp[256];
::recv(sfd, tmp, sizeof(tmp), 0);
int64_t bindDeadline = nowMs() + 150;
while (nowMs() < bindDeadline) {
int waitMs = static_cast<int>(std::max<int64_t>(5, bindDeadline - nowMs()));
if (::poll(&pfd, 1, waitMs) <= 0) break;
uint8_t tmp[512];
ssize_t rlen = ::recv(sfd, tmp, sizeof(tmp), 0);
if (rlen >= 7 && tmp[0] == 0x02 && tmp[1] == 0x01 && tmp[2] == 0x00 &&
tmp[3] == 0x44 && tmp[4] == 0x00) {
break;
}
}
uint8_t infoReq[7] = { 0x00, 0x02, 0x00, 0x2F, 0x00, 0x00, 0x00 };
::sendto(sfd, infoReq, sizeof(infoReq), 0,
reinterpret_cast<const struct sockaddr*>(&vSq), sizeof(vSq));
if (::poll(&pfd, 1, 50) > 0) {
int64_t infoDeadline = nowMs() + 200;
while (nowMs() < infoDeadline) {
int waitMs = static_cast<int>(std::max<int64_t>(5, infoDeadline - nowMs()));
if (::poll(&pfd, 1, waitMs) <= 0) break;
uint8_t buf[1024];
ssize_t rlen = ::recv(sfd, buf, sizeof(buf), 0);
if (rlen >= 7 && buf[0] == 0x02 && buf[3] == 0x2F) {
const uint8_t* rawCi = nullptr;
uint16_t lenCi = 0;
const uint8_t* rawNum = nullptr;
uint16_t lenNum = 0;
if (rlen >= 7 && buf[0] == 0x02 && buf[1] == 0x02 && buf[2] == 0x00 &&
buf[3] == 0x2F && buf[4] == 0x00) {
gotValidReply = true;
const uint8_t* rawCi01 = nullptr;
uint16_t lenCi01 = 0;
const uint8_t* rawCi10 = nullptr;
uint16_t lenCi10 = 0;
const uint8_t* rawNum11 = nullptr;
uint16_t lenNum11 = 0;
size_t pos = 7;
while (pos + 3 <= static_cast<size_t>(rlen)) {
uint8_t tt = buf[pos];
@@ -1559,15 +1625,22 @@ int callscreen_run_main(int argc, char** argv) {
(static_cast<uint16_t>(buf[pos + 2]) << 8);
pos += 3;
if (pos + tl > static_cast<size_t>(rlen)) break;
if (tt == 0x10) {
rawCi = buf + pos;
lenCi = tl;
if (tt == 0x01) {
rawCi01 = buf + pos;
lenCi01 = tl;
} else if (tt == 0x10) {
rawCi10 = buf + pos;
lenCi10 = tl;
} else if (tt == 0x11) {
rawNum = buf + pos;
lenNum = tl;
rawNum11 = buf + pos;
lenNum11 = tl;
}
pos += tl;
}
const uint8_t* rawCi = rawCi01 ? rawCi01 : rawCi10;
uint16_t lenCi = rawCi01 ? lenCi01 : lenCi10;
const uint8_t* rawNum = rawCi01 ? rawCi10 : rawNum11;
uint16_t lenNum = rawCi01 ? lenCi10 : lenNum11;
if (rawCi && lenCi >= 1) {
uint8_t cnt = rawCi[0];
size_t off = 1;
@@ -1608,11 +1681,12 @@ int callscreen_run_main(int argc, char** argv) {
}
}
}
break;
}
}
::close(sfd);
}
return true;
return gotValidReply;
};
auto syncModemCalls = [&]() {
@@ -1625,55 +1699,59 @@ int callscreen_run_main(int argc, char** argv) {
std::string foundNum;
bool sawTerminated = false;
FILE* fp = ::popen("mmcli -m any --voice-list-calls -a 2>/dev/null", "r");
if (fp) {
char line[512];
while (std::fgets(line, sizeof(line), fp)) {
std::string s(line);
if (s.find("No calls") != std::string::npos) {
continue;
if (callId.rfind("sub", 0) != 0) {
FILE* fp = ::popen("mmcli -m any --voice-list-calls -a 2>/dev/null", "r");
if (fp) {
char line[512];
while (std::fgets(line, sizeof(line), fp)) {
std::string s(line);
if (s.find("No calls") != std::string::npos) {
continue;
}
if (s.find("terminated") != std::string::npos) {
sawTerminated = true;
continue;
}
size_t callPos = s.find("/Call/");
if (callPos == std::string::npos) {
continue;
}
size_t idStart = callPos + 6;
size_t idEnd = idStart;
while (idEnd < s.size() && std::isdigit(static_cast<unsigned char>(s[idEnd]))) {
++idEnd;
}
if (idEnd == idStart) {
continue;
}
foundId = s.substr(idStart, idEnd - idStart);
if (s.find("incoming") != std::string::npos) {
foundDir = "incoming";
} else if (s.find("outgoing") != std::string::npos) {
foundDir = "outgoing";
}
size_t lp = s.find('(');
size_t rp = s.find(')', lp == std::string::npos ? 0 : lp);
if (lp != std::string::npos && rp != std::string::npos && rp > lp + 1) {
foundState = s.substr(lp + 1, rp - lp - 1);
}
break;
}
if (s.find("terminated") != std::string::npos) {
sawTerminated = true;
continue;
}
size_t callPos = s.find("/Call/");
if (callPos == std::string::npos) {
continue;
}
size_t idStart = callPos + 6;
size_t idEnd = idStart;
while (idEnd < s.size() && std::isdigit(static_cast<unsigned char>(s[idEnd]))) {
++idEnd;
}
if (idEnd == idStart) {
continue;
}
foundId = s.substr(idStart, idEnd - idStart);
if (s.find("incoming") != std::string::npos) {
foundDir = "incoming";
} else if (s.find("outgoing") != std::string::npos) {
foundDir = "outgoing";
}
size_t lp = s.find('(');
size_t rp = s.find(')', lp == std::string::npos ? 0 : lp);
if (lp != std::string::npos && rp != std::string::npos && rp > lp + 1) {
foundState = s.substr(lp + 1, rp - lp - 1);
}
break;
::pclose(fp);
}
::pclose(fp);
}
if (sawTerminated) {
runAsyncCmd("sxmo_modem.sh checkforfinishedcalls >/dev/null 2>&1");
}
bool qmiOk = true;
if (foundId.empty()) {
queryQmiVoiceCalls(foundId, foundDir, foundState, foundNum, sawTerminated);
qmiOk = queryQmiVoiceCalls(foundId, foundDir, foundState, foundNum, sawTerminated);
}
if (!foundId.empty()) {
missingModemPolls = 0;
if (callId.empty() || callId == "-") {
callId = foundId;
}
@@ -1725,6 +1803,10 @@ int callscreen_run_main(int argc, char** argv) {
sawTerminated ||
(callState == CallState::Outgoing &&
((!callId.empty() && callId != "-") || nowMs() - callStartMs > 3500))) {
if (!sawTerminated && (!qmiOk || ++missingModemPolls < 2)) {
return;
}
missingModemPolls = 0;
std::string callsDir = getRuntimeFile("sxmo_calls");
DIR* d = ::opendir(callsDir.c_str());
if (d) {
@@ -1754,6 +1836,14 @@ int callscreen_run_main(int argc, char** argv) {
return;
}
if (line == "CLOSE") {
if (callState == CallState::SelectSim || callState == CallState::Ended) {
callState = CallState::Idle;
callId.clear();
callNumber.clear();
contactName.clear();
endedAtMs = 0;
writeActiveStateFiles();
}
hideWindow(false);
return;
}
@@ -1770,13 +1860,12 @@ int callscreen_run_main(int argc, char** argv) {
}
return;
}
if (line == "HANGUP_CLOSE" || line.rfind("HANGUP_CLOSE ", 0) == 0) {
hangupCall(true);
return;
}
if (line == "HANGUP" || line.rfind("HANGUP ", 0) == 0) {
if (callState == CallState::Incoming || callState == CallState::Outgoing ||
callState == CallState::Active) {
hangupCall();
} else {
hideWindow(false);
}
hangupCall(!visible);
return;
}
if (line == "MUTE_RING") {
@@ -1816,6 +1905,11 @@ int callscreen_run_main(int argc, char** argv) {
iss >> verb >> arg1 >> arg2 >> arg3;
if (verb == "PROMPT_SIM") {
if (callState == CallState::Incoming || callState == CallState::Outgoing ||
callState == CallState::Active) {
showWindow();
return;
}
simInfo = queryDualSimInfo(true);
callId = "-";
callNumber.clear();
@@ -1857,7 +1951,9 @@ int callscreen_run_main(int argc, char** argv) {
activeSimSlot = 4;
return;
}
simInfo = queryDualSimInfo();
if (!simInfo.slot1Present && !simInfo.slot2Present) {
simInfo = queryDualSimInfo();
}
if (tagStr == "SIM1") {
activeSimSlot = 1;
} else if (tagStr == "SIM2") {
@@ -1883,6 +1979,8 @@ int callscreen_run_main(int argc, char** argv) {
parseSimTag(arg1, arg3);
callState = CallState::Incoming;
callStartMs = nowMs();
lastModemPollMs = callStartMs;
missingModemPolls = 0;
ringMuted = false;
speakerOn = false;
dtmfMode = false;
@@ -1902,6 +2000,8 @@ int callscreen_run_main(int argc, char** argv) {
parseSimTag(arg1, arg3);
callState = CallState::Outgoing;
callStartMs = nowMs();
lastModemPollMs = callStartMs;
missingModemPolls = 0;
ringMuted = false;
speakerOn = false;
btAudioOn = hasBtAudioCard();
@@ -1921,8 +2021,10 @@ int callscreen_run_main(int argc, char** argv) {
parseSimTag(arg1, arg3);
}
callState = CallState::Active;
lastModemPollMs = nowMs();
missingModemPolls = 0;
if (!wasActive) {
callStartMs = nowMs();
callStartMs = lastModemPollMs;
if (!wasOutgoing) {
speakerOn = false;
btAudioOn = hasBtAudioCard();
@@ -2009,6 +2111,14 @@ int callscreen_run_main(int argc, char** argv) {
} else if (ev.type == VisibilityNotify &&
ev.xvisibility.state != VisibilityUnobscured) {
if (isAnotherPluginActive("callscreen")) {
if (callState == CallState::SelectSim || callState == CallState::Ended) {
callState = CallState::Idle;
callId.clear();
callNumber.clear();
contactName.clear();
endedAtMs = 0;
writeActiveStateFiles();
}
hideWindow(false);
} else {
XRaiseWindow(dpy, win);
+7 -1
View File
@@ -937,6 +937,12 @@ int dialer_run_main(int argc, char** argv) {
case XF86XK_Phone:
case XF86XK_PickupPhone:
case XF86XK_Send: {
if (isCallActiveOrRingingFast()) {
writeSoftkeySuppress(nowMs() + 350);
hideWindow(false);
placePhoneCall("");
break;
}
std::string target = selectActiveNumber();
if (!target.empty()) {
if (target == "*#06#") {
@@ -954,8 +960,8 @@ int dialer_run_main(int argc, char** argv) {
executeUssd(target, false);
} else {
writeSoftkeySuppress(nowMs() + 350);
placePhoneCall(target);
hideWindow(false);
placePhoneCall(target);
}
}
break;
+24 -6
View File
@@ -446,8 +446,12 @@ int locker_run_main(int argc, char** argv) {
int64_t lastActivityMs = 0;
int lastRenderedMin = -1;
auto isCallScreenVisible = [&]() -> bool {
return isPidFileAlive(getRuntimeFile("xcallscreen.pid"));
};
auto grabLockerInput = [&]() {
if (!visible || isCallActiveOrRingingFast()) {
if (!visible || isCallScreenVisible()) {
return;
}
XRaiseWindow(dpy, win);
@@ -477,6 +481,7 @@ int locker_run_main(int argc, char** argv) {
};
auto closeOtherOverlays = [&]() {
closeOtherPlugins("locker");
sendPluginCommand("dmenu", "CLOSE");
sendPluginCommand("xdrawer", "CLOSE");
::unlink("/tmp/dwm_plugin_dmenu.active");
@@ -637,7 +642,7 @@ int locker_run_main(int argc, char** argv) {
passcode.empty() ? "Sleep" : "Clear",
&theme.colYellow);
if (!grabHeld && !isCallActiveOrRingingFast()) {
if (!grabHeld && !isCallScreenVisible()) {
grabLockerInput();
}
neo.present();
@@ -675,8 +680,15 @@ int locker_run_main(int argc, char** argv) {
auto lockPhone = [&](bool blankDisplay) {
bool alreadyVisible = visible;
bool hadActiveCall = isCallActiveOrRingingFast() || isCallScreenVisible();
writeSmallFileStr(kLockFlagPath, "1\n");
writeIntFile(activePidPath, static_cast<int>(::getpid()));
sendPluginCommand("callscreen", "HANGUP_CLOSE");
if (hadActiveCall) {
::unlink("/tmp/sxmo_call_ringing");
::unlink("/tmp/sxmo_active_call");
runAsyncArgv("sxmo_modemcall.sh", "hangup", "all");
}
closeOtherOverlays();
verifier.refreshIfNeeded();
int64_t now = nowMs();
@@ -834,7 +846,7 @@ int locker_run_main(int argc, char** argv) {
updateClockFont();
render();
}
bool callNow = isCallActiveOrRingingFast();
bool callNow = isCallScreenVisible();
if (callNow && !callWasActive) {
releaseLockerGrab();
} else if (!callNow && callWasActive) {
@@ -856,7 +868,7 @@ int locker_run_main(int argc, char** argv) {
} else if (ev.type == VisibilityNotify || ev.type == FocusOut ||
ev.type == UnmapNotify) {
if (visible && ::access(kLockFlagPath, F_OK) == 0 &&
!isCallActiveOrRingingFast()) {
!isCallScreenVisible()) {
if (ev.type == UnmapNotify) {
XMapRaised(dpy, win);
}
@@ -889,6 +901,12 @@ int locker_run_main(int argc, char** argv) {
sym == XF86XK_HangupPhone || sym == XK_Cancel ||
sym == _EVDEVK(0x74) || sym == _EVDEVK(0x8e) ||
sym == XK_Escape) {
if (isCallActiveOrRingingFast() || isCallScreenVisible()) {
sendPluginCommand("callscreen", "HANGUP_CLOSE");
::unlink("/tmp/sxmo_call_ringing");
::unlink("/tmp/sxmo_active_call");
runAsyncArgv("sxmo_modemcall.sh", "hangup", "all");
}
passcode.clear();
statusMsg.clear();
statusIsError = false;
@@ -966,7 +984,7 @@ int locker_run_main(int argc, char** argv) {
setSxmoStateFile("screenoff");
blankScreenBacklight();
} else {
if (!isCallActiveOrRingingFast() && !grabHeld) {
if (!isCallScreenVisible() && !grabHeld) {
grabLockerInput();
}
std::time_t t = std::time(nullptr);
@@ -981,7 +999,7 @@ int locker_run_main(int argc, char** argv) {
}
int timeoutMs = -1;
if (visible && !isScreenBlanked() && !isCallActiveOrRingingFast() &&
if (visible && !isScreenBlanked() && !isCallScreenVisible() &&
!grabHeld) {
timeoutMs = 35;
} else if (visible && !isScreenBlanked()) {
+13
View File
@@ -1880,6 +1880,12 @@ inline DualSimInfo queryDualSimInfo(bool forceRefresh = false) {
}
inline void placePhoneCall(const std::string& rawNumber, int simSlot = 0) {
if (isCallActiveOrRingingFast()) {
if (!sendPluginCommand("callscreen", "OPEN")) {
runAsyncArgv("xcallscreen");
}
return;
}
std::string num = normalizePhone(rawNumber);
if (num.empty()) {
return;
@@ -1948,7 +1954,10 @@ inline void closeOtherPlugins(const char* selfPluginName) {
}
inline bool isAnotherPluginActive(const char* selfPluginName) {
bool isCallScreenSelf =
(selfPluginName && std::strcmp(selfPluginName, "callscreen") == 0);
if ((!selfPluginName || std::strcmp(selfPluginName, "locker") != 0) &&
!(isCallScreenSelf && isCallActiveOrRingingFast()) &&
::access("/tmp/bananarchy_screen_locked", F_OK) == 0) {
return true;
}
@@ -1987,6 +1996,10 @@ inline bool isAnotherPluginActive(const char* selfPluginName) {
if (selfPluginName && std::strcmp(p.name, selfPluginName) == 0) {
continue;
}
if (isCallScreenSelf && std::strcmp(p.name, "locker") == 0 &&
isCallActiveOrRingingFast()) {
continue;
}
if (isPidFileAlive(getRuntimeFile(p.pidFile))) {
return true;
}
+1 -1
View File
@@ -208,7 +208,7 @@ bool isRuntimePidAliveNeoui(const char* pidFile) {
bool isExternalOverlayOrLockActive(const std::string& appName) {
if (appName != "callscreen" && appName != "xcallscreen") {
if (isCallActiveOrRingingInNeoui() ||
if (::access("/tmp/sxmo_call_ringing", F_OK) == 0 ||
isRuntimePidAliveNeoui("xcallscreen.pid")) {
return true;
}
+21 -29
View File
@@ -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
+14 -1
View File
@@ -2305,7 +2305,7 @@ static void
lock_phone_screenoff(void)
{
const Arg offcmd = SHCMD("sxmo_dmenu.sh close; sxmo_state.sh set screenoff");
int lfd;
int lfd, cfd;
softkey_pending = 0;
softkey_first_ms = 0;
softkey_deadline_ms = 0;
@@ -2316,6 +2316,13 @@ lock_phone_screenoff(void)
star_down = 0;
pound_down = 0;
write_softkey_state(0, 0);
cfd = open("/tmp/dwm_plugin_callscreen.fifo", O_WRONLY | O_NONBLOCK | O_CLOEXEC);
if (cfd >= 0) {
(void)write(cfd, "HANGUP_CLOSE\n", 13);
close(cfd);
}
unlink("/tmp/sxmo_call_ringing");
unlink("/tmp/sxmo_active_call");
lfd = open("/tmp/bananarchy_screen_locked", O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
if (lfd >= 0) {
(void)write(lfd, "1\n", 2);
@@ -2377,6 +2384,12 @@ keypress(XEvent *e)
return;
}
if (is_passcode_locked()) {
if (CLEANMASK(ev->state) == 0 &&
(keysym == XF86XK_PowerOff || ev->keycode == 124 ||
keysym == XF86XK_Phone || keysym == XF86XK_PickupPhone || ev->keycode == 177)) {
if (dispatch_plugin_global_key(keysym, ev->keycode, CLEANMASK(ev->state), 1))
return;
}
host_spawn_plugin("locker", "wake");
return;
}
+28
View File
@@ -25,6 +25,7 @@
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <dirent.h>
#include <fcntl.h>
#include <fstream>
#include <poll.h>
@@ -1244,6 +1245,33 @@ static int xdrawer_run_main(int argc, char** argv) {
if (sym == XF86XK_PowerOff || ev.xkey.keycode == 124) {
hideWindow(false);
bool callActive = (::access("/tmp/sxmo_call_ringing", F_OK) == 0 ||
::access("/tmp/sxmo_active_call", F_OK) == 0);
if (!callActive) {
std::string cdir = getRuntimeFile("sxmo_calls");
DIR* d = ::opendir(cdir.c_str());
if (d) {
struct dirent* ent;
while ((ent = ::readdir(d)) != nullptr) {
if (ent->d_name[0] != '.' && ent->d_name[0] != '\0') {
callActive = true;
break;
}
}
::closedir(d);
}
}
if (callActive) {
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);
} else {
runAsyncCmd("xcallscreen hangup >/dev/null 2>&1");
}
break;
}
int ffd = ::open("/tmp/dwm_plugin_dmenu.fifo",
O_WRONLY | O_NONBLOCK | O_CLOEXEC);
if (ffd >= 0) {