From 92e2bc56f7f74ca7354271a59765998d09f59d75 Mon Sep 17 00:00:00 2001 From: Sakooooo <78461130+Sakooooo@users.noreply.github.com> Date: Wed, 2 Aug 2023 16:05:37 +0300 Subject: [PATCH] add dwm-movekeyboard patch --- config/dwm/config.def.h | 4 ++ config/dwm/config.def.h.orig | 33 +++++++++++--- config/dwm/dwm.c | 88 ++++++++++++++++++++++++++++++++++++ config/dwm/dwm.c.orig | 10 ++++ 4 files changed, 128 insertions(+), 7 deletions(-) diff --git a/config/dwm/config.def.h b/config/dwm/config.def.h index 3c85a130..9394e415 100644 --- a/config/dwm/config.def.h +++ b/config/dwm/config.def.h @@ -116,6 +116,10 @@ static const Key keys[] = { { MODKEY, XK_comma, focusmon, {.i = -1 } }, { MODKEY, XK_period, focusmon, {.i = +1 } }, { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { MODKEY|ControlMask, XK_l, movekeyboard_x, {.i = 20}}, + { MODKEY|ControlMask, XK_h, movekeyboard_x, {.i = -20}}, + { MODKEY|ControlMask, XK_j, movekeyboard_y, {.i = 20}}, + { MODKEY|ControlMask, XK_k, movekeyboard_y, {.i = -20}}, { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, { MODKEY, XK_minus, setgaps, {.i = -1 } }, { MODKEY, XK_equal, setgaps, {.i = +1 } }, diff --git a/config/dwm/config.def.h.orig b/config/dwm/config.def.h.orig index 93582254..3c85a130 100644 --- a/config/dwm/config.def.h.orig +++ b/config/dwm/config.def.h.orig @@ -1,8 +1,12 @@ /* See LICENSE file for copyright and license details. */ +/* includes */ + +#include + /* appearance */ static const unsigned int borderpx = 2; /* border pixel of windows */ -static const unsigned int gappx = 10; /* gaps between windows */ +static const unsigned int gappx = 15; /* gaps between windows */ static const unsigned int snap = 32; /* snap pixel */ static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */ static const unsigned int systrayonleft = 0; /* 0: systray in the right corner, >0: systray on left of status text */ @@ -11,13 +15,14 @@ static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display static const int showsystray = 1; /* 0 means no systray */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ -static const char *fonts[] = { "monospace:size=10" }; +static const char *fonts[] = { "JetBrainsMono NF:size=10" }; static const char dmenufont[] = "monospace:size=10"; -static const char col_gray1[] = "#222222"; +//static const char col_gray1[] = "#222222"; +static const char col_gray1[] = "#000000"; static const char col_gray2[] = "#444444"; -static const char col_gray3[] = "#bbbbbb"; +static const char col_gray3[] = "#cccccc"; static const char col_gray4[] = "#eeeeee"; -static const char col_cyan[] = "#005577"; +static const char col_cyan[] = "#770000"; static const char *colors[][3] = { /* fg bg border */ [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, @@ -25,18 +30,21 @@ static const char *colors[][3] = { }; static const char *const autostart[] = { - "xsetroot", "-cursor_name", "left_ptr", NULL, + "xsetroot", "-cursor_name", "Catppuccin-Mocha-Dark", NULL, "feh", "--bg-scale", "/home/sako/.config/bspwm/background.png", NULL, + "dwmblocks", NULL, "nm-applet", NULL, "blueman-applet", NULL, "keepassxc", NULL, "flameshot", NULL, + "discord", NULL, + "transmission-gtk", "-m", NULL, NULL /* terminate */ }; /* tagging */ // static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; -static const char *tags[] = { "1", "2", "3", "4", "5", "6" }; +static const char *tags[] = { "web", "dev", "irc", "media", "game", "misc" }; static const Rule rules[] = { /* xprop(1): @@ -46,6 +54,8 @@ static const Rule rules[] = { /* class instance title tags mask isfloating monitor */ { "Gimp", NULL, NULL, 0, 1, -1 }, { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, + { "discord", NULL, NULL, 1 << 2, 0, -1 }, + { ".blueman-manager-wrapped", NULL, NULL, 0, 1, -1}, }; /* layout(s) */ @@ -77,6 +87,10 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char *roficmd[] = { "rofi", "-show-icons", "-show", "drun", NULL }; static const char *termcmd[] = { "kitty", NULL }; +// audio +static const char *upvol[] = { "pactl", "set-sink-volume", "0", "+5%", NULL }; +static const char *downvol[] = { "pactl", "set-sink-volume", "0", "-5%", NULL }; +static const char *mutevol[] = { "pactl", "set-sink-mute", "0", "toggle", NULL }; static const Key keys[] = { /* modifier key function argument */ @@ -97,6 +111,7 @@ static const Key keys[] = { { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XK_p, setlayout, {0} }, { MODKEY|ShiftMask, XK_p, togglefloating, {0} }, + { MODKEY|ShiftMask, XK_f, togglefullscr, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } }, { MODKEY, XK_comma, focusmon, {.i = -1 } }, { MODKEY, XK_period, focusmon, {.i = +1 } }, @@ -105,6 +120,10 @@ static const Key keys[] = { { MODKEY, XK_minus, setgaps, {.i = -1 } }, { MODKEY, XK_equal, setgaps, {.i = +1 } }, { MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } }, + // audio + { 0, XF86XK_AudioLowerVolume, spawn, {.v = downvol } }, + { 0, XF86XK_AudioMute, spawn, {.v = mutevol } }, + { 0, XF86XK_AudioRaiseVolume, spawn, {.v = upvol } }, TAGKEYS( XK_1, 0) TAGKEYS( XK_2, 1) TAGKEYS( XK_3, 2) diff --git a/config/dwm/dwm.c b/config/dwm/dwm.c index 198d0ca7..323de38f 100644 --- a/config/dwm/dwm.c +++ b/config/dwm/dwm.c @@ -207,6 +207,8 @@ static void maprequest(XEvent *e); static void monocle(Monitor *m); static void motionnotify(XEvent *e); static void movemouse(const Arg *arg); +static void movekeyboard_x(const Arg *arg); +static void movekeyboard_y(const Arg *arg); static Client *nexttiled(Client *c); static void pop(Client *c); static void propertynotify(XEvent *e); @@ -1363,6 +1365,92 @@ movemouse(const Arg *arg) } } +void +movekeyboard_x(const Arg *arg){ + int ocx, ocy, nx, ny; + Client *c; + Monitor *m; + + if (!(c = selmon->sel)) + return; + + if (c->isfullscreen) /* no support moving fullscreen windows by mouse */ + return; + + restack(selmon); + + ocx = c->x; + ocy = c->y; + + nx = ocx + arg->i; + ny = ocy; + + if (abs(selmon->wx - nx) < snap) + nx = selmon->wx; + else if (abs((selmon->wx + selmon->ww) - (nx + WIDTH(c))) < snap) + nx = selmon->wx + selmon->ww - WIDTH(c); + + if (abs(selmon->wy - ny) < snap) + ny = selmon->wy; + else if (abs((selmon->wy + selmon->wh) - (ny + HEIGHT(c))) < snap) + ny = selmon->wy + selmon->wh - HEIGHT(c); + + if (!c->isfloating) + togglefloating(NULL); + + if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) + resize(c, nx, ny, c->w, c->h, 1); + + if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) { + sendmon(c, m); + selmon = m; + focus(NULL); + } +} + +void +movekeyboard_y(const Arg *arg){ + int ocx, ocy, nx, ny; + Client *c; + Monitor *m; + + if (!(c = selmon->sel)) + return; + + if (c->isfullscreen) /* no support moving fullscreen windows by mouse */ + return; + + restack(selmon); + + ocx = c->x; + ocy = c->y; + + nx = ocx; + ny = ocy + arg->i; + + if (abs(selmon->wx - nx) < snap) + nx = selmon->wx; + else if (abs((selmon->wx + selmon->ww) - (nx + WIDTH(c))) < snap) + nx = selmon->wx + selmon->ww - WIDTH(c); + + if (abs(selmon->wy - ny) < snap) + ny = selmon->wy; + else if (abs((selmon->wy + selmon->wh) - (ny + HEIGHT(c))) < snap) + ny = selmon->wy + selmon->wh - HEIGHT(c); + + if (!c->isfloating) + togglefloating(NULL); + + if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) + resize(c, nx, ny, c->w, c->h, 1); + + if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) { + sendmon(c, m); + selmon = m; + focus(NULL); + } +} + Client * nexttiled(Client *c) { diff --git a/config/dwm/dwm.c.orig b/config/dwm/dwm.c.orig index 1bf4fa21..198d0ca7 100644 --- a/config/dwm/dwm.c.orig +++ b/config/dwm/dwm.c.orig @@ -239,6 +239,7 @@ static void tagmon(const Arg *arg); static void tile(Monitor *m); static void togglebar(const Arg *arg); static void togglefloating(const Arg *arg); +static void togglefullscr(const Arg *arg); static void toggletag(const Arg *arg); static void toggleview(const Arg *arg); static void unfocus(Client *c, int setfocus); @@ -1219,6 +1220,8 @@ manage(Window w, XWindowAttributes *wa) updatewindowtype(c); updatesizehints(c); updatewmhints(c); + c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2; + c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2; XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask); grabbuttons(c, 0); if (!c->isfloating) @@ -2012,6 +2015,13 @@ togglefloating(const Arg *arg) arrange(selmon); } +void +togglefullscr(const Arg *arg) +{ + if(selmon->sel) + setfullscreen(selmon->sel, !selmon->sel->isfullscreen); +} + void toggletag(const Arg *arg) {