Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-07-29 Thread Anselm R Garbe
Hi Steven,

yes the release is on its way, apart from other releases.

Kind regards,
Anselm

2008/7/29 Steven Blatchford <[EMAIL PROTECTED]>:
> Hi Anselm,
> I was using slock v0.8[1] and received the error below.  The code in hg
> tip fixed the problem.  Anselm can you release v0.9 with these fixes?
>
> Thanks,
> -steve
>
>
> X Error of failed request:  BadMatch (invalid parameter attributes)
> Major opcode of failed request:  136 (DPMS)
> Minor opcode of failed request:  6 (DPMSForceLevel)
> Serial number of failed request:  27
> Current serial number in output stream:  28
>
> [1] http://code.suckless.org/dl/tools/slock-0.8.tar.gz
>
>
> On 00:46 Thu 10 Apr, Anselm R. Garbe wrote:
>>On Wed, Apr 09, 2008 at 11:12:23AM +0200, Anselm R. Garbe wrote:
>>> On Tue, Apr 08, 2008 at 02:37:10PM +0200, Peter Hartlich wrote:
>>> > >> Also, with the new DPMS code from changeset 31, slock crashes here
>>> > >> (X.org server 1.4.0.90, DPMS disabled in xorg.conf):
>>> > >>
>>> > >> | X Error of failed request:  BadMatch (invalid parameter attributes)
>>> > >> |   Major opcode of failed request:  136 (DPMS)
>>> > >> |   Minor opcode of failed request:  6 (DPMSForceLevel)
>>> > >> |   Serial number of failed request:  27
>>> > >> |   Current serial number in output stream:  28
>>> >
>>> > > Right, should be fixed in hg tip now. Please confirm this due to
>>> > > a recheck.
>>> >
>>> > Still crashes at DPMSForceLevel. It seems that DPMSCapable returns True
>>> > even with DPMS disabled...
>>>
>>> Well, then I need to add an error handler.
>>
>>I pushed a changeset into hg tip of slock which attempts to fix
>>the DPMS issue without using a separate error handler, hence
>>please recheck, If the crash still occurs, there is no other
>>choice than wether not supporting DPMS or implementing an error
>>handler which ignores BadMatch errors due to DPMSForceLevel
>>calls.
>>
>>Kind regards,
>>--
>> Anselm R. Garbe >< http://www.suckless.org/ >< GPG key: 0D73F361



Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-07-28 Thread Steven Blatchford
Hi Anselm,
I was using slock v0.8[1] and received the error below.  The code in hg
tip fixed the problem.  Anselm can you release v0.9 with these fixes?

Thanks,
-steve


X Error of failed request:  BadMatch (invalid parameter attributes)
Major opcode of failed request:  136 (DPMS)
Minor opcode of failed request:  6 (DPMSForceLevel)
Serial number of failed request:  27
Current serial number in output stream:  28

[1] http://code.suckless.org/dl/tools/slock-0.8.tar.gz


On 00:46 Thu 10 Apr, Anselm R. Garbe wrote:
>On Wed, Apr 09, 2008 at 11:12:23AM +0200, Anselm R. Garbe wrote:
>> On Tue, Apr 08, 2008 at 02:37:10PM +0200, Peter Hartlich wrote:
>> > >> Also, with the new DPMS code from changeset 31, slock crashes here
>> > >> (X.org server 1.4.0.90, DPMS disabled in xorg.conf):
>> > >> 
>> > >> | X Error of failed request:  BadMatch (invalid parameter attributes)
>> > >> |   Major opcode of failed request:  136 (DPMS)
>> > >> |   Minor opcode of failed request:  6 (DPMSForceLevel)
>> > >> |   Serial number of failed request:  27
>> > >> |   Current serial number in output stream:  28
>> >  
>> > > Right, should be fixed in hg tip now. Please confirm this due to
>> > > a recheck.
>> > 
>> > Still crashes at DPMSForceLevel. It seems that DPMSCapable returns True
>> > even with DPMS disabled...
>> 
>> Well, then I need to add an error handler.
>
>I pushed a changeset into hg tip of slock which attempts to fix
>the DPMS issue without using a separate error handler, hence
>please recheck, If the crash still occurs, there is no other
>choice than wether not supporting DPMS or implementing an error
>handler which ignores BadMatch errors due to DPMSForceLevel
>calls.
>
>Kind regards,
>-- 
> Anselm R. Garbe >< http://www.suckless.org/ >< GPG key: 0D73F361
>
>



Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-10 Thread Jukka Salmi
Peter Hartlich --> dwm (2008-04-10 19:07:34 +0200):
> Hi Jukka,
> 
> > BTW, $exe should also be quoted (see attached patch).
> 
> But with unquoted $exe you can e.g. enter: firefox suckless.org

True. Hmm, changing dmenu to output a properly quoted shell string and
then using `eval exec $exe' is probably too much effort for supporting
command names with whitespace characters...


Regards, Jukka

-- 
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~



Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-10 Thread Peter Hartlich
Hi Jukka,

> BTW, $exe should also be quoted (see attached patch).

But with unquoted $exe you can e.g. enter: firefox suckless.org

Regards,
Peter



Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-10 Thread Jukka Salmi
Anselm R. Garbe --> dwm (2008-04-08 10:57:20 +0200):
> Hi,
> 
> On Mon, Apr 07, 2008 at 10:51:15PM +0200, Peter Hartlich wrote:
> > dmenu_run.patch:
> > - replace $* with "$@" so dmenu_run -p "foo bar" works
> 
> I applied this patch with Jukka's remark.

Thanks.

BTW, $exe should also be quoted (see attached patch).


Cheers, Jukka

-- 
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~
diff -r 787ec648ffef dmenu_run
--- a/dmenu_run Wed Apr 09 23:32:46 2008 +0100
+++ b/dmenu_run Thu Apr 10 17:31:51 2008 +0200
@@ -1,2 +1,2 @@
 #!/bin/sh
-exe=`dmenu_path | dmenu ${1+"$@"}` && exec $exe
+exe=`dmenu_path | dmenu ${1+"$@"}` && exec "$exe"


Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-10 Thread Antoni Grzymala
Enno Gottox Boland dixit (2008-04-10, 11:27):

> l33tness?! - l33tness sucks.
> 
> I think sort | uniq is more unixy and therefor better :)

Yeah, I was making fun of l33tness in case you didn't notice :)

-- 
[a]


signature.asc
Description: Digital signature


Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-10 Thread Enno "Gottox" Boland
l33tness?! - l33tness sucks.

I think sort | uniq is more unixy and therefor better :)

2008/4/10 Antoni Grzymala <[EMAIL PROTECTED]>:
> Szabolcs Nagy dixit (2008-04-10, 11:02):
>
>
>  > actually 'sort | uniq' is not (much) slower
>  > (at least i couldn't measure any difference on my linux setup)
>
>  Yeah, but it's got a negative l33tness factor and uses up four more
>  bytes in writing not mentioning the evil forking :).
>
>  --
>  [a]
>
> -BEGIN PGP SIGNATURE-
>  Version: GnuPG v2.0.7 (GNU/Linux)
>
>  iD8DBQFH/dw7L69KEesxVYMRAuYbAJ4/xpYKTuKDN7MR4l57BLs2ei9ozgCcDDz2
>  XGSPpjd+paOwuW2aA2yO2w4=
>  =bOfm
>  -END PGP SIGNATURE-
>
>



-- 
http://www.gnuffy.org - Real Community Distro
http://www.gnuffy.org/index.php/GnuEm - Gnuffy on Ipaq (Codename Peggy)



Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-10 Thread Antoni Grzymala
Szabolcs Nagy dixit (2008-04-10, 11:02):

> actually 'sort | uniq' is not (much) slower
> (at least i couldn't measure any difference on my linux setup)

Yeah, but it's got a negative l33tness factor and uses up four more
bytes in writing not mentioning the evil forking :).

-- 
[a]


signature.asc
Description: Digital signature


Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-10 Thread Szabolcs Nagy
On 4/9/08, Anselm R. Garbe <[EMAIL PROTECTED]> wrote:
> > What is the problem with `sort | uniq'.
> > Okay, it may be a bit slower, but beside that ...?
>
> There is no problem apart this. So if sort -u works with wmii as
> well, I see no reason to use | uniq.

actually 'sort | uniq' is not (much) slower
(at least i couldn't measure any difference on my linux setup)



Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-09 Thread Peter Hartlich
Hi,

> I pushed a changeset into hg tip of slock which attempts to fix
> the DPMS issue without using a separate error handler, hence
> please recheck, If the crash still occurs, there is no other
> choice than wether not supporting DPMS or implementing an error
> handler which ignores BadMatch errors due to DPMSForceLevel
> calls.

Kind of weird: DPMSForceLevel now neither crashes nor switches off
the monitor, instead it displays the root window with a large X logo
superimposed.

Anyway, enabling DPMS without restoring its disabled status later
seems a bit harsh, if it worked. How about adding a DPMS configuration
variable and a note to the README? (Something like the attached patch.)
This would also be nice for those who have DPMS enabled, but prefer
it to be used based on timeout and not immediately when locking the
terminal.

Regards,
Peter
diff -dpruN slock~/config.h slock/config.h
--- slock~/config.h 1970-01-01 01:00:00.0 +0100
+++ slock/config.h  2008-04-10 06:41:24.0 +0200
@@ -0,0 +1 @@
+#define DPMS   False
diff -dpruN slock~/slock.c slock/slock.c
--- slock~/slock.c  2008-04-10 06:52:22.0 +0200
+++ slock/slock.c   2008-04-10 05:24:24.0 +0200
@@ -22,6 +22,8 @@
 #include 
 #endif
 
+#include "config.h"
+
 void
 eprint(const char *errstr, ...) {
va_list ap;
@@ -125,10 +127,8 @@ main(int argc, char **argv) {
 
/* main event loop */
while(running && !XNextEvent(dpy, &ev)) {
-   if(len == 0 && DPMSCapable(dpy)) {
-   DPMSEnable(dpy);
+   if(DPMS && len == 0)
DPMSForceLevel(dpy, DPMSModeOff);
-   }
if(ev.type == KeyPress) {
buf[0] = 0;
num = XLookupString(&ev.xkey, buf, sizeof buf, &ksym, 
0);


Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-09 Thread Anselm R. Garbe
On Wed, Apr 09, 2008 at 11:12:23AM +0200, Anselm R. Garbe wrote:
> On Tue, Apr 08, 2008 at 02:37:10PM +0200, Peter Hartlich wrote:
> > >> Also, with the new DPMS code from changeset 31, slock crashes here
> > >> (X.org server 1.4.0.90, DPMS disabled in xorg.conf):
> > >> 
> > >> | X Error of failed request:  BadMatch (invalid parameter attributes)
> > >> |   Major opcode of failed request:  136 (DPMS)
> > >> |   Minor opcode of failed request:  6 (DPMSForceLevel)
> > >> |   Serial number of failed request:  27
> > >> |   Current serial number in output stream:  28
> >  
> > > Right, should be fixed in hg tip now. Please confirm this due to
> > > a recheck.
> > 
> > Still crashes at DPMSForceLevel. It seems that DPMSCapable returns True
> > even with DPMS disabled...
> 
> Well, then I need to add an error handler.

I pushed a changeset into hg tip of slock which attempts to fix
the DPMS issue without using a separate error handler, hence
please recheck, If the crash still occurs, there is no other
choice than wether not supporting DPMS or implementing an error
handler which ignores BadMatch errors due to DPMSForceLevel
calls.

Kind regards,
-- 
 Anselm R. Garbe >< http://www.suckless.org/ >< GPG key: 0D73F361



Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-09 Thread Anselm R. Garbe
Sorry for odd reasons the applied patches weren't present in the
dmenu hg tip, this is fixed now.

On Tue, Apr 08, 2008 at 10:57:20AM +0200, Anselm R. Garbe wrote:
> On Mon, Apr 07, 2008 at 10:51:15PM +0200, Peter Hartlich wrote:
> > dmenu_run.patch:
> > - replace $* with "$@" so dmenu_run -p "foo bar" works
> 
> I applied this patch with Jukka's remark.
> 
> > dmenu_path.patch:
> > - no need for ${file##*/} string replacement
> > - sort -u instead of sort | uniq
> > - quote CACHE variable (HOME may contain an IFS character)
> > - error checking with &&
> 
> Applied.
> 
> > slock.patch:
> > - use numpad code from dmenu
> 
> Applied.

-- 
 Anselm R. Garbe >< http://www.suckless.org/ >< GPG key: 0D73F361



Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-09 Thread Anselm R. Garbe
On Wed, Apr 09, 2008 at 11:49:33AM +0200, markus schnalke wrote:
> Anselm R. Garbe <[EMAIL PROTECTED]> wrote:
> > Though,
> > I'm not totally sure if the sort -u breaks anything with wmii.
> > This needs to be tested first.
> 
> What is the problem with `sort | uniq'.
> Okay, it may be a bit slower, but beside that ...?

There is no problem apart this. So if sort -u works with wmii as
well, I see no reason to use | uniq.

Kind regards,
-- 
 Anselm R. Garbe >< http://www.suckless.org/ >< GPG key: 0D73F361



Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-09 Thread markus schnalke
Anselm R. Garbe <[EMAIL PROTECTED]> wrote:
> Though,
> I'm not totally sure if the sort -u breaks anything with wmii.
> This needs to be tested first.

What is the problem with `sort | uniq'.
Okay, it may be a bit slower, but beside that ...?

If it is more portable than `sort -u', so why don't use it?


meillo



Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-09 Thread Anselm R. Garbe
On Tue, Apr 08, 2008 at 09:31:03PM +0200, Matthias-Christian Ott wrote:
> Maybe one could a rc script as a Plan 9 like alternative, if a lot of
> users request Plan 9 tools support.

Well, p9p is no objective anymore for the vanilla dmenu, because
dmenu_path is a sh-script anyways, so it is expected to prefer
the sh-related userland first, even if in use with wmii. Though,
I'm not totally sure if the sort -u breaks anything with wmii.
This needs to be tested first.

Kind regards,
-- 
 Anselm R. Garbe >< http://www.suckless.org/ >< GPG key: 0D73F361



Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-09 Thread Anselm R. Garbe
On Tue, Apr 08, 2008 at 02:37:10PM +0200, Peter Hartlich wrote:
> >> Also, with the new DPMS code from changeset 31, slock crashes here
> >> (X.org server 1.4.0.90, DPMS disabled in xorg.conf):
> >> 
> >> | X Error of failed request:  BadMatch (invalid parameter attributes)
> >> |   Major opcode of failed request:  136 (DPMS)
> >> |   Minor opcode of failed request:  6 (DPMSForceLevel)
> >> |   Serial number of failed request:  27
> >> |   Current serial number in output stream:  28
>  
> > Right, should be fixed in hg tip now. Please confirm this due to
> > a recheck.
> 
> Still crashes at DPMSForceLevel. It seems that DPMSCapable returns True
> even with DPMS disabled...

Well, then I need to add an error handler.

Kind regards,
-- 
 Anselm R. Garbe >< http://www.suckless.org/ >< GPG key: 0D73F361



Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-08 Thread Matthias-Christian Ott
"Sander van Dijk" <[EMAIL PROTECTED]> wrote:

> On Tue, Apr 8, 2008 at 6:40 PM, Matthias-Christian Ott <[EMAIL PROTECTED]> 
> wrote:
> >  It's POSIX conform [1], so I don't see the whole point of the
> >  discussion.
>
> POSIX was created to make it easier to write portable apps. When one,
> knowingly, writes a non-portable app, and then says "hey, but it's
> POSIX compliant", one is missing the point. POSIX is a means to an
> end, not an end in itself. Basically, the point of the discussion is
> the same as the point of POSIX itself: portability.

But as far as I know dwm/dmenu was written to run on POSIX compliant
operating systems. Even X11 was mainly written for POSIX compatible
operating systems. So if you port dwm/dmenu to Plan 9 or something
similar, it makes really sense to change the programme, but under the
current circumstances it is just meaningless and not constructive to
make such a quarrel about it. Just keep it simple and assume that the
system is POSIX compliant.
Additionally the Plan 9 tools require (as far as I remember) an underlying
POSIX layer.

Maybe one could a rc script as a Plan 9 like alternative, if a lot of
users request Plan 9 tools support.

> Greetings, Sander.

Regards
Matthias-Christian



Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-08 Thread Sander van Dijk
On Tue, Apr 8, 2008 at 6:40 PM, Matthias-Christian Ott <[EMAIL PROTECTED]> 
wrote:
>  It's POSIX conform [1], so I don't see the whole point of the
>  discussion.

POSIX was created to make it easier to write portable apps. When one,
knowingly, writes a non-portable app, and then says "hey, but it's
POSIX compliant", one is missing the point. POSIX is a means to an
end, not an end in itself. Basically, the point of the discussion is
the same as the point of POSIX itself: portability.

Greetings, Sander.



Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-08 Thread yy
2008/4/8, Matthias-Christian Ott <[EMAIL PROTECTED]>:
> It's POSIX conform [1], so I don't see the whole point of the
>  discussion.
>
>  Regards
>  Matthias-Christian
>
>  [1] http://www.opengroup.org/onlinepubs/009695399/utilities/sort.html
>
>

Well, plan9 tools usually are simpler than POSIX ones. But I don't
think people using plan9 tools will have any problem to change a
simple script. OTOH uniq is also POSIX compliant.


-- 


- yiyus || JGL .



Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-08 Thread Matthias-Christian Ott
"Anselm R. Garbe" <[EMAIL PROTECTED]> wrote:

> On Tue, Apr 08, 2008 at 08:29:02AM +0200, Jukka Salmi wrote:
> > Peter Hartlich --> dwm (2008-04-08 00:22:13 +0200):
> > > Whoops, sorry then. I had checked SuS, heirloom toolchest, the autoconf
> > > portability manual and DJB's portability notes and none of them mentioned
> > > a missing -u option.
> > 
> > http://www.suckless.org/pipermail/dwm/2007-February/002128.html
>
> I doubt that is a valid assumption still, so I'm fine with the
> sort -u.

It's POSIX conform [1], so I don't see the whole point of the
discussion.

Regards
Matthias-Christian

[1] http://www.opengroup.org/onlinepubs/009695399/utilities/sort.html



Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-08 Thread Peter Hartlich
Hi Anselm,

>> Also, with the new DPMS code from changeset 31, slock crashes here
>> (X.org server 1.4.0.90, DPMS disabled in xorg.conf):
>> 
>> | X Error of failed request:  BadMatch (invalid parameter attributes)
>> |   Major opcode of failed request:  136 (DPMS)
>> |   Minor opcode of failed request:  6 (DPMSForceLevel)
>> |   Serial number of failed request:  27
>> |   Current serial number in output stream:  28
 
> Right, should be fixed in hg tip now. Please confirm this due to
> a recheck.

Still crashes at DPMSForceLevel. It seems that DPMSCapable returns True
even with DPMS disabled...

Regards,
Peter



Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-08 Thread Anselm R. Garbe
Hi,

On Mon, Apr 07, 2008 at 10:51:15PM +0200, Peter Hartlich wrote:
> dmenu_run.patch:
>   - replace $* with "$@" so dmenu_run -p "foo bar" works

I applied this patch with Jukka's remark.

> dmenu_path.patch:
>   - no need for ${file##*/} string replacement
>   - sort -u instead of sort | uniq
>   - quote CACHE variable (HOME may contain an IFS character)
>   - error checking with &&

Applied.

> slock.patch:
>   - use numpad code from dmenu

Applied.

> Also, with the new DPMS code from changeset 31, slock crashes here
> (X.org server 1.4.0.90, DPMS disabled in xorg.conf):
> 
> | X Error of failed request:  BadMatch (invalid parameter attributes)
> |   Major opcode of failed request:  136 (DPMS)
> |   Minor opcode of failed request:  6 (DPMSForceLevel)
> |   Serial number of failed request:  27
> |   Current serial number in output stream:  28

Right, should be fixed in hg tip now. Please confirm this due to
a recheck.

Many thanks!

Kind regards,
-- 
 Anselm R. Garbe >< http://www.suckless.org/ >< GPG key: 0D73F361



Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-08 Thread Anselm R. Garbe
On Tue, Apr 08, 2008 at 08:29:02AM +0200, Jukka Salmi wrote:
> Peter Hartlich --> dwm (2008-04-08 00:22:13 +0200):
> > Whoops, sorry then. I had checked SuS, heirloom toolchest, the autoconf
> > portability manual and DJB's portability notes and none of them mentioned
> > a missing -u option.
> 
> http://www.suckless.org/pipermail/dwm/2007-February/002128.html

I doubt that is a valid assumption still, so I'm fine with the
sort -u.

Kind regards,
-- 
 Anselm R. Garbe >< http://www.suckless.org/ >< GPG key: 0D73F361



Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-07 Thread Jukka Salmi
Hello,

Peter Hartlich --> dwm (2008-04-08 00:22:13 +0200):
[...]
> >>  uptodate() {
> >> -  test ! -f $CACHE && return 1
> >> +  test -f "$CACHE" &&
> >>for dir in $PATH
> >>do
> >> -  test $dir -nt $CACHE && return 1
> >> +  test ! $dir -nt "$CACHE" || return 1
> >>done
> >> -  return 0
> >>  }
>  
> > Why? This is equivalent...
> 
> Besides the quoting, one and a half lines less. :)

;-) (I missed the quoting; that's fine of course.)


> > Not all sort(1)s have a -u option.
> 
> Whoops, sorry then. I had checked SuS, heirloom toolchest, the autoconf
> portability manual and DJB's portability notes and none of them mentioned
> a missing -u option.

http://www.suckless.org/pipermail/dwm/2007-February/002128.html


Regards, Jukka

-- 
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~



Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-07 Thread Peter Hartlich
Hi Jukka,

> I'd prefer
> 
>   exe=`dmenu_path | dmenu ${1+"$@"}` && exec $exe

Agreed.

>>  uptodate() {
>> -test ! -f $CACHE && return 1
>> +test -f "$CACHE" &&
>>  for dir in $PATH
>>  do
>> -test $dir -nt $CACHE && return 1
>> +test ! $dir -nt "$CACHE" || return 1
>>  done
>> -return 0
>>  }
 
> Why? This is equivalent...

Besides the quoting, one and a half lines less. :)

> Not all sort(1)s have a -u option.

Whoops, sorry then. I had checked SuS, heirloom toolchest, the autoconf
portability manual and DJB's portability notes and none of them mentioned
a missing -u option.

Regards,
Peter



Re: [dwm] dmenu, slock patches; slock DPMS crash

2008-04-07 Thread Jukka Salmi
Hello,

Peter Hartlich --> dwm (2008-04-07 22:51:15 +0200):
[...]
> diff -r 612d48273009 dmenu_run
> --- a/dmenu_run   Thu Apr 03 21:56:19 2008 +0100
> +++ b/dmenu_run   Mon Apr 07 22:17:29 2008 +0200
> @@ -1,2 +1,2 @@
>  #!/bin/sh
> -exe=`dmenu_path | dmenu $*` && exec $exe
> +exe=`dmenu_path | dmenu "$@"` && exec $exe

Makes sense. I'd prefer

exe=`dmenu_path | dmenu ${1+"$@"}` && exec $exe

though to make sure dmenu is not passed an empty argument in case
dmenu_run is called without arguments.


> diff -r 612d48273009 dmenu_path
> --- a/dmenu_path  Thu Apr 03 21:56:19 2008 +0100
> +++ b/dmenu_path  Mon Apr 07 22:17:24 2008 +0200
> @@ -3,24 +3,24 @@
>  IFS=:
>  
>  uptodate() {
> - test ! -f $CACHE && return 1
> + test -f "$CACHE" &&
>   for dir in $PATH
>   do
> - test $dir -nt $CACHE && return 1
> + test ! $dir -nt "$CACHE" || return 1
>   done
> - return 0
>  }

Why? This is equivalent...


>  if ! uptodate
>  then
>   for dir in $PATH
>   do
> - for file in "$dir"/*
> + cd "$dir" &&
> + for file in *
>   do
> - test -x "$file" && echo "${file##*/}"
> + test -x "$file" && echo "$file"
>   done

Hmm, for few directories and lots of files this is indeed slightly
faster.


> - done | sort | uniq > $CACHE.$$
> - mv $CACHE.$$ $CACHE
> + done | sort -u > "$CACHE".$$ &&
> + mv "$CACHE".$$ "$CACHE"
>  
> -cat $CACHE
> +cat "$CACHE"

Not all sort(1)s have a -u option. However, the '&&' is a good idea,
as is the quoting.


Cheers, Jukka

-- 
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~



[dwm] dmenu, slock patches; slock DPMS crash

2008-04-07 Thread Peter Hartlich
Hi,

Three patches are attached:

dmenu_run.patch:
- replace $* with "$@" so dmenu_run -p "foo bar" works

dmenu_path.patch:
- no need for ${file##*/} string replacement
- sort -u instead of sort | uniq
- quote CACHE variable (HOME may contain an IFS character)
- error checking with &&

slock.patch:
- use numpad code from dmenu

Also, with the new DPMS code from changeset 31, slock crashes here
(X.org server 1.4.0.90, DPMS disabled in xorg.conf):

| X Error of failed request:  BadMatch (invalid parameter attributes)
|   Major opcode of failed request:  136 (DPMS)
|   Minor opcode of failed request:  6 (DPMSForceLevel)
|   Serial number of failed request:  27
|   Current serial number in output stream:  28

Regards,
Peter
diff -r 612d48273009 dmenu_run
--- a/dmenu_run Thu Apr 03 21:56:19 2008 +0100
+++ b/dmenu_run Mon Apr 07 22:17:29 2008 +0200
@@ -1,2 +1,2 @@
 #!/bin/sh
-exe=`dmenu_path | dmenu $*` && exec $exe
+exe=`dmenu_path | dmenu "$@"` && exec $exe
diff -r 612d48273009 dmenu_path
--- a/dmenu_pathThu Apr 03 21:56:19 2008 +0100
+++ b/dmenu_pathMon Apr 07 22:17:24 2008 +0200
@@ -3,24 +3,24 @@
 IFS=:
 
 uptodate() {
-   test ! -f $CACHE && return 1
+   test -f "$CACHE" &&
for dir in $PATH
do
-   test $dir -nt $CACHE && return 1
+   test ! $dir -nt "$CACHE" || return 1
done
-   return 0
 }
 
 if ! uptodate
 then
for dir in $PATH
do
-   for file in "$dir"/*
+   cd "$dir" &&
+   for file in *
do
-   test -x "$file" && echo "${file##*/}"
+   test -x "$file" && echo "$file"
done
-   done | sort | uniq > $CACHE.$$
-   mv $CACHE.$$ $CACHE
+   done | sort -u > "$CACHE".$$ &&
+   mv "$CACHE".$$ "$CACHE"
 fi
 
-cat $CACHE
+cat "$CACHE"
diff -r 8a784031d90a slock.c
--- a/slock.c   Thu Mar 13 16:59:01 2008 +
+++ b/slock.c   Mon Apr 07 22:14:29 2008 +0200
@@ -131,6 +131,11 @@
if(ev.type == KeyPress) {
buf[0] = 0;
num = XLookupString(&ev.xkey, buf, sizeof buf, &ksym, 
0);
+   if(IsKeypadKey(ksym)) 
+   if(ksym == XK_KP_Enter)
+   ksym = XK_Return;
+   else if(ksym >= XK_KP_0 && ksym <= XK_KP_9)
+   ksym = (ksym - XK_KP_0) + XK_0;
if(IsFunctionKey(ksym) || IsKeypadKey(ksym)
|| IsMiscFunctionKey(ksym) || 
IsPFKey(ksym)
|| IsPrivateKeypadKey(ksym))