summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.h27
-rw-r--r--main.cpp29
-rw-r--r--notes.org1
-rw-r--r--test2
4 files changed, 47 insertions, 12 deletions
diff --git a/config.h b/config.h
index d5d7ba5..4b140ac 100644
--- a/config.h
+++ b/config.h
@@ -8,8 +8,15 @@
const std::string startup[] = {"picom -fD 3", "feh --bg-scale /usr/share/backgrounds/vapor_trails_blue.png", "~/.config/polybar/launch.sh", "emacs --daemon"};
//Main config
+// Sensible gaps
const int gaps = 3;
const int outerGaps = 3;
+// Huge gaps
+/*
+const int gaps = 20;
+const int outerGaps = 30;
+*/
+
const std::string logFile = "/tmp/yatlog.txt";
//WS config
@@ -58,18 +65,22 @@ KEYCOM(wMove);
KEYCOM(bashSpawn);
KEYCOM(screenTest);
-//Super key mod
+// Super key mod
#define MOD Mod4Mask
-//Alt key mod
+// Alt key mod
//#define MOD Mod1Mask
#define SHIFT ShiftMask
+
+// Programs to run for keybinds
const char* alacritty[] = {"alacritty", NULL};
const char* rofi[] = {"rofi", "-i", "-show", "drun", NULL};
const char* qutebrowser[] = {"qutebrowser", NULL};
const char* i3lock[] = {"i3lock", "-eti", "/usr/share/backgrounds/lockscreen.png", NULL};
const char* suspend[] = {"systemctl", "suspend", NULL};
-const char* monConfig[] = {"~/.i3_commands/monitor-config.sh"};
+// Script to run for keybinds
+// Script I made to run an xrandr command
+const char* monConfig[] = {"~/.yat_commands/monitor-config.sh"};
#define WSKEY(K, X) \
@@ -77,8 +88,8 @@ const char* monConfig[] = {"~/.i3_commands/monitor-config.sh"};
{MOD|SHIFT, K, wToWS, {.num = X}}
const Key keyBinds[] = {
- //Modifiers //Key //Func //Args
- //General
+ // Modifiers //Key //Func //Args
+ // General
{MOD, XK_e, exit, {NULL}},
{MOD, XK_Return, spawn, {.str = alacritty}},
{MOD, XK_d, spawn, {.str = rofi}},
@@ -90,17 +101,17 @@ const Key keyBinds[] = {
{MOD|SHIFT, XK_x, spawn, {.str = suspend}},
{MOD, XK_m, bashSpawn, {.str = monConfig}},
{MOD|SHIFT, XK_t, screenTest, {NULL}},
- //Focus
+ // Focus
{MOD, XK_h, focChange, {.dir = Left}},
{MOD, XK_j, focChange, {.dir = Down}},
{MOD, XK_k, focChange, {.dir = Up}},
{MOD, XK_l, focChange, {.dir = Right}},
- //Window moving
+ // Window moving
{MOD|SHIFT, XK_h, wMove, {.dir = Left}},
{MOD|SHIFT, XK_j, wMove, {.dir = Down}},
{MOD|SHIFT, XK_k, wMove, {.dir = Up}},
{MOD|SHIFT, XK_l, wMove, {.dir = Right}},
- //Workspaces
+ // Workspaces
WSKEY(XK_1, 1),
WSKEY(XK_2, 2),
WSKEY(XK_3, 3),
diff --git a/main.cpp b/main.cpp
index 6553889..bfbd22e 100644
--- a/main.cpp
+++ b/main.cpp
@@ -66,6 +66,7 @@ int currWS = 1;
// Usefull functions
int FFCF(int sID);
void detectScreens();
+void updateMousePos();
void keyPress(XKeyEvent e);
void configureRequest(XConfigureRequestEvent e);
@@ -107,6 +108,15 @@ void detectScreens()
}
XFree(monitors);
}
+void updateMousePos()
+{
+ Window rootRet, childRet;
+ int rX, rY, cX, cY;
+ unsigned int maskRet;
+ XQueryPointer(dpy, root, &rootRet, &childRet, &rX, &rY, &cX, &cY, &maskRet);
+ mX = rX;
+ mY = rY;
+}
//Keybind commands
void exit(const KeyArg arg)
@@ -162,13 +172,23 @@ void kill(const KeyArg arg)
void changeWS(const KeyArg arg)
{
int prevWS = currWS;
- currWS = arg.num;
+ currWS = arg.num;
if(prevWS == currWS)
return;
+ for(int i = 0; i < maxMonitors; i++)
+ {
+ if(nscreens > screenPreferences[arg.num][i])
+ {
+ focusedWorkspaces[screenPreferences[arg.num][i]] = arg.num;
+ focusedScreen = screenPreferences[arg.num][i];
+ }
+ }
+
untile(prevWS);
- tile(currWS, outerGaps, outerGaps, sW - outerGaps*2, sH - outerGaps*2 - bH);
+ //tile(currWS, outerGaps, outerGaps, sW - outerGaps*2, sH - outerGaps*2 - bH);
+ tileRoots();
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
//EWMH
@@ -384,6 +404,7 @@ void screenTest(const KeyArg arg)
void keyPress(XKeyEvent e)
{
if(e.same_screen!=1) return;
+ updateMousePos();
KeySym keysym = XLookupKeysym(&e, 0);
for(int i = 0; i < sizeof(keyBinds)/sizeof(keyBinds[0]); i++)
{
@@ -426,6 +447,7 @@ void mapRequest(XMapRequestEvent e)
//Use focused to determine monitors
XWindowAttributes focAttr;
XGetWindowAttributes(dpy, focusedWindow, &focAttr);
+ //TODO: Make this find the monitor
log("\tFocused is at x: " << focAttr.x << ", y: " << focAttr.y);
}
else
@@ -442,6 +464,7 @@ void mapRequest(XMapRequestEvent e)
else
{
//Use mouse
+ //TODO: Make this find the monitor
log("\tMouse is at x: " << rX << ", y: " << rY);
mX = rX;
mY = rY;
@@ -746,7 +769,7 @@ int main(int argc, char** argv)
}
}
- XSetInputFocus(dpy, root, RevertToNone, CurrentTime);
+ XSetInputFocus(dpy, root, RevertToNone, CurrentTime);
cout << "Begin mainloop\n";
while(keepGoing)
diff --git a/notes.org b/notes.org
index e67a9a0..4489102 100644
--- a/notes.org
+++ b/notes.org
@@ -8,6 +8,7 @@
- If not then use mouseX and mouseY
** When to update mouseX and mouseY
Whenever I change focus or focused screen or map a new window
+Or just updating every key press should work
** When to change focusedScreen
It should get changed when I change workspace to one that should go on a different screen
** How to tell which monitor to focus when changing workspace
diff --git a/test b/test
index 6a49b10..81cab6f 100644
--- a/test
+++ b/test
@@ -2,7 +2,7 @@
make
-Xephyr -screen 1600x900+160+0 :100 &
+Xephyr -screen 1600x900+2080+90 :100 &
sleep 0.1