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) {
|
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(¤tdesktop, result, 2);
|
memcpy(¤t, 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')
|
|
||||||
current = ' ';
|
|
||||||
}
|
}
|
||||||
printf("%s", finalbuffer);
|
if(isdigit(final[i]) && *current == final[i])
|
||||||
|
final[i + 1] = '<';
|
||||||
|
if(final[i] == '\n')
|
||||||
|
final[i] = ' ';
|
||||||
|
}
|
||||||
|
printf("%s", final);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue