[hackers] [surf] Simplify SETPROP macro || Quentin Rameau

From: <git_AT_suckless.org>
Date: Mon, 8 May 2017 14:08:23 +0200 (CEST)

commit 654d527f87e59c6c9f507402878bed62398c4e61
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Thu May 4 16:49:17 2017 +0200
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Mon May 8 11:30:20 2017 +0200

    Simplify SETPROP macro
    
    Get rid of xargs by using a subshell instead.
    Use two replacement commands in sed because back-references in BRE are
    too differently implemented in different libc.
    Rename p, q, to reflect what they're used for.
    Reorder sh positional arguments.
    Set $0 to a command name and shift other positional parameters to
    clarify the "sh -c" command.

diff --git a/config.def.h b/config.def.h
index 5fb79de..a8a4a7b 100644
--- a/config.def.h
+++ b/config.def.h
_AT_@ -50,13 +50,13 @@ static int winsize[] = { 800, 600 };
 static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
                                     WEBKIT_FIND_OPTIONS_WRAP_AROUND;
 
-#define SETPROP(p, q) { \
+/* SETPROP(readprop, setprop)*/
+#define SETPROP(r, s) { \
         .v = (const char *[]){ "/bin/sh", "-c", \
- "prop=\"`xprop -id $2 $0 " \
- "| sed \"s/^$0(STRING) = \\(\\\\\"\\?\\)\\(.*\\)\\1$/\\2/\" " \
- "| xargs -0 printf %b | dmenu`\" &&" \
- "xprop -id $2 -f $1 8s -set $1 \"$prop\"", \
- p, q, winid, NULL \
+ "prop=\"$(printf '%b' \"$(xprop -id $1 $2 " \
+ "| sed \"s/^$2(STRING) = //;s/^\\\"\\(.*\\)\\\"$/\\1/\")\" " \
+ "| dmenu)\" && xprop -id $1 -f $3 8s -set $3 \"$prop\"", \
+ "surf-setprop", winid, r, s, NULL \
         } \
 }
 
Received on Mon May 08 2017 - 14:08:23 CEST

This archive was generated by hypermail 2.3.0 : Mon May 08 2017 - 14:12:28 CEST