added setfloating function

This commit is contained in:
Alexander Bocken 2020-08-29 17:42:22 +02:00
parent a34914ccb4
commit b943c6cb48
2 changed files with 23 additions and 5 deletions

View File

@ -37,7 +37,7 @@ static char selfgcolor[] = nord6;
static char selbgcolor[] = nord10; static char selbgcolor[] = nord10;
static char selbordercolor[] = nord4; static char selbordercolor[] = nord4;
static const char col_urgborder[] = "#ff0000"; static const char col_urgborder[] = nord11;
static const char *colors[][3] = { static const char *colors[][3] = {
/* fg bg border */ /* fg bg border */
@ -52,6 +52,7 @@ typedef struct {
} Sp; } Sp;
const char *spcmd1[] = {"st", "-n", "scratchpadterm", "-t", "Scratchpad", "-g", "120x34", NULL }; const char *spcmd1[] = {"st", "-n", "scratchpadterm", "-t", "Scratchpad", "-g", "120x34", NULL };
const char *spcmd2[] = {"st", "-n", "scratchcalc", "-t", "Calculator", "-g", "120x34", "-e", "dropdowncalc", NULL }; const char *spcmd2[] = {"st", "-n", "scratchcalc", "-t", "Calculator", "-g", "120x34", "-e", "dropdowncalc", NULL };
static Sp scratchpads[] = { static Sp scratchpads[] = {
/* name cmd */ /* name cmd */
{"scratchpad", spcmd1}, {"scratchpad", spcmd1},
@ -140,7 +141,7 @@ static Key keys[] = {
{ MODKEY, XK_w, spawn, SHCMD("$BROWSER") }, { MODKEY, XK_w, spawn, SHCMD("$BROWSER") },
{ MODKEY|ShiftMask, XK_w, spawn, SHCMD("brave") }, { 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, 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, XK_r, spawn, SHCMD("st -e $FILE") },
{ MODKEY|ShiftMask, XK_r, spawn, SHCMD("st -e lf") }, { MODKEY|ShiftMask, XK_r, spawn, SHCMD("st -e lf") },
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
@ -170,7 +171,7 @@ static Key keys[] = {
{ MODKEY, XK_f, togglefullscr, {0} }, { MODKEY, XK_f, togglefullscr, {0} },
{ MODKEY|ShiftMask, XK_f, setlayout, {.v = &layouts[8]} }, { MODKEY|ShiftMask, XK_f, setlayout, {.v = &layouts[8]} },
{ MODKEY, XK_g, shiftview, { .i = -1 } }, { 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, XK_h, focusmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_h, setmfact, {.f = -0.05} }, { MODKEY|ShiftMask, XK_h, setmfact, {.f = -0.05} },
{ MODKEY|ControlMask, XK_h, tagmon, {.i = -1 } }, { 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, 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|ShiftMask, XK_x, spawn, SHCMD("prompt \"Shutdown computer?\" \"sudo -A shutdown -h now\"") },
{ MODKEY, XK_c, togglescratch, {.ui = 1 } }, { 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, XK_v, spawn, SHCMD("st -e $EDITOR -c \"VimwikiIndex\"") },
{ MODKEY|ShiftMask, XK_v, setfloating, {0} },
{ MODKEY|ShiftMask, XK_v, spawn, SHCMD("hover left") }, { MODKEY|ShiftMask, XK_v, spawn, SHCMD("hover left") },
{ MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_b, togglebar, {0} },
{ MODKEY|ShiftMask, XK_b, spawn, SHCMD("bt") }, { MODKEY|ShiftMask, XK_b, spawn, SHCMD("bt") },
{ MODKEY, XK_n, spawn, SHCMD("st -e newsboat; pkill -RTMIN+13 dwmblocks") }, { 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|ShiftMask, XK_n, spawn, SHCMD("hover right") },
{ MODKEY, XK_m, spawn, SHCMD("st -e ncmpcpp") }, { 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") }, { 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_F12, spawn, SHCMD("st -e sudo nmtui") },
/* { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, */ /* { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, */
{ MODKEY, XK_space, zoom, {0} }, { 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") }, { 0, XK_Print, spawn, SHCMD("maim pic-full-$(date '+%y%m%d-%H%M-%S').png") },
{ ShiftMask, XK_Print, spawn, SHCMD("maimpick") }, { ShiftMask, XK_Print, spawn, SHCMD("maimpick") },
{ MODKEY, XK_Print, spawn, SHCMD("dmenurecord") }, { MODKEY, XK_Print, spawn, SHCMD("dmenurecord") },

14
dwm.c
View File

@ -204,6 +204,7 @@ static int sendevent(Client *c, Atom proto);
static void sendmon(Client *c, Monitor *m); static void sendmon(Client *c, Monitor *m);
static void setclientstate(Client *c, long state); static void setclientstate(Client *c, long state);
static void setfocus(Client *c); static void setfocus(Client *c);
static void setfloating(const Arg *arg);
static void setfullscreen(Client *c, int fullscreen); static void setfullscreen(Client *c, int fullscreen);
static void setlayout(const Arg *arg); static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg); static void setmfact(const Arg *arg);
@ -1826,6 +1827,19 @@ togglefloating(const Arg *arg)
arrange(selmon); 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 void
togglefullscr(const Arg *arg) togglefullscr(const Arg *arg)
{ {