fix bug
This commit is contained in:
parent
454ac588d0
commit
a4ea977c68
26
bspc.c
26
bspc.c
|
@ -280,11 +280,10 @@ char *send_msg_to_bspwm(char *args[], int count)
|
|||
}
|
||||
|
||||
int main(void) {
|
||||
char finalbuffer[64], currentdesktop[2];
|
||||
char final[64], current[2];
|
||||
char *occupied[] = {"query", "-D", "-d", ".occupied", "--names"};
|
||||
char *focused[] = {"query", "-D", "-d", ".focused", "--names"};
|
||||
char *result;
|
||||
char current;
|
||||
int count = 5;
|
||||
|
||||
result = send_msg_to_bspwm(occupied, count);
|
||||
|
@ -294,7 +293,7 @@ int main(void) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
memcpy(&finalbuffer, result, 64);
|
||||
memcpy(&final, result, 64);
|
||||
|
||||
result = send_msg_to_bspwm(focused, count);
|
||||
if(!result) {
|
||||
|
@ -303,19 +302,20 @@ int main(void) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
memcpy(¤tdesktop, result, 2);
|
||||
*(currentdesktop + 1) = '\0';
|
||||
memcpy(¤t, result, 2);
|
||||
current[1] = '\0';
|
||||
|
||||
result = finalbuffer;
|
||||
for(int i = 0; i < 64; i++) {
|
||||
current = *(finalbuffer + i);
|
||||
if(current == '\0') break;
|
||||
if(isdigit(current) && *currentdesktop == current)
|
||||
*(finalbuffer + i + 1) = '<';
|
||||
if(current == '\n')
|
||||
current = ' ';
|
||||
if(final[i] == '\0') {
|
||||
if (i) final[i - 1] = '\0';
|
||||
break;
|
||||
}
|
||||
printf("%s", finalbuffer);
|
||||
if(isdigit(final[i]) && *current == final[i])
|
||||
final[i + 1] = '<';
|
||||
if(final[i] == '\n')
|
||||
final[i] = ' ';
|
||||
}
|
||||
printf("%s", final);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue