fix multi item aliasing from single owner

This commit is contained in:
FelixKratz 2021-09-20 11:49:09 +02:00
parent 6a61e3ef2d
commit 91a9a694d5
3 changed files with 15 additions and 4 deletions

View file

@ -46,7 +46,9 @@ Table of Contents
* [Scripting](#scripting) * [Scripting](#scripting)
* [Experimental Features](#experimental-features) * [Experimental Features](#experimental-features)
* [Default Menu Bar Item Alias](#default-menu-bar-item-alias) * [Default Menu Bar Item Alias](#default-menu-bar-item-alias)
* [Credits](#credits)## Description * [Credits](#credits)
## Description
This bar project aims to create a highly flexible, customizable and fast statusbar for users that like playing around with This bar project aims to create a highly flexible, customizable and fast statusbar for users that like playing around with
shell scripts and want to make their statusbar show exactly the information they need for their workflow. shell scripts and want to make their statusbar show exactly the information they need for their workflow.
@ -401,7 +403,7 @@ sketchybar -m add alias <application_name> <position>
``` ```
this operation requires screen capture permissions, which should be granted in the system preferences. this operation requires screen capture permissions, which should be granted in the system preferences.
This will put the default item into sketchybar. This will put the default item into sketchybar.
Aliases currently are not clickable. Aliases currently are not clickable but can be modified with all the options available for simple items.
The command can be overloaded by providing a *window_owner* and a *window_name* The command can be overloaded by providing a *window_owner* and a *window_name*
```bash ```bash
@ -411,9 +413,16 @@ this way the default system items can also be slurped into sketchybar, e.g.:
Owner: Control Center, Name: Bluetooth <br> Owner: Control Center, Name: Bluetooth <br>
Owner: Control Center, Name: WiFi <br> Owner: Control Center, Name: WiFi <br>
Owner: Control Center Name: Sound
Owner: Control Center, Name: UserSwitcher <br> Owner: Control Center, Name: UserSwitcher <br>
Owner: TextInputSwitcher, Name: Keyboard Input <br> Owner: TextInputSwitcher, Name: Keyboard Input <br>
Owner: SystemUIServer, Name: AppleTimeMachineExtra <br> Owner: SystemUIServer, Name: AppleTimeMachineExtra <br>
Or the individual widgets of [Stats](https://github.com/exelban/stats):<br>
Owner: Stats Name: CPU_Mini<br>
Owner: Stats Name: RAM_Mini<br>
Owner: Stats Name: Network_Speed<br>
etc...
## Credits ## Credits
yabai, yabai,
spacebar, spacebar,

View file

@ -30,7 +30,7 @@ void alias_find_window(struct alias* alias) {
if (!owner_ref) continue; if (!owner_ref) continue;
char* owner = cfstring_copy(owner_ref); char* owner = cfstring_copy(owner_ref);
char* name = cfstring_copy(name_ref); char* name = cfstring_copy(name_ref);
if (!owner) continue; //printf("Owner: %s Name: %s \n", owner, name);
if (!(alias->owner && strcmp(alias->owner, owner) == 0 && ((alias->name && strcmp(alias->name, name) == 0) || !alias->name))) { free(owner); free(name); continue; } if (!(alias->owner && strcmp(alias->owner, owner) == 0 && ((alias->name && strcmp(alias->name, name) == 0) || !alias->name))) { free(owner); free(name); continue; }
free(owner); free(owner);

View file

@ -319,11 +319,13 @@ static void handle_domain_add(FILE* rsp, struct token domain, char* message) {
else if (bar_item->type == BAR_COMPONENT_ALIAS) { else if (bar_item->type == BAR_COMPONENT_ALIAS) {
char* owner = NULL; char* owner = NULL;
char* nme = NULL; char* nme = NULL;
get_key_value_pair(name.text, &owner, &nme, ','); char* tmp_name = string_copy(name.text);
get_key_value_pair(tmp_name, &owner, &nme, ',');
if (!nme || !owner) if (!nme || !owner)
alias_init(&bar_item->alias, token_to_string(name), NULL); alias_init(&bar_item->alias, token_to_string(name), NULL);
else else
alias_init(&bar_item->alias, string_copy(owner), string_copy(nme)); alias_init(&bar_item->alias, string_copy(owner), string_copy(nme));
free(tmp_name);
bar_item->has_alias = true; bar_item->has_alias = true;
} }
} else if (token_equals(command, COMMAND_ADD_PLUGIN)) { } else if (token_equals(command, COMMAND_ADD_PLUGIN)) {