Weechat scratchpad #1
6
config.h
6
config.h
@ -54,7 +54,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 };
|
||||||
const char *spcmd3[] = {"st", "-n", "matrix", "-e", "weechat", NULL };
|
const char *spcmd3[] = {"st", "-n", "matrix", "-A", "0.1", "-e", "weechat", NULL };
|
||||||
|
|
||||||
static Sp scratchpads[] = {
|
static Sp scratchpads[] = {
|
||||||
/* name cmd */
|
/* name cmd */
|
||||||
@ -148,9 +148,9 @@ static Key keys[] = {
|
|||||||
/* { MODKEY|ShiftMask, XK_q, spawn, SHCMD("") }, */
|
/* { MODKEY|ShiftMask, XK_q, spawn, SHCMD("") }, */
|
||||||
{ MODKEY, XK_w, spawn, SHCMD("$BROWSER") },
|
{ MODKEY, XK_w, spawn, SHCMD("$BROWSER") },
|
||||||
{ MODKEY|ShiftMask, XK_w, spawn, SHCMD("chromium") }, /*using ungoogled-chromium as backup browser*/
|
{ MODKEY|ShiftMask, XK_w, spawn, SHCMD("chromium") }, /*using ungoogled-chromium as backup browser*/
|
||||||
{ MODKEY|ShiftMask|ControlMask, XK_w, togglewarp, {0} },
|
{ MODKEY|ShiftMask|ControlMask, XK_w, togglewarp, {0} },
|
||||||
{ MODKEY, XK_e, spawn, SHCMD("st -e neomutt -e 'set sidebar_visible = no'; pkill -RTMIN+13 dwmblocks") },
|
{ MODKEY, XK_e, spawn, SHCMD("st -e neomutt -e 'set sidebar_visible = no'; pkill -RTMIN+13 dwmblocks") },
|
||||||
{ MODKEY|ShiftMask, XK_e, togglescratch, {.ui = 2 } },
|
{ MODKEY|ShiftMask, XK_e, togglescratch, {.ui = 2 } },
|
||||||
|
|
||||||
//{ MODKEY|ShiftMask, XK_e, spawn, SHCMD("element-desktop") },
|
//{ MODKEY|ShiftMask, XK_e, spawn, SHCMD("element-desktop") },
|
||||||
{ MODKEY, XK_r, spawn, SHCMD("st -e $FILE") },
|
{ MODKEY, XK_r, spawn, SHCMD("st -e $FILE") },
|
||||||
|
75
dwm.c
75
dwm.c
@ -58,6 +58,7 @@
|
|||||||
#define SPTAG(i) ((1 << LENGTH(tags)) << (i))
|
#define SPTAG(i) ((1 << LENGTH(tags)) << (i))
|
||||||
#define SPTAGMASK (((1 << LENGTH(scratchpads))-1) << LENGTH(tags))
|
#define SPTAGMASK (((1 << LENGTH(scratchpads))-1) << LENGTH(tags))
|
||||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||||
|
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||||
|
|
||||||
/* enums */
|
/* enums */
|
||||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||||
@ -174,6 +175,7 @@ static void fibonacci(Monitor *mon, int s);
|
|||||||
static void focus(Client *c);
|
static void focus(Client *c);
|
||||||
static void focusin(XEvent *e);
|
static void focusin(XEvent *e);
|
||||||
static void focusmon(const Arg *arg);
|
static void focusmon(const Arg *arg);
|
||||||
|
static void focusclientmon(Monitor *msearch);
|
||||||
static void focusstack(const Arg *arg);
|
static void focusstack(const Arg *arg);
|
||||||
static Atom getatomprop(Client *c, Atom prop);
|
static Atom getatomprop(Client *c, Atom prop);
|
||||||
static int getrootptr(int *x, int *y);
|
static int getrootptr(int *x, int *y);
|
||||||
@ -203,6 +205,7 @@ static void run(void);
|
|||||||
static void scan(void);
|
static void scan(void);
|
||||||
static int sendevent(Client *c, Atom proto);
|
static int sendevent(Client *c, Atom proto);
|
||||||
static void sendmon(Client *c, Monitor *m);
|
static void sendmon(Client *c, Monitor *m);
|
||||||
|
static void sendmontags(Client *c, Monitor *m, unsigned int tags);
|
||||||
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 setfloating(const Arg *arg);
|
||||||
@ -789,8 +792,7 @@ drawbar(Monitor *m)
|
|||||||
for (i = 0; i < LENGTH(tags); i++) {
|
for (i = 0; i < LENGTH(tags); i++) {
|
||||||
/* do not draw vacant tags */
|
/* do not draw vacant tags */
|
||||||
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
w = TEXTW(tags[i]);
|
w = TEXTW(tags[i]);
|
||||||
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
|
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
|
||||||
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
|
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
|
||||||
@ -913,6 +915,20 @@ focusmon(const Arg *arg)
|
|||||||
warp(selmon->sel);
|
warp(selmon->sel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
focusclientmon(Monitor *msearch)
|
||||||
|
{
|
||||||
|
Monitor *m;
|
||||||
|
|
||||||
|
if (!mons->next)
|
||||||
|
return;
|
||||||
|
if ((m = msearch) == selmon)
|
||||||
|
return;
|
||||||
|
unfocus(selmon->sel, 0);
|
||||||
|
selmon = m;
|
||||||
|
focus(NULL);
|
||||||
|
warp(selmon->sel);
|
||||||
|
}
|
||||||
void
|
void
|
||||||
focusstack(const Arg *arg)
|
focusstack(const Arg *arg)
|
||||||
{
|
{
|
||||||
@ -1496,13 +1512,29 @@ scan(void)
|
|||||||
void
|
void
|
||||||
sendmon(Client *c, Monitor *m)
|
sendmon(Client *c, Monitor *m)
|
||||||
{
|
{
|
||||||
|
sendmontags(c, m, m->tagset[m->seltags]);
|
||||||
|
//if (c->mon == m)
|
||||||
|
// return;
|
||||||
|
//unfocus(c, 1);
|
||||||
|
//detach(c);
|
||||||
|
//detachstack(c);
|
||||||
|
//c->mon = m;
|
||||||
|
//c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
|
||||||
|
//attach(c);
|
||||||
|
//attachstack(c);
|
||||||
|
//focus(NULL);
|
||||||
|
//arrange(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sendmontags(Client *c, Monitor *m, unsigned int tags){
|
||||||
if (c->mon == m)
|
if (c->mon == m)
|
||||||
return;
|
return;
|
||||||
unfocus(c, 1);
|
unfocus(c, 1);
|
||||||
detach(c);
|
detach(c);
|
||||||
detachstack(c);
|
detachstack(c);
|
||||||
c->mon = m;
|
c->mon = m;
|
||||||
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
|
c->tags = tags;
|
||||||
attach(c);
|
attach(c);
|
||||||
attachstack(c);
|
attachstack(c);
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
@ -1883,23 +1915,38 @@ void
|
|||||||
togglescratch(const Arg *arg)
|
togglescratch(const Arg *arg)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
|
Monitor *m;
|
||||||
unsigned int found = 0;
|
unsigned int found = 0;
|
||||||
unsigned int scratchtag = SPTAG(arg->ui);
|
unsigned int scratchtag = SPTAG(arg->ui);
|
||||||
Arg sparg = {.v = scratchpads[arg->ui].cmd};
|
Arg sparg = {.v = scratchpads[arg->ui].cmd};
|
||||||
|
|
||||||
for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next);
|
for (m = mons; m && !found; m = m->next)
|
||||||
if (found) {
|
for (c = m->clients; c && !(found = c->tags & scratchtag); c = c->next);
|
||||||
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
|
|
||||||
if (newtagset) {
|
if (found){
|
||||||
selmon->tagset[selmon->seltags] = newtagset;
|
if (c->mon == selmon) {
|
||||||
focus(NULL);
|
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
|
||||||
arrange(selmon);
|
if (newtagset) {
|
||||||
|
selmon->tagset[selmon->seltags] = newtagset;
|
||||||
|
focus(NULL);
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
if (ISVISIBLE(c)) {
|
||||||
|
focus(c);
|
||||||
|
restack(selmon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ISVISIBLE(c)) {
|
else{
|
||||||
focus(c);
|
unsigned int newtagset = c->mon->tagset[c->mon->seltags] ^ scratchtag;
|
||||||
restack(selmon);
|
if (newtagset)
|
||||||
|
c->mon->tagset[c->mon->seltags] = newtagset;
|
||||||
|
//add scratchtag to monitor where client is sent to
|
||||||
|
selmon->tagset[selmon->seltags] |= scratchtag;
|
||||||
|
sendmontags(c, selmon, scratchtag);
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
selmon->tagset[selmon->seltags] |= scratchtag;
|
selmon->tagset[selmon->seltags] |= scratchtag;
|
||||||
spawn(&sparg);
|
spawn(&sparg);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user