Last active
March 18, 2021 09:20
-
-
Save josefandersson/f26ed70fdddd5f508352f34d0911809d to your computer and use it in GitHub Desktop.
Method for bypassing bspwm 'focus' bug for chromium based apps. Build bspwmhacky.c, start it with bspwm, use xdotool to move hacky window to desktop before focusing on desktop.
This file contains 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
#include <X11/Xlib.h> | |
#include <X11/Xutil.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
int main(void) { | |
XEvent e; | |
Display *d = XOpenDisplay(NULL); | |
if (d == NULL) { | |
fprintf(stderr, "Cannot open display\n"); | |
exit(1); | |
} | |
int s = DefaultScreen(d); | |
Window w = XCreateSimpleWindow(d, RootWindow(d, s), 0, 0, 1, 1, 1, 0, 0); | |
XMapWindow(d, w); | |
XClassHint *ch = XAllocClassHint(); | |
ch->res_name = "bspwmhacky"; | |
ch->res_class = "bspwmhacky"; | |
XSetClassHint(d, w, ch); | |
XFree(ch); | |
XMoveWindow(d, w, 0, -10); | |
while (1) { | |
XNextEvent(d, &e); | |
usleep(10); | |
} | |
return 0; | |
} |
This file contains 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
bspc rule -a bspwmhacky state=floating | |
# Program has to be launched after rule is set | |
killall bspwmhacky ; bspwmhacky & |
This file contains 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
# Switch to a desktop on focused monitor (made for dual monitor) | |
super + {1-9} | |
D={0-8}; \ | |
M=$((($(xdotool get_desktop) > 8))); \ | |
T=$((($D + 9 * $M))); \ | |
xdotool search --class hacky set_desktop_for_window %@ "$T"; \ | |
xdotool set_desktop $T; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use:
bspwmhacky.c
(eg.gcc bspwmhacky.c -L/usr/X11R6/lib -lX11 -o bspwmhacky
)For single monitor this is sufficient:
I will note that this fix of having a ghost window could be incompatible with some peoples hotkeys/scripts but this works for me.