From b943c6cb48f404e252fef7e2aee1b2a428f5408b Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Sat, 29 Aug 2020 17:42:22 +0200 Subject: [PATCH] added setfloating function --- config.h | 14 +++++++++----- dwm.c | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/config.h b/config.h index a25a96c..045d3a5 100644 --- a/config.h +++ b/config.h @@ -37,7 +37,7 @@ static char selfgcolor[] = nord6; static char selbgcolor[] = nord10; static char selbordercolor[] = nord4; -static const char col_urgborder[] = "#ff0000"; +static const char col_urgborder[] = nord11; static const char *colors[][3] = { /* fg bg border */ @@ -52,6 +52,7 @@ typedef struct { } Sp; const char *spcmd1[] = {"st", "-n", "scratchpadterm", "-t", "Scratchpad", "-g", "120x34", NULL }; const char *spcmd2[] = {"st", "-n", "scratchcalc", "-t", "Calculator", "-g", "120x34", "-e", "dropdowncalc", NULL }; + static Sp scratchpads[] = { /* name cmd */ {"scratchpad", spcmd1}, @@ -140,7 +141,7 @@ static Key keys[] = { { MODKEY, XK_w, spawn, SHCMD("$BROWSER") }, { MODKEY|ShiftMask, XK_w, spawn, SHCMD("brave") }, { MODKEY, XK_e, spawn, SHCMD("st -e neomutt -e 'set sidebar_visible = no'; pkill -RTMIN+12 dwmblocks") }, - { MODKEY|ShiftMask, XK_e, spawn, SHCMD("tutorialvids") }, + { MODKEY|ShiftMask, XK_e, spawn, SHCMD("element-desktop") }, { MODKEY, XK_r, spawn, SHCMD("st -e $FILE") }, { MODKEY|ShiftMask, XK_r, spawn, SHCMD("st -e lf") }, { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, @@ -170,7 +171,7 @@ static Key keys[] = { { MODKEY, XK_f, togglefullscr, {0} }, { MODKEY|ShiftMask, XK_f, setlayout, {.v = &layouts[8]} }, { MODKEY, XK_g, shiftview, { .i = -1 } }, - { MODKEY|ShiftMask, XK_g, spawn, SHCMD("hover center") }, + //{ MODKEY|ShiftMask, XK_g, spawn, SHCMD("hover center") }, { MODKEY, XK_h, focusmon, {.i = -1 } }, { MODKEY|ShiftMask, XK_h, setmfact, {.f = -0.05} }, { MODKEY|ControlMask, XK_h, tagmon, {.i = -1 } }, @@ -192,12 +193,15 @@ static Key keys[] = { { MODKEY, XK_x, spawn, SHCMD("slock & ( sleep 4; xset dpms force off; mpc pause ; pauseallmpv)") }, { MODKEY|ShiftMask, XK_x, spawn, SHCMD("prompt \"Shutdown computer?\" \"sudo -A shutdown -h now\"") }, { MODKEY, XK_c, togglescratch, {.ui = 1 } }, - { MODKEY|ShiftMask, XK_c, spawn, SHCMD("mpv --no-osc --no-input-default-bindings --input-conf=/dev/null --title=mpvfloat /dev/video0") }, + { MODKEY|ShiftMask, XK_c, setfloating, {0} }, + { MODKEY|ShiftMask, XK_c, spawn, SHCMD("hover center") }, { MODKEY, XK_v, spawn, SHCMD("st -e $EDITOR -c \"VimwikiIndex\"") }, + { MODKEY|ShiftMask, XK_v, setfloating, {0} }, { MODKEY|ShiftMask, XK_v, spawn, SHCMD("hover left") }, { MODKEY, XK_b, togglebar, {0} }, { MODKEY|ShiftMask, XK_b, spawn, SHCMD("bt") }, { MODKEY, XK_n, spawn, SHCMD("st -e newsboat; pkill -RTMIN+13 dwmblocks") }, + { MODKEY|ShiftMask, XK_n, setfloating, {0} }, { MODKEY|ShiftMask, XK_n, spawn, SHCMD("hover right") }, { MODKEY, XK_m, spawn, SHCMD("st -e ncmpcpp") }, { MODKEY|ShiftMask, XK_m, spawn, SHCMD("mpc toggle; notify-send \"DUNST_COMMAND_TOGGLE\"; pkill -RTMIN+10 dwmblocks") }, @@ -227,7 +231,7 @@ static Key keys[] = { { MODKEY, XK_F12, spawn, SHCMD("st -e sudo nmtui") }, /* { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, */ { MODKEY, XK_space, zoom, {0} }, - { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { MODKEY|ShiftMask, XK_space, togglefloating, {1} }, { 0, XK_Print, spawn, SHCMD("maim pic-full-$(date '+%y%m%d-%H%M-%S').png") }, { ShiftMask, XK_Print, spawn, SHCMD("maimpick") }, { MODKEY, XK_Print, spawn, SHCMD("dmenurecord") }, diff --git a/dwm.c b/dwm.c index 3169f6c..325bfea 100644 --- a/dwm.c +++ b/dwm.c @@ -204,6 +204,7 @@ static int sendevent(Client *c, Atom proto); static void sendmon(Client *c, Monitor *m); static void setclientstate(Client *c, long state); static void setfocus(Client *c); +static void setfloating(const Arg *arg); static void setfullscreen(Client *c, int fullscreen); static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); @@ -1826,6 +1827,19 @@ togglefloating(const Arg *arg) arrange(selmon); } +void +setfloating(const Arg *arg) +{ + if (!selmon->sel) + return; + if (selmon->sel->isfullscreen) /* no support for fullscreen windows */ + return; + selmon->sel->isfloating = True; + resize(selmon->sel, selmon->sel->x, selmon->sel->y, + selmon->sel->w, selmon->sel->h, 0); + arrange(selmon); +} + void togglefullscr(const Arg *arg) {