mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-10-29 05:40:21 -04:00
feat: add dispatch spawn_on_empty
This commit is contained in:
parent
98f942568a
commit
ab4c8d5679
4 changed files with 32 additions and 1 deletions
|
|
@ -265,7 +265,9 @@ bind=ALT+SHIFT,Z,incgaps,-1
|
|||
bind=ALT+SHIFT,R,togglegaps
|
||||
|
||||
#custom app bind example
|
||||
# bind=SUPER,Return,spawn,google-chrome
|
||||
# spawn_on_empty (if tag 4 is empty , open app in this,otherwise view to tag 4)
|
||||
# bind=SUPER,Return,spawn_on_empty,google-chrome,4
|
||||
# spawn
|
||||
# bind=CTRL+ALT,Return,spawn,st -e ~/tool/ter-multiplexer.sh
|
||||
|
||||
# Mouse Button Bindings
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ void togglemaxmizescreen(const Arg *arg);
|
|||
void togglegaps(const Arg *arg);
|
||||
void tagmon(const Arg *arg);
|
||||
void spawn(const Arg *arg);
|
||||
void spawn_on_empty(const Arg *arg);
|
||||
void setlayout(const Arg *arg);
|
||||
void switch_layout(const Arg *arg);
|
||||
void setmfact(const Arg *arg);
|
||||
|
|
|
|||
19
maomao.c
19
maomao.c
|
|
@ -5287,6 +5287,25 @@ void spawn(const Arg *arg) {
|
|||
}
|
||||
}
|
||||
|
||||
void spawn_on_empty(const Arg *arg) {
|
||||
bool is_empty = true;
|
||||
Client *c;
|
||||
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (arg->ui & c->tags) {
|
||||
is_empty = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!is_empty) {
|
||||
view(arg,true);
|
||||
return;
|
||||
} else {
|
||||
view(arg,true);
|
||||
spawn(arg);
|
||||
}
|
||||
}
|
||||
|
||||
void startdrag(struct wl_listener *listener, void *data) {
|
||||
struct wlr_drag *drag = data;
|
||||
if (!drag->icon)
|
||||
|
|
|
|||
|
|
@ -449,6 +449,15 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value) {
|
|||
} else if (strcmp(func_name, "spawn") == 0) {
|
||||
func = spawn;
|
||||
(*arg).v = strdup(arg_value);
|
||||
} else if (strcmp(func_name, "spawn_on_empty") == 0) {
|
||||
char cmd[256],tag_num[256];
|
||||
if (sscanf(arg_value, "%255[^,],%255s", cmd, tag_num) == 2) {
|
||||
func = spawn_on_empty;
|
||||
(*arg).v = strdup(cmd); // 注意:之后需要释放这个内存
|
||||
(*arg).ui = 1 << (atoi(tag_num) - 1);
|
||||
} else {
|
||||
fprintf(stderr, "Error: Invalid value format: %s\n", arg_value);
|
||||
}
|
||||
} else if (strcmp(func_name, "quit") == 0) {
|
||||
func = quit;
|
||||
} else if (strcmp(func_name, "moveresize") == 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue