[dev] [surf] Dependency on modifier keys

2010-02-23 Thread Sean Whitton
Hi,

I am getting very tired of Firefox taking forever to start up, eating my
ram and slowing my machine down, so, since I already use dwm, I am
considering switching to surf.  I tried modifying config.h to remove the
need to hit a modifier (control by default) before every command: it
seems to me to make more sense to just be able to scroll with j and k
without having to hold down another key.

But of course, as I quickly discovered, this doesn't work, as one then
loses the ability to type j and k into text boxes, which is pretty dire.

I don't know GDK.  Does it have the capability to tell surf when a
textbox has focus, and then a patch could detect this, and turn off
command keys until the box loses focus/escape is hit?

S

-- 
Sean Whitton / 
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/



signature.asc
Description: Digital signature


Re: [dev] [surf] Dependency on modifier keys

2010-02-23 Thread Sean Whitton
Hi,

On Tue, Feb 23, 2010 at 01:57:17PM +0100, markus schnalke wrote:
> I used surf for several weeks last year. I had the same problem, so I
> hacked a mode interface like vi has. It is just a quick hack, it is
> outdated, and I don't use it anymore, but maybe it helps.

Thanks for that.  I've cleaned up the patch to be sure it works with
0.3, and I've removed all the other things - anyone who is interested
will find it attached.

I think, though, that a better approach might be to have this mode
activated automatically when a textbox gets focus.  If one goes to a
search engine whose scripts put your cursor straight in the search box
anyway, then it's stupid to have to press i first before you can type
something in it.  I'll try to find the time to see how uzbl does it, as
has been suggested.

S

-- 
Sean Whitton / 
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/

Only in surf-0.3~: b
diff -up surf-0.3/config.def.h surf-0.3~/config.def.h
--- surf-0.3/config.def.h	2009-10-30 12:41:02.0 +
+++ surf-0.3~/config.def.h	2010-02-23 14:09:08.0 +
@@ -33,6 +34,7 @@ static Key keys[] = {
 { MODKEY,   GDK_slash,  spawn,  SETPROP("_SURF_FIND") },
 { MODKEY,   GDK_n,  find,   { .b = TRUE } },
 { MODKEY|GDK_SHIFT_MASK,GDK_n,  find,   { .b = FALSE } },
+	{ 0,GDK_i,  insert, { 0 } },
 };
 
 static Item items[] = {
diff -up surf-0.3/surf.c surf-0.3~/surf.c
--- surf-0.3/surf.c	2009-10-30 12:41:02.0 +
+++ surf-0.3~/surf.c	2010-02-23 14:04:52.0 +
@@ -65,7 +65,9 @@ static int ignorexprop = 0;
 static char winid[64];
 static char *progname;
 static gboolean lockcookie = FALSE;
+static gboolean insert_mode = FALSE;
 
+static void insert(Client *c, const Arg *arg);
 static char *buildpath(const char *path);
 static void changecookie(SoupCookieJar *jar, SoupCookie *o, SoupCookie *n, gpointer p);
 static void cleanup(void);
@@ -391,21 +393,59 @@ itemclick(GtkMenuItem *mi, Client *c) {
 			items[i].func(c, &(items[i].arg));
 }
 
+void
+insert(Client *c, const Arg *arg) {
+	insert_mode = TRUE;
+	update(clients);
+}
+
 gboolean
 keypress(GtkWidget* w, GdkEventKey *ev, Client *c) {
 	guint i;
 	gboolean processed = FALSE;
 
 	updatewinid(c);
+
+	if (ev->type   != GDK_KEY_PRESS ||
+		ev->keyval == GDK_Return   ||
+		ev->keyval == GDK_Page_Up   ||
+		ev->keyval == GDK_Page_Down ||
+		ev->keyval == GDK_Up||
+		ev->keyval == GDK_Down||
+		ev->keyval == GDK_Left||
+		ev->keyval == GDK_Right  ||
+		ev->keyval == GDK_Shift_L   ||
+		ev->keyval == GDK_Shift_R)
+		return FALSE;
+	
+	/* turn off insert mode */
+	if (insert_mode && (ev->keyval == GDK_Escape)) {
+		insert_mode = FALSE;
+		update(c);
+		return TRUE;
+	}
+	
+	if (insert_mode && ( ((ev->state & MODKEY) != MODKEY) || !MODKEY ) ) {
+		return FALSE;
+	}
+	
+	if (ev->keyval == GDK_Escape) {
+		webkit_web_view_set_highlight_text_matches(c->view, FALSE);
+		/* return TRUE; */
+	}
+
+
+
 	for(i = 0; i < LENGTH(keys); i++) {
-		if(gdk_keyval_to_lower(ev->keyval) == keys[i].keyval
-&& CLEANMASK(ev->state) == keys[i].mod
+		if(ev->keyval == keys[i].keyval
+/* && CLEANMASK(ev->state) == keys[i].mod */
 && keys[i].func) {
 			keys[i].func(c, &(keys[i].arg));
 			processed = TRUE;
 		}
 	}
-	return processed;
+	/* return processed; */
+	return TRUE;
 }
 
 void


signature.asc
Description: Digital signature


Re: [dev] [surf] Dependency on modifier keys

2010-02-23 Thread Sean Whitton
On Tue, Feb 23, 2010 at 02:19:10PM +, Sean Whitton wrote:
> Thanks for that.  I've cleaned up the patch to be sure it works with
> 0.3, and I've removed all the other things - anyone who is interested
> will find it attached.

This patch has broken my zoom and scrolling keys; now j and k just zoom,
and nothing scrolls.  Just a warning to anyone else who thinks they
might use it.

S

-- 
Sean Whitton / 
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/



signature.asc
Description: Digital signature


Re: [dev] [surf] Dependency on modifier keys

2010-02-23 Thread Sean Whitton
Hi,

On Tue, Feb 23, 2010 at 08:39:19PM +0100, markus schnalke wrote:
> This might be caused by your settings in config.h . Of course one
> needs to adjust the keymappings too.
> 
> I attach my config.h to show a possible key setup. Be aware it is for
> an outdated version of surf.

This is what I was thinking.  It seems that with this patch you can no
longer differentiate between Mod-Shift-j and j - or even Mod-j.
Certainly not in the way I was doing it.  I've moved things around to
get it to work but this may be a problem with the patch.

S

-- 
Sean Whitton / 
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/



signature.asc
Description: Digital signature


Re: [dev] [surf] Dependency on modifier keys

2010-02-24 Thread Sean Whitton
On Wed, Feb 24, 2010 at 12:38:46AM +0100, markus schnalke wrote:
> That is likely true. I did not use modification keys, except of shift
> which is handled (by gtk?) internally.
> 
> Actually, this hack had the purpose *to get rid of* modification keys.
> ;-)

This is true, of course.  There's another issue though: the patch seems
to stop stuff in ~/.surf/script.js from binding keys: my hinting script
has totally stopped working.  That's quite annoying.

S

-- 
Sean Whitton / 
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/



signature.asc
Description: Digital signature


Re: [dev] [surf] Dependency on modifier keys

2010-02-24 Thread Sean Whitton
On Wed, Feb 24, 2010 at 12:25:13PM +0100, julien steinhauser wrote:
> If you change ctrl-f to f in your hinting script, does it work better?

This is what I did, but unfortunately it makes no difference.

S

-- 
Sean Whitton / 
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/



signature.asc
Description: Digital signature


[dev] [surf] Who stole the cookies from the cookie jar?

2010-03-11 Thread Sean Whitton
Hi,

From when I started using surf, I found it a bit annoying how cookies
don't seem to 'stick' - logging into things like, say, Google Calendar
doesn't persist for more than a few hours when you tick "remember me",
which is something that a lot of services have.  Is this a problem with
how surf stores cookies, or something that most of the websites that
allow login have that clashes with surf and relies on quirks of the more
popular browsers?

It's got worse this week, in that surf has basically stopped accepting
cookies at all, and I can't login to any websites as I either get logged
out immediately, or I get "your browser's cookie support is turned off".
I've managed to fix this by simply deleting my cookies file and starting
again, but this shouldn't happen so is probably a bug.

Not sure how helpful this e-mail is in fixing bugs, but if I am
misinterpreting features as bugs, I would very much appreciate an
explication :-)

S

-- 
Sean Whitton / 
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/



signature.asc
Description: Digital signature


Re: [dev] [surf] Who stole the cookies from the cookie jar?

2010-03-11 Thread Sean Whitton
Hi,

On Thu, Mar 11, 2010 at 02:52:15PM +0300, anonymous wrote:
> Use stable version. Now most of cookies-related code is removed and it
> will be rewritten for multi-process design. The problem with existing
> cookies code is that it stores cookies when you exit and reloads when you
> start new surf process. So if you run 2 surf processes, login in first,
> close it and then close second, the second will store empty cookies.txt
> again and rewrite cookies stored by first process. It is common situation,
> you can see something like it when bash stores its history.
> 
> 

What do you mean by "stable version"?  I've been using 0.3, the .tar.gz
download, and am not pulling from Mercurial.

S

-- 
Sean Whitton / 
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/



signature.asc
Description: Digital signature


[dev] [dwm] [patch] Hide window border if window is only one visible, and bar is hidden

2010-03-26 Thread Sean Whitton
Hi,

Attached is a patch that causes dwm to remove a window's border when the
bar is hidden, and the window is the only one visible - that is, when it
is the only client on the tag, or the tag is in monocle mode.  It's
dependent on pertag, which I use, but it could easily be hacked to
remove this dependency.

Issues:

- If you move a window to another monitor, it won't get resized to fill
  the extra borderpx*2 columns and rows until you switch to that
  monitor.
- If you have more than one monitor, it'll be a lot harder to tell which
  is focussed if borders have been removed on both.  You'll have to look
  for solid/hollow terminal cursors etc.  This is just personal
  preference, but is worth pointing out.

I don't speak C so this patch is likely very code inefficient and ugly,
and it may well have other bugs.  Do let me know if you find the time to
clean it up.

S

-- 
Sean Whitton / 
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/

diff -up dwm-5.7.2/dwm.c dwm-5.7.2-modified/dwm.c
--- dwm-5.7.2/dwm.c	2009-09-27 20:20:23.0 +0100
+++ dwm-5.7.2-modified/dwm.c	2010-03-26 19:58:14.0 +
@@ -394,10 +394,33 @@ arrange(Monitor *m) {
 
 void
 arrangemon(Monitor *m) {
+	Client *c;
+	XWindowChanges wc;
+	unsigned int n;
+
 	strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
 	if(m->lt[m->sellt]->arrange)
 		m->lt[m->sellt]->arrange(m);
 	restack(m);
+
+	/* rest of function is to hide a window's border when it's the only one on screen */
+	n = 0;
+	for(c = m->clients; c; c = c->next)
+		if(ISVISIBLE(c))
+			n++;
+	if (n != 0 && m->sel) { /* we don't care if there are no windows, or nothing is selected */
+		c = m->sel;
+		if (!m->showbar && (m->lt[m->sellt]->arrange == monocle || n == 1)) {
+			wc.border_width = 0;
+			XConfigureWindow(dpy, c->win, CWBorderWidth, &wc);
+			XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w + 2 * c->bw, c->h + 2 * c->bw);
+		}
+		else {
+			wc.border_width = c->bw;
+			XConfigureWindow(dpy, c->win, CWBorderWidth, &wc);
+			XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
+		}
+	}
 }
 
 void
@@ -812,6 +835,10 @@ expose(XEvent *e) {
 
 void
 focus(Client *c) {
+	Client *mc;
+	XWindowChanges wc;
+	unsigned int n;
+	
 	if(!c || !ISVISIBLE(c))
 		for(c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
 	if(selmon->sel)
@@ -826,6 +853,23 @@ focus(Client *c) {
 		grabbuttons(c, True);
 		XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
 		XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
+
+		/* this bit is to hide a window's border when it's the only one on the screen */
+		n = 0;
+		for(mc = selmon->clients; mc; mc = mc->next)
+			if(ISVISIBLE(mc))
+n++;
+		if (!selmon->showbar && (selmon->lt[selmon->sellt]->arrange == monocle || n == 1)) {
+			wc.border_width = 0;
+			XConfigureWindow(dpy, c->win, CWBorderWidth, &wc);
+			XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w + 2 * c->bw, c->h + 2 * c->bw);
+		}
+		else {
+			wc.border_width = c->bw;
+			XConfigureWindow(dpy, c->win, CWBorderWidth, &wc);
+			XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
+		}
+		
 	}
 	else
 		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);


signature.asc
Description: Digital signature


Re: [dev] [dmenu] A clickable dmenu is a dream?

2010-03-27 Thread Sean Whitton
Hi.

On Sat, Mar 27, 2010 at 04:21:24PM -0600, Jeff Shipley wrote:
> What might be useful would be a dmenu that copies in the X selection
> buffer when it's middle-clicked. (Sorry if this has already been
> discussed). This wouldn't be very useful for commands, but could be
> very useful for arguments. You could type in surf, paste in the url,
> and then open surf with that url.

You can achieve this with M-p in dmenu-4.0.

S

-- 
Sean Whitton / 
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/



signature.asc
Description: Digital signature


Re: [dev] Re: [dmenu] subwindow patch

2010-03-31 Thread Sean Whitton
Hi,

On Tue, Mar 30, 2010 at 11:54:15PM +, Connor Lane Smith wrote:
> On 30 March 2010 23:35, Connor Lane Smith  wrote:
> > I thought it would be nice for certain programs (like surf) to spawn
> > dmenu within its own borders. It turns out this is actually very
> > simple. The attached patch uses the argument '-w'. Hopefully it could
> > be of use to someone else.
> 
> Actually here's an even simpler way (4 lines). This takes the argument
> '-e xid', where xid is the window it will nest into.
> 
> cls



This is nice.  What would be even nicer is if dmenu stole mouse/kb
control only for the window in question, so you could switch to another
window/tag and leave it open while looking up part of a url or
something.

S

-- 
Sean Whitton / 
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/



signature.asc
Description: Digital signature


Re: [dev] [surf] toggle_images_plugins_scripts patch for tip

2010-04-17 Thread Sean Whitton
Hi,

On Thu, Mar 25, 2010 at 03:47:18PM +0100, pancake wrote:
> Is there any possibility to change the default canvas color in
> webkit? I use my own
> css which set the background color to black, but while the page is
> loading or when
> there's no loaded page it is white and it burns my eyes. This would
> be another
> feature I would be happy to use :)

I've figured out how to make a slight improvement to this - add this to 
the setup function:

webkit_web_view_set_transparent(c->view, TRUE);

This gets me a nice black background (which isn't the colour of my root 
window) when pages are loading and when surf launches.  No idea which 
window/widget/bleh the colour is actually coming from.

S

-- 
Sean Whitton / 
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/



signature.asc
Description: Digital signature


Re: [dev] [surf] toggle_images_plugins_scripts patch for tip

2010-04-24 Thread Sean Whitton
Hi,

On Sun, Apr 18, 2010 at 11:16:41AM +0200, pancake wrote:
> Thanks!
> 
> This fixes my visual problem too :)
> 
> I thougth that black came from the gtk theme...but no idea where it comes 
> from...
> 
> We can add this option in config.h?

I've attached a patch to add such a config option.  Perhaps someone 
would like to add it to the surf website or something.

I've tried changing my GTK theme but it doesn't seem to change colour.

S

PS Sorry for the spam pancake - kept sending it from my e-mail address that 
isn't subscribed to the list.

-- 
Sean Whitton / 
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/

diff -up surf/config.def.h modsurf/config.def.h
--- surf/config.def.h	2010-04-24 20:40:29.0 +0100
+++ modsurf/config.def.h	2010-04-24 20:38:46.0 +0100
@@ -7,6 +7,7 @@ static char *scriptfile = ".surf/scr
 static char *cookiefile = ".surf/cookies.txt";
 static char *dldir  = ".surf/dl/";
 static time_t sessiontime   = 3600;
+static gboolean blackbg = TRUE;
 
 #define SETPROP(p)   { .v = (char *[]){ "/bin/sh", "-c", \
 	"prop=\"`xprop -id $1 $0 | cut -d '\"' -f 2 | dmenu`\" &&" \
diff -up surf/surf.c modsurf/surf.c
--- surf/surf.c	2010-04-24 20:40:29.0 +0100
+++ modsurf/surf.c	2010-04-24 20:39:55.0 +0100
@@ -531,6 +531,8 @@ newclient(void) {
 	g_signal_connect(G_OBJECT(c->view), "notify::load-status", G_CALLBACK(loadstatuschange), c);
 	g_signal_connect(G_OBJECT(c->view), "notify::progress", G_CALLBACK(progresschange), c);
 
+	webkit_web_view_set_transparent(c->view, blackbg);
+
 	/* Indicator */
 	c->indicator = gtk_drawing_area_new();
 	gtk_widget_set_size_request(c->indicator, 0, 2);


Re: [dev] [surf] fix for running script.js

2010-05-10 Thread Sean Whitton
Hi,

On Sun, May 09, 2010 at 07:27:25PM +0200, Troels Henriksen wrote:
> script.js will not be run unless the site you are visiting (or has
> visited in the past?) uses Javascript.  This is bad.  The attached patch
> makes surf run script.js in every newly created web view.
> 

Nice job - I see that this has been integrated into hg.

Scripts still don't work if you have page JavaScript turned off, though.  
Is there any way around this?

S

-- 
Sean Whitton / 
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/




Re: [dev] surf patch: bind keystrokes to snippets of Javascript

2010-05-11 Thread Sean Whitton
Hi,

On Tue, May 11, 2010 at 02:13:01PM +0100, Sean Whitton wrote:
> On Tue, May 11, 2010 at 11:10:04AM +0200, Troels Henriksen wrote:
> > The attached patch lets you bind keys to small lines of Javascript to
> > run.
> > 
> > The intent is that the usual ~/.surf/script.js defines various methods,
> > which are then run by the bindings.  This is much cleaner than having
> > script.js create its own event listeners for keybindings going outside
> > surf's own system.
> 
> This works brilliantly - thank you.  If anyone was wondering how to add 
> keybindings to your config file, this is what I have in config.h for 
> hinting (that works):
> 
> { 0,GDK_f,  eval,   { .v = (char *[]){ 
> "hintMode()", NULL } } },
> { 0,GDK_F,  eval,   { .v = (char *[]){ 
> "hintMode(true)", NULL } } },
> { 0,GDK_Escape, eval,   { .v = (char *[]){ 
> "removeHints()", NULL } } },
> 
> ... and just comment out the line document.addEventListener all the way 
> down to the end of the hinting script in script.js.

Don't comment any JavaScript out; this breaks the binding of the numbers 
to actually use the hints.  Sorry.

S

-- 
Sean Whitton / 
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/



signature.asc
Description: Digital signature


Re: [dev] surf patch: bind keystrokes to snippets of Javascript

2010-05-11 Thread Sean Whitton
Hi,

On Tue, May 11, 2010 at 11:10:04AM +0200, Troels Henriksen wrote:
> The attached patch lets you bind keys to small lines of Javascript to
> run.
> 
> The intent is that the usual ~/.surf/script.js defines various methods,
> which are then run by the bindings.  This is much cleaner than having
> script.js create its own event listeners for keybindings going outside
> surf's own system.

This works brilliantly - thank you.  If anyone was wondering how to add 
keybindings to your config file, this is what I have in config.h for 
hinting (that works):

{ 0,GDK_f,  eval,   { .v = (char *[]){ 
"hintMode()", NULL } } },
{ 0,GDK_F,  eval,   { .v = (char *[]){ 
"hintMode(true)", NULL } } },
{ 0,GDK_Escape, eval,   { .v = (char *[]){ 
"removeHints()", NULL } } },

... and just comment out the line document.addEventListener all the way 
down to the end of the hinting script in script.js.

S

-- 
Sean Whitton / 
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/



signature.asc
Description: Digital signature


Re: [dev] surf patch: bind keystrokes to snippets of Javascript

2010-05-18 Thread Sean Whitton
Hi,

On Mon, May 17, 2010 at 07:10:21PM +0200, Troels Henriksen wrote:
> Here is a further improved link hinting script, which positions the
> hints better when the element is broken across lines, and prevents
> recursive invocations of hintMode().  (Sorry for not attaching it, but
> my nearby sucky mailserver won't permit me to send .js-files).

This script doesn't seem to bind numbers at all for me, so I can turn 
hinting on and off, but can't select any hints.  Any ideas why this 
might be?

S

-- 
Sean Whitton / 
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/



signature.asc
Description: Digital signature


Re: [dev] Tiling windowmanager workflow (Was: [dvtm] Fibonacci layout patch)

2010-06-10 Thread Sean Whitton
Dunno how interesting this will be...

I've recently made some changes to my workflow since I've switched a 
number of hefty GUI applications for CLI ones, the advantage being that 
they tile a lot better and so don't need dedicated tags.  But I'm still 
far from comfortable.  A key problem is that one of my newest apps, 
wyrd, dies if it ever goes below 80 columns wide, which is a pain if you 
accidentally switch it out of master in tiled or bstack on my 
1280px-wide screen.

So:
Tags 1, 2, 7, 8 & 9 are tiled layout tags for normal usage.
3 is called www and is tabbed + surf in bstack layout, so I can open 
  download terminals or wahtever without losing the page width 
  (attachabove also in play)
4 is com and is e-mail, calendar and a terminal for running 
  taskwarrior.org's excellent task list application.  So, organisation.
5 is net and is cortex for reddit (when it works, which is not so 
  often), two Irssis for identi.ca/twitter and IRC, my RSS reader and 
  also ncmpcc - it's my "fun" perma tag in the sense that 4 is my less 
  fun one
6 is ful and is where fullscreen stuff is set to go, and floating apps - 
  gimp, wine and my PDF reader.  At the moment when I hit :w in vim when 
  editing LaTeX, it gets compiled and refreshed in a PDF viewer in this 
  tag.  This is good, and the tag starts up in monocle mode, but if I 
  have more than one LaTeX doc open at once it starts to get less 
  useful.

I want to make more of use of having more than one tag selected at once, 
and having windows on more than one tag etc., but I don't really have 
useful bindings for it.  I am thinking I might get some shortcuts to 
pull in my fullscreen tag into others, when for example I am working 
with LaTeX, which I do a lot.

S

-- 
Sean Whitton / 
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/



signature.asc
Description: Digital signature


Re: [dev] Re: [dmenu] getting dmenu to use multiselect with tab completion

2010-07-29 Thread Sean Whitton
Hi,

On Thu, Jul 29, 2010 at 12:26:54PM +0200, Catalin David wrote:
> Hello!
> 
> On Sun, Jul 18, 2010 at 9:49 PM, Sean Neilan  wrote:
> > I'm sorry, I found what I was looking for a couple minutes after I sent this
> > email.
> > http://lists.suckless.org/dwm/0901/7355.html
> > This patch will let you use tab completion to select a file. Wow.
> 
> Unfortunately, i was not able to patch the latest version of dmenu
> with it... Can you please tell me what version of dmenu you used?
> 
> Thanks,
> 
> Catalin
> 

The attached patch is what I did to get it to work on a reasonably 
recent version of dmenu.  I suggest you apply the changes in this 
manually to get it to work.  It's pretty neat :-)

S

-- 
Sean Whitton / 
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/

diff --git a/dmenu/dmenu.1 b/dmenu/dmenu.1
index 2279835..4e669a2 100644
--- a/dmenu/dmenu.1
+++ b/dmenu/dmenu.1
@@ -14,6 +14,7 @@ dmenu \- dynamic menu
 .RB [ \-sf " "]
 .RB [ \-xs ]
 .RB [ \-v ]
+.RB [ \-c ]
 .SH DESCRIPTION
 .SS Overview
 dmenu is a generic menu for X, originally designed for
@@ -55,6 +56,9 @@ xmms-like pattern matching.
 .TP
 .B \-v
 prints version information to standard output, then exits.
+.TP
+.B \-c
+enables filename completion for text after a space (useful with the dmenu_run 
script).
 .SH USAGE
 dmenu reads a list of newline-separated items from standard input and creates a
 menu.  When the user selects an item or enters any text and presses Return, 
his/her
@@ -76,7 +80,9 @@ Select the first item of the previous/next 'page' of items.
 Select the first/last item.
 .TP
 .B Tab (Control\-i)
-Copy the selected item to the input field.
+Copy the selected item to the input field.  Also, if the -c option is given 
and there
+is a space in the input, will try to expand and complete text after the space 
into a
+valid filename. (First Tab - Longest Completion, Multiple Tabs - cycle through 
files)
 .TP
 .B Return (Control\-j)
 Confirm selection and quit (print the selected item to standard output). 
Returns
diff --git a/dmenu/dmenu.c b/dmenu/dmenu.c
index b30b92a..8d1f33c 100644
--- a/dmenu/dmenu.c
+++ b/dmenu/dmenu.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -61,6 +62,7 @@ static Bool grabkeyboard(void);
 static void initfont(const char *fontstr);
 static void kpress(XKeyEvent * e);
 static void match(char *pattern);
+static void matchfile(char *filestart, Bool cycling);
 static void readstdin(void);
 static void run(void);
 static void setup(Bool topbar);
@@ -81,7 +83,7 @@ static int cursor = 0;
 static int screen;
 static unsigned int mw, mh;
 static unsigned int numlockmask = 0;
-static Bool running = True;
+static Bool running = True, filecomplete = False;
 static Bool xmms = False;
 static Display *dpy;
 static DC dc;
@@ -384,6 +386,7 @@ initfont(const char *fontstr) {
 
 void
 kpress(XKeyEvent * e) {
+   static KeySym lastkey=0;
char buf[32];
int i, num;
unsigned int len;
@@ -498,7 +501,11 @@ kpress(XKeyEvent * e) {
if(num && !iscntrl((int) buf[0])) {
buf[num] = 0;
memmove(text + cursor + num, text + cursor, sizeof text 
- cursor);
-   strncpy(text + cursor, buf, sizeof text - cursor);
+   //strncpy(text + cursor, buf, sizeof text - cursor);
+   if (len > 0)
+   strncat(text, buf, sizeof text);
+   else
+   strncpy(text, buf, sizeof text);
cursor+=num;
match(text);
}
@@ -581,6 +588,11 @@ kpress(XKeyEvent * e) {
return;
break;
case XK_Tab:
+   if( filecomplete && strchr(text, ' ')!=NULL ) {
+   matchfile( strchr(text, ' ')+1, lastkey==XK_Tab );
+   cursor = strlen(text);
+   break;
+   }
if(!sel)
return;
strncpy(text, sel->text, sizeof text);
@@ -591,6 +603,7 @@ kpress(XKeyEvent * e) {
len = strlen(text);
cursor = MIN(cursor, len);
cursor = MAX(cursor, 0);
+   lastkey=ksym;
drawmenu();
 }
 
@@ -669,6 +682,44 @@ match(char *pattern) {
 }
 
 void
+matchfile(char *filestart, Bool cycling ) {
+   static int try=0, p=0;
+   wordexp_t exp;
+   int i, j, k;
+
+   if( !cycling ) { 
+p = strlen(filestart);
+try=0;
+   }
+   filestart[ p+1 ] = 0;
+   filestart[ p ] = '*';
+
+   wordexp(filestart, &exp, 0);
+   if( exp.we_wordc > 0 ) {
+for(j=0,i=0; exp.we_wordv[try][i]!=0; i++,j++) {
+ if( exp.we_wordv[t

Re: [dev] [dwm] spawn a floating window

2010-08-08 Thread Sean Whitton
Hi,

On Sat, Aug 07, 2010 at 10:01:47PM +0200, Pascal Wittmann wrote:
> I tried to write a function that spawns a window/client and makes it
> floating, but with no success. I looked a the spawn function, but I
> have no idea how to get/alter the isfloating value of the new client.
> Simply taking the selected one won't  work.
> 
> Example of use: You are reading a something in fullscreen and want to
> try some code snippet or do some computations, I find it useful to
> have a terminal (or someting else) floating around.
> 
> I could gain the same effect by switching the the layout to floating
> and open the application then, but I wonder if its possible (without
> big effort) to write such a function?

You could set a rule to match terminals based on title and mark them as 
floating, then use urxvt -T floatingwin or something to launch the term.  
I use the title matching trick a lot.

S

-- 
Sean Whitton / 
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/



pgpmQKVlmcbiA.pgp
Description: PGP signature


Re: [dev] Re: dwm puzzle [fixed; with blame]

2010-09-14 Thread Sean Whitton
Hi,

On Sun, Sep 12, 2010 at 10:52:12AM -0400, Peter John Hartman wrote:
> Ok, I haven't done this yet, but a little update.  It turns out that this
> patch /didn't/ fix the problem; or, at least, it partially did.  On
> occasion, firefox at least and mplayer in full screen mode will not
> behave.  It is something intermittent as far as I can tell.  I should
> not that it still remains true that this never happened in 5.8.2.
> (It never happened that I recall; and I've been running 5.8.2 since
> last night when it happened again in hg tip and so far it has not
> yet happened.)

I'm actually having this problem with 5.8.2; Firefox is intermittently 
ignoring the fact that it isn't supposed to float and that it's supposed 
to go to the 6th workspace - so it seems to be ignoring the rules set 
for it from time to time.  So I wouldn't confine your search to 
changesets after 5.8.2.

S

-- 
Sean Whitton / 
OpenPGP KeyID: 0x3B6D411B
http://seanwhitton.com/



pgpfvYxP1QwCP.pgp
Description: PGP signature