You are not logged in.
ANOKNUSA wrote:So I've been sloppily trying to get a couple things working, and my near-nonexistent C skills and knowledge have left me stumped. The first thing is this centerclock patch; I'd like the clock to be displayed on the far right of the statusbar---next to the status text---and leave the maximum width of the section at the number of characters in the clock text. I haven't quite figured out how to draw the clock text in its own section rather than replacing the status or window title text.
The second thing is to just change the window border color from dc.sel[ColBorder] to dc.norm[ColBG] in the monocle layout, to match the statusbar. This removes the visual distraction of the border, but leaves a few pixels of padding around the screen edge and below the statusbar text. If I've only got one window visible I'm in monocle mode anyway, so something like the better-borders and noborders patches seems like overkill. I've sort of figured out how this might work, but nothing reliable. Like I said, I don't really grok C.
I'm using dwm 6.0. I've been fumbling around with this for two days, so if anyone's got some pointers, or is willing to make those modifications, I'd be grateful.
I could come up with something in the next week or so, maybe next two weeks. University is starting again on monday, so I have some others things to take care of first.
Thanks, Unia. I just started up class myself (hence my late reply), so I totally understand.
Offline
This patch basically enables transparent window moving/resizing. It was taken from here. I also further modified it to accept runtime parameters for the font and six colors, so as to allow runtime modification of the color scheme. Sloppy, because I'm not so well-versed in C.
--- dwm.c 2011-12-19 09:38:30.000000000 -0500
+++ dwm.c 2014-09-09 18:27:48.490434427 -0400
@@ -103,6 +103,7 @@
unsigned long sel[ColLast];
Drawable drawable;
GC gc;
+ GC invert_gc;
struct {
int ascent;
int descent;
@@ -178,6 +179,7 @@
static Monitor *dirtomon(int dir);
static void drawbar(Monitor *m);
static void drawbars(void);
+static void drawoutline(int x, int y, int w, int h, int bw);
static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]);
static void drawtext(const char *text, unsigned long col[ColLast], Bool invert);
static void enternotify(XEvent *e);
@@ -220,7 +222,7 @@
static void setfullscreen(Client *c, Bool fullscreen);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
-static void setup(void);
+static void setup(int argdcc, char *argdcv[]);
static void showhide(Client *c);
static void sigchld(int unused);
static void spawn(const Arg *arg);
@@ -492,6 +494,7 @@
XUngrabKey(dpy, AnyKey, AnyModifier, root);
XFreePixmap(dpy, dc.drawable);
XFreeGC(dpy, dc.gc);
+ XFreeGC(dpy, dc.invert_gc);
XFreeCursor(dpy, cursor[CurNormal]);
XFreeCursor(dpy, cursor[CurResize]);
XFreeCursor(dpy, cursor[CurMove]);
@@ -774,6 +777,13 @@
}
void
+drawoutline(int x, int y, int w, int h, int bw){
+ XDrawRectangle(dpy, root, dc.invert_gc,
+ x-bw, y-bw,
+ w+2*bw-1, h+2*bw-1);
+}
+
+void
drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) {
int x;
@@ -1221,6 +1231,7 @@
void
movemouse(const Arg *arg) {
int x, y, ocx, ocy, nx, ny;
+ Bool first;
Client *c;
Monitor *m;
XEvent ev;
@@ -1228,13 +1239,14 @@
if(!(c = selmon->sel))
return;
restack(selmon);
- ocx = c->x;
- ocy = c->y;
+ nx = ocx = c->x;
+ ny = ocy = c->y;
if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, cursor[CurMove], CurrentTime) != GrabSuccess)
return;
if(!getrootptr(&x, &y))
return;
+ first = True;
do {
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
switch(ev.type) {
@@ -1244,6 +1256,10 @@
handler[ev.type](&ev);
break;
case MotionNotify:
+ if(!first){
+ drawoutline(nx, ny, c->w, c->h, c->bw); /* clear */
+ XUngrabServer(dpy);
+ }
nx = ocx + (ev.xmotion.x - x);
ny = ocy + (ev.xmotion.y - y);
if(nx >= selmon->wx && nx <= selmon->wx + selmon->ww
@@ -1260,11 +1276,20 @@
&& (abs(nx - c->x) > snap || abs(ny - c->y) > snap))
togglefloating(NULL);
}
- if(!selmon->lt[selmon->sellt]->arrange || c->isfloating)
- resize(c, nx, ny, c->w, c->h, True);
+ if(!selmon->lt[selmon->sellt]->arrange || c->isfloating){
+ if(!first) XSync(dpy, False);
+ XGrabServer(dpy);
+ drawoutline(nx, ny, c->w, c->h, c->bw);
+ first = False;
+ }
break;
}
} while(ev.type != ButtonRelease);
+ if(!first){
+ drawoutline(nx, ny, c->w, c->h, c->bw); /* clear */
+ XUngrabServer(dpy);
+ if(nx != ocx || ny != ocy) resize(c, nx, ny, c->w, c->h, True);
+ }
XUngrabPointer(dpy, CurrentTime);
if((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
sendmon(c, m);
@@ -1363,8 +1388,9 @@
void
resizemouse(const Arg *arg) {
- int ocx, ocy;
+ int ocx, ocy, ocw, och;
int nw, nh;
+ Bool first;
Client *c;
Monitor *m;
XEvent ev;
@@ -1374,10 +1400,13 @@
restack(selmon);
ocx = c->x;
ocy = c->y;
+ ocw = nw = c->w;
+ och = nh = c->h;
if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, cursor[CurResize], CurrentTime) != GrabSuccess)
return;
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
+ first = True;
do {
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
switch(ev.type) {
@@ -1387,6 +1416,10 @@
handler[ev.type](&ev);
break;
case MotionNotify:
+ if(!first){
+ drawoutline(c->x, c->y, nw, nh, c->bw); /* clear */
+ XUngrabServer(dpy);
+ }
nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
if(c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww
@@ -1396,11 +1429,20 @@
&& (abs(nw - c->w) > snap || abs(nh - c->h) > snap))
togglefloating(NULL);
}
- if(!selmon->lt[selmon->sellt]->arrange || c->isfloating)
- resize(c, c->x, c->y, nw, nh, True);
+ if(!selmon->lt[selmon->sellt]->arrange || c->isfloating){
+ if(!first) XSync(dpy, False);
+ XGrabServer(dpy);
+ drawoutline(c->x, c->y, nw, nh, c->bw);
+ first = False;
+ }
break;
}
} while(ev.type != ButtonRelease);
+ if(!first){
+ drawoutline(c->x, c->y, nw, nh, c->bw); /* clear */
+ XUngrabServer(dpy);
+ if(nw != ocw || nh != och) resize(c, c->x, c->y, nw, nh, True);
+ }
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
XUngrabPointer(dpy, CurrentTime);
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
@@ -1581,8 +1623,9 @@
}
void
-setup(void) {
+setup(int argdcc, char *argdcv[]) {
XSetWindowAttributes wa;
+ XGCValues gv;
/* clean up any zombies immediately */
sigchld(0);
@@ -1590,7 +1633,10 @@
/* init screen */
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);
- initfont(font);
+ if(argdcc == 8)
+ initfont(argdcv[1]);
+ else
+ initfont(font);
sw = DisplayWidth(dpy, screen);
sh = DisplayHeight(dpy, screen);
bh = dc.h = dc.font.height + 2;
@@ -1612,17 +1658,32 @@
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
/* init appearance */
- dc.norm[ColBorder] = getcolor(normbordercolor);
- dc.norm[ColBG] = getcolor(normbgcolor);
- dc.norm[ColFG] = getcolor(normfgcolor);
- dc.sel[ColBorder] = getcolor(selbordercolor);
- dc.sel[ColBG] = getcolor(selbgcolor);
- dc.sel[ColFG] = getcolor(selfgcolor);
+ if(argdcc == 8) {
+ dc.norm[ColBorder] = getcolor(argdcv[2]);
+ dc.norm[ColBG] = getcolor(argdcv[3]);
+ dc.norm[ColFG] = getcolor(argdcv[4]);
+ dc.sel[ColBorder] = getcolor(argdcv[5]);
+ dc.sel[ColBG] = getcolor(argdcv[6]);
+ dc.sel[ColFG] = getcolor(argdcv[7]);
+ } else {
+ dc.norm[ColBorder] = getcolor(normbordercolor);
+ dc.norm[ColBG] = getcolor(normbgcolor);
+ dc.norm[ColFG] = getcolor(normfgcolor);
+ dc.sel[ColBorder] = getcolor(selbordercolor);
+ dc.sel[ColBG] = getcolor(selbgcolor);
+ dc.sel[ColFG] = getcolor(selfgcolor);
+ }
dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen));
dc.gc = XCreateGC(dpy, root, 0, NULL);
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
if(!dc.font.set)
XSetFont(dpy, dc.gc, dc.font.xfont->fid);
+
+ gv.function = GXinvert;
+ gv.subwindow_mode = IncludeInferiors;
+ gv.line_width = 1; /* opt_bw */
+ dc.invert_gc = XCreateGC(dpy, root, GCFunction | GCSubwindowMode | GCLineWidth, &gv);
+
/* init bars */
updatebars();
updatestatus();
@@ -2130,14 +2191,14 @@
main(int argc, char *argv[]) {
if(argc == 2 && !strcmp("-v", argv[1]))
die("dwm-"VERSION", © 2006-2011 dwm engineers, see LICENSE for details\n");
- else if(argc != 1)
- die("usage: dwm [-v]\n");
+ else if(argc != 1 && argc != 8)
+ die("usage: dwm [-v]\n dwm [fn nr nb nf sr sb sf]\n");
if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
fputs("warning: no locale support\n", stderr);
if(!(dpy = XOpenDisplay(NULL)))
die("dwm: cannot open display\n");
checkotherwm();
- setup();
+ setup(argc, argv);
scan();
run();
cleanup();
Offline
Hello, Does anyone have a dwm 6.0 patch that will patch cleanly against dwm.c? I've been searching for 2 days and it's driving me crazy.
Offline
Hello, Does anyone have a dwm 6.0 patch that will patch cleanly against dwm.c?
You'll have to clarify. This doesn't make any sense.
Offline
Indeed, saying *what* patch you want that is patched against 6.0 would be a minimum requirement. But in most cases, I'd bet you could find it on Unia's github page.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
config.h
#define DEFAULT_TAG 1 << 3
#define SEL_TARGET_TAG Yes
dwm.c
--- /usr/local/src/dwm-6.0/dwm.def.c 2011-12-19 16:02:46.000000000 +0100
+++ /usr/local/src/dwm-6.0/dwm.c 2014-09-11 19:54:04.068324442 +0200
@@ -322,7 +322,17 @@
XFree(ch.res_class);
if(ch.res_name)
XFree(ch.res_name);
- c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
+
+ #ifdef DEFAULT_TAG
+ c->tags = c->tags == 0 ? DEFAULT_TAG
+ : c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
+ #else
+ c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
+ #endif
+
+ #ifdef SEL_TARGET_TAG
+ c->mon->tagset[c->mon->seltags] = c->tags;
+ #endif
}
Bool
Hello,
If you do not set DEFAULT_TAG and SEL_TARGET_TAG, this patch does not change the module, just the source program.
DEFAULT_TAG used to start all programs without rules on the same tag, not on the current tag.
SEL_TARGET_TAG switches to the target tag, when you assign rules to run a command or DEFAULT_TAG is not the current tag.
example:
I run an android-like menu with lots of icons on the tag 1, applications are on others tags. DWM becomes usable by end users.
I hope I did it the right way.
Last edited by nenesse (2014-09-11 19:08:51)
Offline
Silly question: why are there patches for version 6.1 if the latest official version is 6.0?
Offline
6.1 will be the release of the code that is now available on github: http://git.suckless.org/dwm/
@ANOKNUSA: Sorry, it's going to take longer I literally have zero free time on my hands, and it's likely to remain the same for the coming eight weeks. I'll whip something up as soon as I can, perhaps I can squeeze in a little time in a lunch break or something.
Last edited by Unia (2014-09-12 19:29:59)
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
Is it possible to set dwm to change next or previous tag on MODKEY+XK_Left or MODKEY+XK_Right?
Offline
`nextprev` or `shiftview` might be what you're looking for:
Offline
@Unia: Don't go out of your way on my account. It's not like these are essential features I need or anything; they're both basically cosmetic. Like I said, I understand your situation; I myself am on page #13 of the twenty or so pages I need to have written for university by Monday.
Offline
@Unia: Don't go out of your way on my account. It's not like these are essential features I need or anything; they're both basically cosmetic. Like I said, I understand your situation; I myself am on page #13 of the twenty or so pages I need to have written for university by Monday.
I'm making programming sessions till 1 or 2 AM to make my deadline by sunday. At the same time I'm three chapters behind with math... Busy weeks!
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
`nextprev` or `shiftview` might be what you're looking for:
Thanks! shiftview does exactly what i want.
Offline
I'm three chapters behind with math...
You have my sympathies.
Offline
Is there any other tiling layouts for dwm-git? I couldn't find bottom stack path for dwm-git w/ pertag.
Offline
The dwm version mentioned in the patch name refers more relevantly to the version of dwm against which the patch was made, than it does the version with which the patch works. Most layout patches add code rather than modifying existing code, so they'll probably work with 6.1 regardless of the version in the patch name (and there are some 6.1 patches that work fine with 6.0). Aside from the reimplemented graphics drawing code in 6.1, dwm hasn't really changed in the last couple years. Just back up your config (or stash your changes using Git) and try the patches out.
Offline
Hi,
I am actually using DWM with two monitors. Is it somehow possible to jump to active windows on the other monitor as it is possible via Mod-Tab on the very same monitor?
Cheers,
L-K
Offline
No. Each monitor uses its own independent tag set. If windows aren't in a monitor's tag set, they can't be shown on that monitor, and the window manager can't interact with them.
Offline
I already asked this on IRC but didn't receive a answer.
I'm trying DWM and I'm wondering if there's a simple way to highlight a tag when there's some activity in it. Like if Firefox opened a new tab then that tag would turn into some different colour. For example in Awesome tag turns into red in that case. I found http://jasonwryan.com/blog/2011/01/25/s … ts-in-dwm/ this but I think it only works for cli programs sending a bell. Is there some obvious way / patch I'm missing to make it work (in which case I'm sorry for the stupid question) or is that simply something not easily done in DWM?
Last edited by Buumi (2014-10-06 10:33:08)
Offline
The urgency hints are what you are looking for, however I'm not sure Firefox sets it. Perhaps you need to query for another event? I know Skype (i.e. Qt) uses its own, one that the standard urgency patch does not do. You can find the patch on how to include it here: https://github.com/Unia/dwm-patches/blo … ntion.diff
That, in combination with the patch you linked to, should give you urgency hints for Qt applications. It shouldn't be too hard to also include Firefox's hint, you just have to find out how it sets it.
If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Offline
Just a quick query about coloring the text on the dwm bar via the shell syntax. This person's apperantly managed to do it without applying any patches.
I wish to follow the same procedure (without patching) as applying the patches breaks too many things in my config.
http://lists.suckless.org/dev/1105/7925.html
I've added the struct to the config.h file.
But if I try and invoke the color via \x02 or \x03 say I simply get a font change.
Here's my shell file.
#! /bin/bash
export DISPLAY=:0
while true; do
#BATT=$( acpi -b | sed 's/.*[charging|unknown], \([0-9]*\)%.*/\1/gi' )
#STATUS=$( acpi -b | sed 's/.*: \([a-zA-Z]*\),.*/\1/gi' )
CPU=$( grep 'cpu ' /proc/stat | awk '{printf("%.0f%%"), ($2+$3+$4+$6+$7+$8)*100/($2+$3+$4+$5+$6+$7+$8)}' )
MEM=$( free | grep Mem | awk '{printf("%.0f%%"), $3/$2 * 100.0}' )
SWAPFS=$( cat /proc/swaps | grep -o [0-9]* | head -3 | tail -1 | awk '{GB=$1/=1048576; printf "%0.2fGB\n", $1}' )
ROOTFS=$( df | grep rootfs | grep -o [0-9]*% )
HOMEFS=$( df | grep '/home$' | grep -o [0-9]*% )
TMPFS=$( df | grep '/tmp' | grep -o [0-9]*% | head -n1 )
ESSID=$( /sbin/iwconfig wlan0 | grep -o \".*\" )
LINKQUALITY=$(grep 'wlan0' /proc/net/wireless | awk '{print $3}' | sed s/\\./%/)
IP=$( wget -q -O - http://ip.tupeux.com | tail)
#DOWNTOTAL=$(/sbin/ifconfig wlan0 | grep 'RX bytes' | awk '{print $3$4}')
#UPTOTAL=$(/sbin/ifconfig wlan0 | grep 'RX bytes' | awk '{print $7$8}')
DOWNTOTAL=$(grep 'wlan0' /proc/net/dev | awk '{printf("(%.1fG)"), $2/1024/1024/1024}')
UPTOTAL=$(grep 'wlan0' /proc/net/dev | awk '{printf("(%.1fG)"), $10/1024/1024/1024}')
RATE=$( awk '{if(l1){print $2-l1,$10-l2} else{l1=$2; l2=$10;}}' <(grep wlan0 /proc/net/dev) <(sleep 1; grep wlan0 /proc/net/dev))
DOWNRATE=$(echo $RATE | awk '{printf("%.0fK"), $1/1024}')
UPRATE=$(echo $RATE | awk '{printf("%.0fK"), $2/1024}')
BATT=$( acpi -b | grep -o [0-9]*% )
VOLSTATE=$( amixer sget Master | grep -o [[0-9][a-z]*] )
VOLLEVEL=$( amixer sget Master | grep -o [0-9]*% )
STRING="\u00c8 \x02 $CPU\
\u00de $MEM\
\u00c5 $SWAPFS\
/$ROOTFS\
~$HOMEFS\
/tmp $TMPFS\
\u00c0 $ESSID ($LINKQUALITY) $IP\
\u00d0 $DOWNRATE $DOWNTOTAL\
\u00d1 $UPRATE $UPTOTAL\
\u00c4 $BATT\
\u00d5 $(date +"%l:%M %a %d %b")"
if [ $VOLSTATE == '[off]' ]; then
STRING="$STRING \u00d4\u00d7"
else STRING="$STRING \u00d4 $VOLLEVEL"
fi
xsetroot -name "`echo -e $STRING`"
sleep 5
done &
Last edited by wildfowl (2015-01-14 22:56:56)
Offline
Just a quick query about coloring the text on the dwm bar via the shell syntax. This person's apperantly managed to do it without applying any patches.
I wish to follow the same procedure (without patching) as applying the patches breaks too many things in my config.
The status bar text is printed without any processing using XDrawString (or XmbDrawString). As far as i know, neither supports color changing. But your script fits to this patch:
http://dwm.suckless.org/patches/statuscolors
which allows to select from a small list of predefined colors. There are at least two other patches which allow for arbitrary color selection.
Ceterum autem censeo Systemdinem esse delendam
Offline
unia's statusbarcolors patch shifts the text whenever you change colors.
Offline
What do you think this, first spoke Castilian and my English is terrible so I apologize in advance and I'm working with git version.
Second the function incnmaster, has no control over selmon.master values, i.e., if we increase one we must subtract one to return to original and if we increased 200 we subtract those 200 to return to the original but have 2 windows. The problem is only to increase to decrease the MAX solve the problem. Then if you press 32769 times modkey + L, we have a nice error in execution.
I've thought about doing cyclical, as focusstack, and the number of stacks and number of positions are linear except for the case of one single, is n + 1 positions where n are the stacks. Therefore a mod (n + 1) we could do. But one problem arises, the tags do not have the same number of stacks. Therefore would have to change this value in view, toggleview ... or have one for each tag.
Just ask your review before putting it in the devmail suckless.
It is sufficient to increase the complexity? More solutions? Let me your opinions. Regards.
Offline
Anyone heard of patch that introduces a jump list for tags? Similar to vim's jump list where I can press <C-o> to jump backwards in a list of visited positions. Right now I have a key for switching between the current and the last visited tag, but it's a bit uncomfortable to use with too many tags.
There are two types of people in this world - those who can count to 10 by using their fingers, and those who can count to 1023.
Offline