diff --git a/README.md b/README.md index bbd0ee7..5666840 100644 --- a/README.md +++ b/README.md @@ -437,9 +437,10 @@ sketchybar -m --move after Currently only on HEAD. It is possible to clone another item instead of adding a completely blank item ```bash -sketchybar -m --clone +sketchybar -m --clone [optional: before/after] ``` -the new item will inherit *all* properties of the parent item. +the new item will inherit *all* properties of the parent item. The optional *before* and *after* modifiers can be used +to move the item *before*, or *after* the parent, equivalently to a --move command. ## Renaming Items Currently only on HEAD. It is possible to rename any item. The new name should obviously not be in use by another item: diff --git a/src/message.c b/src/message.c index 13def16..e25fea5 100644 --- a/src/message.c +++ b/src/message.c @@ -75,6 +75,7 @@ static void handle_domain_rename(FILE* rsp, struct token domain, char* message) static void handle_domain_clone(FILE* rsp, struct token domain, char* message) { struct token name = get_token(&message); struct token parent = get_token(&message); + struct token modifier = get_token(&message); struct bar_item* parent_item = NULL; int parent_index = bar_manager_get_item_index_for_name(&g_bar_manager, parent.text); @@ -92,6 +93,10 @@ static void handle_domain_clone(FILE* rsp, struct token domain, char* message) { struct bar_item* bar_item = bar_manager_create_item(&g_bar_manager); bar_item_inherit_from_item(bar_item, parent_item); bar_item_set_name(bar_item, token_to_string(name)); + if (token_equals(modifier, ARGUMENT_COMMON_VAL_BEFORE)) + bar_manager_move_item(&g_bar_manager, bar_item, parent_item, true); + else if (token_equals(modifier, ARGUMENT_COMMON_VAL_AFTER)) + bar_manager_move_item(&g_bar_manager, bar_item, parent_item, false); bar_item_needs_update(bar_item); }