Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

Run or Raise #519

Open
clicseo opened this issue Nov 19, 2023 · 3 comments
Open

Run or Raise #519

clicseo opened this issue Nov 19, 2023 · 3 comments
Labels
A: enhancement New feature or request

Comments

@clicseo
Copy link

clicseo commented Nov 19, 2023

Hello,

I am trying to implement a run or raise feature on my new dwl build. I used wlrctl for all my other wayland compositors but I am getting Foreign Toplevel Management interface not found! on dwl.

How can I implement this feature, any other available tool to get it? I want to have keybindings to open apps, or focus them if they're already opened instead of opening new instances of the app.

Thank you in advance!

@clicseo clicseo added the A: enhancement New feature or request label Nov 19, 2023
@wochap
Copy link

wochap commented Nov 25, 2023

You could extend the functionality of the namedscratchpads patch:

void
run_or_raise_scratch(const Arg *arg)
{
	Client *c;
	unsigned int found = 0;

	/* search for first window that matches the scratchkey */
	wl_list_for_each(c, &clients, link)
		if (c->scratchkey == ((char**)arg->v)[0][0]) {
			found = 1;
			break;
		}

	if (found) {
		if (VISIBLEON(c, selmon)) {
			if (focustop(selmon) != c) {
			        // focus
				focusclient(c, 1);
			}
		} else {
			// show/move client to current workspace/tags
			c->tags = selmon->tagset[selmon->seltags];
			// TODO: or change current workspace/tags to where client is located
			
			// focus
			focusclient(c, 1);
		}
		arrange(selmon);
	} else{
		spawnscratch(arg);
	}
}

@Sneethe
Copy link

Sneethe commented Nov 26, 2023

If this works well. Be sure to add it to the patch list.

@clicseo
Copy link
Author

clicseo commented Nov 29, 2023

You could extend the functionality of the namedscratchpads patch:

void
run_or_raise_scratch(const Arg *arg)
{
	Client *c;
	unsigned int found = 0;

	/* search for first window that matches the scratchkey */
	wl_list_for_each(c, &clients, link)
		if (c->scratchkey == ((char**)arg->v)[0][0]) {
			found = 1;
			break;
		}

	if (found) {
		if (VISIBLEON(c, selmon)) {
			if (focustop(selmon) != c) {
			        // focus
				focusclient(c, 1);
			}
		} else {
			// show/move client to current workspace/tags
			c->tags = selmon->tagset[selmon->seltags];
			// TODO: or change current workspace/tags to where client is located
			
			// focus
			focusclient(c, 1);
		}
		arrange(selmon);
	} else{
		spawnscratch(arg);
	}
}

After a couple of days fighting with this I managed to make it work. Thank you very much for your help, the only thing I had to change is:

        selmon->tagset[selmon->seltags] = c->tags;
        focusclient(c, 1);
        arrange(selmon);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants