feat(x11): disable X screensaver/DPMS blanking and enforce explicit-only locking

This commit is contained in:
Luxferre
2026-10-22 22:15:28 +03:00
parent c646800dbf
commit 179cc3066b
20 changed files with 38 additions and 227 deletions
-21
View File
@@ -839,23 +839,6 @@ handle_builtin_toggle(const char *toggle_name)
if (fd >= 0)
close(fd);
}
} else if (strcmp(toggle_name, "autoscreenoff") == 0) {
const char *home = getenv("HOME");
if (!home || !home[0])
home = "/home/user";
char path[256];
snprintf(path, sizeof(path), "%s/.cache/sxmo/sxmo.noidle", home);
if (access(path, F_OK) == 0) {
unlink(path);
} else {
char dir[256];
snprintf(dir, sizeof(dir), "%s/.cache/sxmo", home);
mkdir(dir, 0755);
int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
if (fd >= 0)
close(fd);
}
spawn_detached_sh("sxmo_state.sh set unlock");
} else if (strcmp(toggle_name, "bluetooth") == 0) {
int rc = system("doas sxmo_bluetoothtoggle.sh >/dev/null 2>&1");
(void)rc;
@@ -1829,10 +1812,6 @@ open_builtin_menu(const char *menu_name, int keep_idx)
snprintf(label, sizeof(label), "%s Auto-suspend %s", ICON_ZZZ, (access(pbuf, F_OK) == 0) ? ICON_TOF : ICON_TON);
add_menu_item(label, "@toggle:autosuspend", 1);
snprintf(pbuf, sizeof(pbuf), "%s/.cache/sxmo/sxmo.noidle", home);
snprintf(label, sizeof(label), "%s Auto-screen-off %s", ICON_ZZZ, (access(pbuf, F_OK) == 0) ? ICON_TOF : ICON_TON);
add_menu_item(label, "@toggle:autoscreenoff", 1);
snprintf(label, sizeof(label), "%s Hooks", ICON_TRM);
add_menu_item(label, "sxmo_hookmenu.sh", 0);
snprintf(label, sizeof(label), "%s Suspend Blockers", ICON_CFG);
+4 -3
View File
@@ -1909,7 +1909,7 @@ keypress(XEvent *e)
keysym == XK_Return ||
keysym == XF86XK_KbdLcdMenu1 || keysym == XF86XK_KbdLcdMenu2) &&
is_phone_locked()) {
const Arg unlockcmd = SHCMD("xset dpms 0 0 0; xset dpms force on; sxmo_state.sh set unlock");
const Arg unlockcmd = SHCMD("xset s off s noblank -dpms; sxmo_state.sh set unlock");
softkey_pending = 0;
softkey_first_ms = 0;
softkey_deadline_ms = 0;
@@ -2487,11 +2487,11 @@ run(void)
while (read(lidfd, &ie, sizeof(ie)) == (ssize_t)sizeof(ie)) {
if (ie.type == EV_SW && ie.code == SW_LID) {
if (ie.value == 1) {
const Arg offcmd = SHCMD("sxmo_dmenu.sh close; xset dpms 0 0 3; xset dpms force off; sxmo_state.sh set screenoff");
const Arg offcmd = SHCMD("sxmo_dmenu.sh close; sxmo_state.sh set screenoff");
set_hw_backlight(0);
spawn(&offcmd);
} else if (ie.value == 0) {
const Arg oncmd = SHCMD("xset dpms 0 0 0; xset dpms force on; sxmo_state.sh set unlock");
const Arg oncmd = SHCMD("xset s off s noblank -dpms; sxmo_state.sh set unlock");
set_hw_backlight(1);
spawn(&oncmd);
}
@@ -2659,6 +2659,7 @@ setup(void)
sw = DisplayWidth(dpy, screen);
sh = DisplayHeight(dpy, screen);
root = RootWindow(dpy, screen);
XSetScreenSaver(dpy, 0, 0, DontPreferBlanking, AllowExposures);
drw = drw_create(dpy, screen, root, sw, sh);
snprintf(active_font, sizeof(active_font), "%s", font);