This commit is contained in:
randomuser 2022-09-19 13:29:32 -05:00
parent 454ac588d0
commit a4ea977c68
1 changed files with 13 additions and 13 deletions

26
bspc.c
View File

@ -280,11 +280,10 @@ char *send_msg_to_bspwm(char *args[], int count)
} }
int main(void) { int main(void) {
char finalbuffer[64], currentdesktop[2]; char final[64], current[2];
char *occupied[] = {"query", "-D", "-d", ".occupied", "--names"}; char *occupied[] = {"query", "-D", "-d", ".occupied", "--names"};
char *focused[] = {"query", "-D", "-d", ".focused", "--names"}; char *focused[] = {"query", "-D", "-d", ".focused", "--names"};
char *result; char *result;
char current;
int count = 5; int count = 5;
result = send_msg_to_bspwm(occupied, count); result = send_msg_to_bspwm(occupied, count);
@ -294,7 +293,7 @@ int main(void) {
return 1; return 1;
} }
memcpy(&finalbuffer, result, 64); memcpy(&final, result, 64);
result = send_msg_to_bspwm(focused, count); result = send_msg_to_bspwm(focused, count);
if(!result) { if(!result) {
@ -303,19 +302,20 @@ int main(void) {
return 1; return 1;
} }
memcpy(&currentdesktop, result, 2); memcpy(&current, result, 2);
*(currentdesktop + 1) = '\0'; current[1] = '\0';
result = finalbuffer;
for(int i = 0; i < 64; i++) { for(int i = 0; i < 64; i++) {
current = *(finalbuffer + i); if(final[i] == '\0') {
if(current == '\0') break; if (i) final[i - 1] = '\0';
if(isdigit(current) && *currentdesktop == current) break;
*(finalbuffer + i + 1) = '<'; }
if(current == '\n') if(isdigit(final[i]) && *current == final[i])
current = ' '; final[i + 1] = '<';
if(final[i] == '\n')
final[i] = ' ';
} }
printf("%s", finalbuffer); printf("%s", final);
return 0; return 0;
} }