Created
December 26, 2018 06:38
-
-
Save smblott-github/5cc6595f6627244fdeac897668a19d72 to your computer and use it in GitHub Desktop.
<alt-Tab> for dwm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* this implements <alt-Tab> for dwm, put it in config.h */ | |
static int alt_tab_count = 0; | |
/* focus and restack a client */ | |
static void focus_restack(Client *c) | |
{ if (c) { focus(c); restack(selmon); } } | |
static void start_alt_tab(const Arg *arg) | |
{ alt_tab_count = 0; } | |
static Client *next_visible(Client *c) | |
{ | |
for(/* DO_NOTHING */; c && !ISVISIBLE(c); c=c->snext); | |
return c; | |
} | |
static int count_visible(void) | |
{ | |
int count = 0; | |
for (Client *c=next_visible(selmon->stack); c; c = next_visible(c->snext)) | |
count += 1; | |
return count; | |
} | |
static Client *get_nth_client(int n) | |
{ | |
Client *c; | |
for (c=next_visible(selmon->stack); c && n--; c = next_visible(c->snext)); | |
return c; | |
} | |
static void alt_tab(const Arg *arg) | |
{ | |
// put all of the windows back in their original focus/stack position */ | |
for (int i=0; i<alt_tab_count; i+=1) | |
focus_restack(get_nth_client(alt_tab_count)); | |
// focus and restack the nth window */ | |
alt_tab_count = (alt_tab_count + 1) % count_visible(); | |
focus_restack(get_nth_client(alt_tab_count)); | |
} | |
/* | |
static Key keys[] = { | |
// ... | |
{ 0, XK_Alt_L, start_alt_tab, {0} }, | |
{ MODKEY, XK_Tab, alt_tab, {0} }, | |
// ... | |
}; | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could this search clients throughout different tags aswell?