Remove unnecessary background services and polling loops to improve battery life
This commit is contained in:
1 parent
726500085a
commit
68cf9c515b
17 files changed
+159
-22
No files matched your search
@@ -278,6 +278,62 @@ update_t9_status_indicator(void)
|
||||
fprintf(fp, "%s\n", badge);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
if (dpy && root) {
|
||||
char status_dir[256];
|
||||
snprintf(status_dir, sizeof(status_dir), "%s/sxmo_status/default", base);
|
||||
DIR *dir = opendir(status_dir);
|
||||
if (dir) {
|
||||
char names[32][64];
|
||||
int count = 0;
|
||||
struct dirent *ent;
|
||||
while ((ent = readdir(dir)) != NULL && count < 32) {
|
||||
if (ent->d_name[0] == '.')
|
||||
continue;
|
||||
snprintf(names[count], sizeof(names[count]), "%s", ent->d_name);
|
||||
count++;
|
||||
}
|
||||
closedir(dir);
|
||||
for (int i = 0; i < count - 1; i++) {
|
||||
for (int j = i + 1; j < count; j++) {
|
||||
if (strcmp(names[i], names[j]) > 0) {
|
||||
char tmp[64];
|
||||
memcpy(tmp, names[i], sizeof(tmp));
|
||||
memcpy(names[i], names[j], sizeof(names[i]));
|
||||
memcpy(names[j], tmp, sizeof(names[j]));
|
||||
}
|
||||
}
|
||||
}
|
||||
char status_line[512];
|
||||
size_t pos = 0;
|
||||
status_line[0] = '\0';
|
||||
for (int i = 0; i < count; i++) {
|
||||
char fpath[320];
|
||||
snprintf(fpath, sizeof(fpath), "%s/%s", status_dir, names[i]);
|
||||
FILE *sfp = fopen(fpath, "r");
|
||||
if (!sfp)
|
||||
continue;
|
||||
char lbuf[128];
|
||||
if (fgets(lbuf, sizeof(lbuf), sfp)) {
|
||||
size_t len = strlen(lbuf);
|
||||
while (len > 0 && (lbuf[len - 1] == '\n' || lbuf[len - 1] == '\r'))
|
||||
lbuf[--len] = '\0';
|
||||
if (len > 0 && pos + len + 2 < sizeof(status_line)) {
|
||||
if (pos > 0)
|
||||
status_line[pos++] = ' ';
|
||||
memcpy(status_line + pos, lbuf, len);
|
||||
pos += len;
|
||||
status_line[pos] = '\0';
|
||||
}
|
||||
}
|
||||
fclose(sfp);
|
||||
}
|
||||
if (pos > 0) {
|
||||
XStoreName(dpy, root, status_line);
|
||||
XFlush(dpy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in new issue
Block a user