rpms/i3lock/devel i3lock-1.0-189ee55bc074c14d61a900d428401580614a5618.patch, NONE, 1.1 i3lock-1.0-1cddfc4a98efa54203f48de30b9937aaf66a95b4.patch, NONE, 1.1 i3lock-1.0-206036a852e3d9c598e3fe82d84fd2ac54bbaa55.patch, NONE, 1.1 i3lock-1.0-25fe0bf00d7519db5c514cdb320870fa52265e2e.patch, NONE, 1.1 i3lock-1.0-2e5bee59d5444f84126df845bfb8e02cd252576f.patch, NONE, 1.1 i3lock-1.0-69a987db550678b640d0f59246e6ac2cd7ce2657.patch, NONE, 1.1 i3lock-1.0-9c4dee2e8633d4ff2c9787fc3f1b6591338c41f5.patch, NONE, 1.1 i3lock-1.0-c1a91badbed68ab63e1109bf74902e2f88bae008.patch, NONE, 1.1 i3lock-1.0-ef1d47ce5b663ccc75f8387021bcc4a9e75b2a5d.patch, NONE, 1.1 i3lock.spec, 1.2, 1.3

Simon Wesp cassmodiah at fedoraproject.org
Fri Feb 5 19:59:17 UTC 2010


Author: cassmodiah

Update of /cvs/pkgs/rpms/i3lock/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv12862

Modified Files:
	i3lock.spec 
Added Files:
	i3lock-1.0-189ee55bc074c14d61a900d428401580614a5618.patch 
	i3lock-1.0-1cddfc4a98efa54203f48de30b9937aaf66a95b4.patch 
	i3lock-1.0-206036a852e3d9c598e3fe82d84fd2ac54bbaa55.patch 
	i3lock-1.0-25fe0bf00d7519db5c514cdb320870fa52265e2e.patch 
	i3lock-1.0-2e5bee59d5444f84126df845bfb8e02cd252576f.patch 
	i3lock-1.0-69a987db550678b640d0f59246e6ac2cd7ce2657.patch 
	i3lock-1.0-9c4dee2e8633d4ff2c9787fc3f1b6591338c41f5.patch 
	i3lock-1.0-c1a91badbed68ab63e1109bf74902e2f88bae008.patch 
	i3lock-1.0-ef1d47ce5b663ccc75f8387021bcc4a9e75b2a5d.patch 
Log Message:
* Sat Feb 05 2010 Simon Wesp <cassmodiah at fedoraproject.org> - 1.0-3
- Some bugfixes (sync with upstream)
- Add patch http://code.stapelberg.de/git/i3lock/commit/?id=189ee55bc074c14d61a900d428401580614a5618
- Add patch http://code.stapelberg.de/git/i3lock/commit/?id=69a987db550678b640d0f59246e6ac2cd7ce2657
- Add patch http://code.stapelberg.de/git/i3lock/commit/?id=c1a91badbed68ab63e1109bf74902e2f88bae008
- Add patch http://code.stapelberg.de/git/i3lock/commit/?id=9c4dee2e8633d4ff2c9787fc3f1b6591338c41f5
- Add patch http://code.stapelberg.de/git/i3lock/commit/?id=206036a852e3d9c598e3fe82d84fd2ac54bbaa55
- Add patch http://code.stapelberg.de/git/i3lock/commit/?id=1cddfc4a98efa54203f48de30b9937aaf66a95b4
- Add patch http://code.stapelberg.de/git/i3lock/commit/?id=ef1d47ce5b663ccc75f8387021bcc4a9e75b2a5d
- Add patch http://code.stapelberg.de/git/i3lock/commit/?id=25fe0bf00d7519db5c514cdb320870fa52265e2e
- Add patch http://code.stapelberg.de/git/i3lock/commit/?id=2e5bee59d5444f84126df845bfb8e02cd252576f


i3lock-1.0-189ee55bc074c14d61a900d428401580614a5618.patch:
 config.mk |    2 +-
 i3lock.c  |   41 ++++++++++++++++++++++++++++++++++++++---
 2 files changed, 39 insertions(+), 4 deletions(-)

--- NEW FILE i3lock-1.0-189ee55bc074c14d61a900d428401580614a5618.patch ---
>From 189ee55bc074c14d61a900d428401580614a5618 Mon Sep 17 00:00:00 2001
From: Jan-Erik Rediger <badboy at archlinux.us>
Date: Fri, 19 Jun 2009 22:52:55 +0100
Subject: i3lock now can use xpm images as background

---
diff --git i3lock-1.0.orig/config.mk i3lock-1.0/config.mk
index 8b2b613..664c254 100644
--- i3lock-1.0.orig/config.mk
+++ i3lock-1.0/config.mk
@@ -13,7 +13,7 @@ MANDIR = $(DESTDIR)$(PREFIX)/share/man
 
 # includes and libs
 INCS = -I. -I/usr/include -I${X11INC}
-LIBS = -L${X11LIB} -lX11 -lpam -lXext
+LIBS = -L${X11LIB} -lX11 -lpam -lXext -lXpm
 
 # flags
 CPPFLAGS = -DVERSION=\"${VERSION}\"
diff --git i3lock-1.0.orig/i3lock.c i3lock-1.0/i3lock.c
index 2c95929..5b495b5 100644
--- i3lock-1.0.orig/i3lock.c
+++ i3lock-1.0/i3lock.c
@@ -26,6 +26,7 @@
 #include <X11/keysym.h>
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
+#include <X11/xpm.h>
 #include <X11/extensions/dpms.h>
 #include <stdbool.h>
 #include <getopt.h>
@@ -44,6 +45,22 @@ static void die(const char *errstr, ...) {
 }
 
 /*
+ * Check if given file can be opened => exists
+ *
+ */
+bool file_exists(const char * filename)
+{
+        FILE * file = fopen(filename, "r");
+        if(file)
+        {
+                fclose(file);
+                return true;
+        }
+        return false;
+}
+
+
+/*
  * Callback function for PAM. We only react on password request callbacks.
  *
  */
@@ -87,6 +104,8 @@ int main(int argc, char *argv[]) {
         bool dont_fork = false;
         bool beep = false;
         bool dpms = false;
+        bool xpm_image = false;
+        char xpm_image_path[256];
         Cursor invisible;
         Display *dpy;
         KeySym ksym;
@@ -106,10 +125,11 @@ int main(int argc, char *argv[]) {
                 {"nofork", no_argument, NULL, 'n'},
                 {"beep", no_argument, NULL, 'b'},
                 {"dpms", no_argument, NULL, 'd'},
+                {"image", required_argument, NULL, 'i'},
                 {NULL, no_argument, NULL, 0}
         };
 
-        while ((opt = getopt_long(argc, argv, "vnbd", long_options, &optind)) != -1) {
+        while ((opt = getopt_long(argc, argv, "vnbdi:", long_options, &optind)) != -1) {
                 switch (opt) {
                         case 'v':
                                 die("i3lock-"VERSION", © 2009 Michael Stapelberg\n"
@@ -123,8 +143,12 @@ int main(int argc, char *argv[]) {
                         case 'd':
                                 dpms = true;
                                 break;
+                        case 'i':
+                                strncpy(xpm_image_path, optarg, 255);
+                                xpm_image = true;
+                                break;
                         default:
-                                die("i3lock: Unknown option. Syntax: i3lock [-v] [-n] [-b] [-d]\n");
+                                die("i3lock: Unknown option. Syntax: i3lock [-v] [-n] [-b] [-d] [-i image.xpm]\n");
                 }
         }
 
@@ -156,6 +180,18 @@ int main(int argc, char *argv[]) {
         invisible = XCreatePixmapCursor(dpy, pmap, pmap, &black, &black, 0, 0);
         XDefineCursor(dpy, w, invisible);
         XMapRaised(dpy, w);
+
+        if(xpm_image && file_exists(xpm_image_path))
+        {
+                GC gc = XDefaultGC(dpy, 0);
+                int depth = DefaultDepth(dpy, screen);
+                int disp_width = DisplayWidth(dpy, screen);
+                int disp_height = DisplayHeight(dpy, screen);
+                Pixmap pix = XCreatePixmap(dpy, w, disp_width, disp_height, depth);
+                XpmReadFileToPixmap(dpy, w, xpm_image_path, &pix, 0, 0);
+                XCopyArea(dpy, pix, w, gc, 0, 0, disp_width, disp_height, 0, 0);
+        }
+
         for(len = 1000; len; len--) {
                 if(XGrabPointer(dpy, root, False, ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
                         GrabModeAsync, GrabModeAsync, None, invisible, CurrentTime) == GrabSuccess)
--
cgit v0.8.3

i3lock-1.0-1cddfc4a98efa54203f48de30b9937aaf66a95b4.patch:
 config.mk |    2 +-
 i3lock.1  |    6 ++++++
 i3lock.c  |   56 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 3 files changed, 56 insertions(+), 8 deletions(-)

--- NEW FILE i3lock-1.0-1cddfc4a98efa54203f48de30b9937aaf66a95b4.patch ---
>From 1cddfc4a98efa54203f48de30b9937aaf66a95b4 Mon Sep 17 00:00:00 2001
From: Jan-Erik Rediger <badboy at archlinux.us>
Date: Sun, 02 Aug 2009 17:59:16 +0100
Subject: adding option to enable tiling of images

---
diff --git i3lock-1.0.orig/config.mk i3lock-1.0/config.mk
index 664c254..78e6237 100644
--- i3lock-1.0.orig/config.mk
+++ i3lock-1.0/config.mk
@@ -13,7 +13,7 @@ MANDIR = $(DESTDIR)$(PREFIX)/share/man
 
 # includes and libs
 INCS = -I. -I/usr/include -I${X11INC}
-LIBS = -L${X11LIB} -lX11 -lpam -lXext -lXpm
+LIBS = -L${X11LIB} -lX11 -lpam -lXext -lXpm -lm
 
 # flags
 CPPFLAGS = -DVERSION=\"${VERSION}\"
diff --git i3lock-1.0.orig/i3lock.1 i3lock-1.0/i3lock.1
index cb45870..d07af67 100644
--- i3lock-1.0.orig/i3lock.1
+++ i3lock-1.0/i3lock.1
@@ -23,6 +23,7 @@ i3lock \- slightly improved version of slock
 .IR image.xpm \|]
 .RB [\|\-c
 .IR color \|]
+.RB [\|\-t\|]
 
 .SH DESCRIPTION
 .B i3lock
@@ -77,6 +78,11 @@ XPM by using convert(1) from ImageMagick or GIMP for example.
 .B \-c, \-\-color
 Turns the screen into the given color instead of white. Color must be given in 6-byte format: rrggbb (i.e. ff0000 is red)
 
+.TP
+.B \-t, \-\-tiling
+If an image is specified (via -i) it will display the image tiled all over the screen (if it is a multi-monitor setup, the image is visible on all screens)
+>>>>>>> adding option to enable tiling of images:i3lock.1
+
 .SH AUTHOR
 Michael Stapelberg <michael+i3lock at stapelberg dot de>
 
diff --git i3lock-1.0.orig/i3lock.c i3lock-1.0/i3lock.c
index 64d2301..adb7020 100644
--- i3lock-1.0.orig/i3lock.c
+++ i3lock-1.0/i3lock.c
@@ -22,6 +22,7 @@
 #include <stdio.h>
 #include <stdint.h>
 #include <string.h>
+#include <math.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <X11/keysym.h>
@@ -36,6 +37,31 @@
 
 static char passwd[256];
 
+/*
+ * displays an xpm image tiled over the whole screen
+ * (the image will be visible on all screens
+ * when using a multi monitor setup)
+ *
+ */
+void tiling_image(XpmImage *image,
+        int disp_height, int disp_width,
+        Display *dpy,
+        Pixmap pix,
+        Window w,
+        GC gc) {
+    int rows = (int)ceil(disp_height / (float)image->height),
+        cols = (int)ceil(disp_width / (float)image->width);
+
+    int x = 0,
+        y = 0;
+
+    for(y = 0; y < rows; y++) {
+        for(x = 0; x < cols; x++) {
+            XCopyArea(dpy, pix, w, gc, 0, 0, image->width, image->height, image->width * x, image->height * y);
+        }
+    }
+}
+
 static void die(const char *errstr, ...) {
         va_list ap;
 
@@ -151,6 +177,7 @@ int main(int argc, char *argv[]) {
         bool beep = false;
         bool dpms = false;
         bool xpm_image = false;
+        bool tiling = false;
         char xpm_image_path[256];
         char color[7] = "ffffff"; // white
         Cursor invisible;
@@ -174,10 +201,11 @@ int main(int argc, char *argv[]) {
                 {"dpms", no_argument, NULL, 'd'},
                 {"image", required_argument, NULL, 'i'},
                 {"color", required_argument, NULL, 'c'},
+                {"tiling", no_argument, NULL, 't'},
                 {NULL, no_argument, NULL, 0}
         };
 
-        while ((opt = getopt_long(argc, argv, "vnbdi:c:", long_options, &optind)) != -1) {
+        while ((opt = getopt_long(argc, argv, "vnbdi:c:t", long_options, &optind)) != -1) {
                 switch (opt) {
                         case 'v':
                                 die("i3lock-"VERSION", © 2009 Michael Stapelberg\n"
@@ -207,8 +235,11 @@ int main(int argc, char *argv[]) {
 
                                 break;
                         }
+                        case 't':
+                                tiling = true;
+                                break;
                         default:
-                                die("i3lock: Unknown option. Syntax: i3lock [-v] [-n] [-b] [-d] [-i image.xpm] [-c color]\n");
+                                die("i3lock: Unknown option. Syntax: i3lock [-v] [-n] [-b] [-d] [-i image.xpm] [-c color] [-t]\n");
                 }
         }
 
@@ -241,19 +272,31 @@ int main(int argc, char *argv[]) {
         XDefineCursor(dpy, w, invisible);
         XMapRaised(dpy, w);
 
-        if(xpm_image && file_exists(xpm_image_path))
-        {
+        if (xpm_image && file_exists(xpm_image_path)) {
                 GC gc = XDefaultGC(dpy, 0);
                 int depth = DefaultDepth(dpy, screen);
                 int disp_width = DisplayWidth(dpy, screen);
                 int disp_height = DisplayHeight(dpy, screen);
                 Pixmap pix = XCreatePixmap(dpy, w, disp_width, disp_height, depth);
-                int err = XpmReadFileToPixmap(dpy, w, xpm_image_path, &pix, 0, 0);
+                XpmImage xpm_image;
+                XpmInfo xpm_info;
+
+                int err = XpmReadFileToXpmImage(xpm_image_path, &xpm_image, &xpm_info);
                 if (err != 0) {
                         print_xpm_error(err);
                         return 1;
                 }
-                XCopyArea(dpy, pix, w, gc, 0, 0, disp_width, disp_height, 0, 0);
+
+                err = XpmCreatePixmapFromXpmImage(dpy, w, &xpm_image, &pix, 0, 0);
+                if (err != 0) {
+                        print_xpm_error(err);
+                        return 1;
+                }
+
+                if (tiling)
+                    tiling_image(&xpm_image, disp_height, disp_width, dpy, pix, w, gc);
+                else
+                    XCopyArea(dpy, pix, w, gc, 0, 0, disp_width, disp_height, 0, 0);
         }
 
         for(len = 1000; len; len--) {
--
cgit v0.8.3

i3lock-1.0-206036a852e3d9c598e3fe82d84fd2ac54bbaa55.patch:
 i3lock.c |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

--- NEW FILE i3lock-1.0-206036a852e3d9c598e3fe82d84fd2ac54bbaa55.patch ---
>From 206036a852e3d9c598e3fe82d84fd2ac54bbaa55 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael at stapelberg.de>
Date: Sun, 02 Aug 2009 17:50:30 +0100
Subject: Skip leading # signs for the color, fix input validation

---
diff --git i3lock-1.0.orig/i3lock.c i3lock-1.0/i3lock.c
index eca32e9..64d2301 100644
--- i3lock-1.0.orig/i3lock.c
+++ i3lock-1.0/i3lock.c
@@ -45,7 +45,6 @@ static void die(const char *errstr, ...) {
         exit(EXIT_FAILURE);
 }
 
-
 /*
  * Returns the colorpixel to use for the given hex color (think of HTML).
  *
@@ -197,13 +196,17 @@ int main(int argc, char *argv[]) {
                                 xpm_image = true;
                                 break;
                         case 'c':
-                                strncpy(color, optarg, 6);
-                                color[6] = 0;
+                        {
+                                char *arg = optarg;
+                                /* Skip # if present */
+                                if (arg[0] == '#')
+                                        arg++;
+
+                                if (strlen(arg) != 6 || sscanf(arg, "%06[0-9a-fA-F]", color) != 1)
+                                        die("color is invalid, color must be given in 6-byte format: rrggbb\n");
 
-                                char parsed_color[7];
-                                if (strlen(color) != 6 || sscanf(color, "%06[0-9a-fA-F]", parsed_color) != 1)
-                                    die("color is invalid, color must be given in 6-byte format: rrggbb\n");
                                 break;
+                        }
                         default:
                                 die("i3lock: Unknown option. Syntax: i3lock [-v] [-n] [-b] [-d] [-i image.xpm] [-c color]\n");
                 }
--
cgit v0.8.3

i3lock-1.0-25fe0bf00d7519db5c514cdb320870fa52265e2e.patch:
 README |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- NEW FILE i3lock-1.0-25fe0bf00d7519db5c514cdb320870fa52265e2e.patch ---
>From 25fe0bf00d7519db5c514cdb320870fa52265e2e Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael at stapelberg.de>
Date: Wed, 19 Aug 2009 19:34:51 +0100
Subject: Document dependency on libpam in README

---
diff --git i3lock-1.0.orig/README i3lock-1.0/README
index 13628e3..13d1ea6 100644
--- i3lock-1.0.orig/README
+++ i3lock-1.0/README
@@ -12,7 +12,8 @@ i3lock was forked from slock-0.9
 
 Requirements
 ------------
-In order to build i3lock you need the Xlib header files.
+In order to build i3lock you need the Xlib header files and the PAM development
+headers (libpam-dev or similar).
 
 
 Installation
--
cgit v0.8.3

i3lock-1.0-2e5bee59d5444f84126df845bfb8e02cd252576f.patch:
 i3lock.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- NEW FILE i3lock-1.0-2e5bee59d5444f84126df845bfb8e02cd252576f.patch ---
>From 2e5bee59d5444f84126df845bfb8e02cd252576f Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael at stapelberg.de>
Date: Thu, 10 Dec 2009 19:24:58 +0100
Subject: Skip keypresses without entering a password, they cause a delay

When suspending your system to RAM, a race-condition can occur which
causes many enter keypresses to be sent. These effectively delay
your login by 3 seconds times 50 times (or so), so we just skip empty
passwords. If your password is empty, you don’t need to lock your
screen anyway.
---
diff --git i3lock-1.0.orig/i3lock.c i3lock-1.0/i3lock.c
index d136ad2..de880c3 100644
--- i3lock-1.0.orig/i3lock.c
+++ i3lock-1.0/i3lock.c
@@ -335,6 +335,9 @@ int main(int argc, char *argv[])
                 switch(ksym) {
                 case XK_Return:
                         passwd[len] = 0;
+                        /* Skip empty passwords */
+                        if (len == 0)
+                                continue;
                         if ((ret = pam_authenticate(handle, 0)) == PAM_SUCCESS)
                                 running = false;
                         else {
--
cgit v0.8.3

i3lock-1.0-69a987db550678b640d0f59246e6ac2cd7ce2657.patch:
 i3lock.c |   36 ++++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

--- NEW FILE i3lock-1.0-69a987db550678b640d0f59246e6ac2cd7ce2657.patch ---
>From 69a987db550678b640d0f59246e6ac2cd7ce2657 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael at stapelberg.de>
Date: Sat, 27 Jun 2009 20:35:59 +0100
Subject: Handle error codes when loading the pixmap

---
diff --git i3lock-1.0.orig/i3lock.c i3lock-1.0/i3lock.c
index 5b495b5..a824c6a 100644
--- i3lock-1.0.orig/i3lock.c
+++ i3lock-1.0/i3lock.c
@@ -48,7 +48,7 @@ static void die(const char *errstr, ...) {
  * Check if given file can be opened => exists
  *
  */
-bool file_exists(const char * filename)
+bool file_exists(const char *filename)
 {
         FILE * file = fopen(filename, "r");
         if(file)
@@ -59,6 +59,31 @@ bool file_exists(const char * filename)
         return false;
 }
 
+/*
+ * Puts the given XPM error code to stderr
+ *
+ */
+void print_xpm_error(int err)
+{
+        switch (err) {
+                case XpmColorError:
+                        fprintf(stderr, "XPM: Could not parse or alloc requested color\n");
+                        break;
+                case XpmOpenFailed:
+                        fprintf(stderr, "XPM: Cannot open file\n");
+                        break;
+                case XpmFileInvalid:
+                        fprintf(stderr, "XPM: invalid XPM file\n");
+                        break;
+                case XpmNoMemory:
+                        fprintf(stderr, "XPM: Not enough memory\n");
+                        break;
+                case XpmColorFailed:
+                        fprintf(stderr, "XPM: Color not found\n");
+                        break;
+        }
+}
+
 
 /*
  * Callback function for PAM. We only react on password request callbacks.
@@ -188,12 +213,16 @@ int main(int argc, char *argv[]) {
                 int disp_width = DisplayWidth(dpy, screen);
                 int disp_height = DisplayHeight(dpy, screen);
                 Pixmap pix = XCreatePixmap(dpy, w, disp_width, disp_height, depth);
-                XpmReadFileToPixmap(dpy, w, xpm_image_path, &pix, 0, 0);
+                int err = XpmReadFileToPixmap(dpy, w, xpm_image_path, &pix, 0, 0);
+                if (err != 0) {
+                        print_xpm_error(err);
+                        return 1;
+                }
                 XCopyArea(dpy, pix, w, gc, 0, 0, disp_width, disp_height, 0, 0);
         }
 
         for(len = 1000; len; len--) {
-                if(XGrabPointer(dpy, root, False, ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
+                if(XGrabPointer(dpy, root, False, ButtonPressMask | ButtonReleaseMask,
                         GrabModeAsync, GrabModeAsync, None, invisible, CurrentTime) == GrabSuccess)
                         break;
                 usleep(1000);
--
cgit v0.8.3

i3lock-1.0-9c4dee2e8633d4ff2c9787fc3f1b6591338c41f5.patch:
 i3lock.1 |    8 +++++++-
 i3lock.c |   39 +++++++++++++++++++++++++++++++++++----
 2 files changed, 42 insertions(+), 5 deletions(-)

--- NEW FILE i3lock-1.0-9c4dee2e8633d4ff2c9787fc3f1b6591338c41f5.patch ---
>From 9c4dee2e8633d4ff2c9787fc3f1b6591338c41f5 Mon Sep 17 00:00:00 2001
From: Jan-Erik Rediger <badboy at archlinux.us>
Date: Fri, 31 Jul 2009 19:35:40 +0100
Subject: adding option to choose background color

---
diff --git i3lock-1.0.orig/i3lock.1 i3lock-1.0/i3lock.1
index 214d22a..cb45870 100644
--- i3lock-1.0.orig/i3lock.1
+++ i3lock-1.0/i3lock.1
@@ -21,10 +21,12 @@ i3lock \- slightly improved version of slock
 .RB [\|\-d\|]
 .RB [\|\-i
 .IR image.xpm \|]
+.RB [\|\-c
+.IR color \|]
 
 .SH DESCRIPTION
 .B i3lock
-locks your screen by making it white. To quit
+locks your screen by making it white (default). To quit
 .B i3lock
 just enter your password.
 
@@ -71,6 +73,10 @@ you did not disable this in your X server).
 Display the given XPM image instead of a blank screen. You can convert an image to
 XPM by using convert(1) from ImageMagick or GIMP for example.
 
+.TP
+.B \-c, \-\-color
+Turns the screen into the given color instead of white. Color must be given in 6-byte format: rrggbb (i.e. ff0000 is red)
+
 .SH AUTHOR
 Michael Stapelberg <michael+i3lock at stapelberg dot de>
 
diff --git i3lock-1.0.orig/i3lock.c i3lock-1.0/i3lock.c
index a824c6a..eca32e9 100644
--- i3lock-1.0.orig/i3lock.c
+++ i3lock-1.0/i3lock.c
@@ -20,6 +20,7 @@
 #include <stdarg.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <stdint.h>
 #include <string.h>
 #include <unistd.h>
 #include <sys/types.h>
@@ -44,6 +45,27 @@ static void die(const char *errstr, ...) {
         exit(EXIT_FAILURE);
 }
 
+
+/*
+ * Returns the colorpixel to use for the given hex color (think of HTML).
+ *
+ * The hex_color may not start with #, for example FF00FF works.
+ *
+ * NOTE that get_colorpixel() does _NOT_ check the given color code for validity.
+ * This has to be done by the caller.
+ *
+ */
+uint32_t get_colorpixel(char *hex) {
+        char strgroups[3][3] = {{hex[0], hex[1], '\0'},
+                                {hex[2], hex[3], '\0'},
+                                {hex[4], hex[5], '\0'}};
+        uint32_t rgb16[3] = {(strtol(strgroups[0], NULL, 16)),
+                             (strtol(strgroups[1], NULL, 16)),
+                             (strtol(strgroups[2], NULL, 16))};
+
+        return (rgb16[0] << 16) + (rgb16[1] << 8) + rgb16[2];
+}
+
 /*
  * Check if given file can be opened => exists
  *
@@ -131,6 +153,7 @@ int main(int argc, char *argv[]) {
         bool dpms = false;
         bool xpm_image = false;
         char xpm_image_path[256];
+        char color[7] = "ffffff"; // white
         Cursor invisible;
         Display *dpy;
         KeySym ksym;
@@ -151,10 +174,11 @@ int main(int argc, char *argv[]) {
                 {"beep", no_argument, NULL, 'b'},
                 {"dpms", no_argument, NULL, 'd'},
                 {"image", required_argument, NULL, 'i'},
+                {"color", required_argument, NULL, 'c'},
                 {NULL, no_argument, NULL, 0}
         };
 
-        while ((opt = getopt_long(argc, argv, "vnbdi:", long_options, &optind)) != -1) {
+        while ((opt = getopt_long(argc, argv, "vnbdi:c:", long_options, &optind)) != -1) {
                 switch (opt) {
                         case 'v':
                                 die("i3lock-"VERSION", © 2009 Michael Stapelberg\n"
@@ -172,8 +196,16 @@ int main(int argc, char *argv[]) {
                                 strncpy(xpm_image_path, optarg, 255);
                                 xpm_image = true;
                                 break;
+                        case 'c':
+                                strncpy(color, optarg, 6);
+                                color[6] = 0;
+
+                                char parsed_color[7];
+                                if (strlen(color) != 6 || sscanf(color, "%06[0-9a-fA-F]", parsed_color) != 1)
+                                    die("color is invalid, color must be given in 6-byte format: rrggbb\n");
+                                break;
                         default:
-                                die("i3lock: Unknown option. Syntax: i3lock [-v] [-n] [-b] [-d] [-i image.xpm]\n");
+                                die("i3lock: Unknown option. Syntax: i3lock [-v] [-n] [-b] [-d] [-i image.xpm] [-c color]\n");
                 }
         }
 
@@ -196,7 +228,7 @@ int main(int argc, char *argv[]) {
 
         /* init */
         wa.override_redirect = 1;
-        wa.background_pixel = WhitePixel(dpy, screen);
+        wa.background_pixel = get_colorpixel(color);
         w = XCreateWindow(dpy, root, 0, 0, DisplayWidth(dpy, screen), DisplayHeight(dpy, screen),
                         0, DefaultDepth(dpy, screen), CopyFromParent,
                         DefaultVisual(dpy, screen), CWOverrideRedirect | CWBackPixel, &wa);
--
cgit v0.8.3

i3lock-1.0-c1a91badbed68ab63e1109bf74902e2f88bae008.patch:
 i3lock.1 |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

--- NEW FILE i3lock-1.0-c1a91badbed68ab63e1109bf74902e2f88bae008.patch ---
>From c1a91badbed68ab63e1109bf74902e2f88bae008 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael at stapelberg.de>
Date: Sat, 27 Jun 2009 21:06:44 +0100
Subject: Document the new option in the manpage

---
diff --git i3lock-1.0.orig/i3lock.1 i3lock-1.0/i3lock.1
index 922c153..214d22a 100644
--- i3lock-1.0.orig/i3lock.1
+++ i3lock-1.0/i3lock.1
@@ -8,7 +8,7 @@
 .fi
 ..
 
-.TH i3lock 1 "MAY 2009" Linux "User Manuals"
+.TH i3lock 1 "JUNE 2009" Linux "User Manuals"
 
 .SH NAME
 i3lock \- slightly improved version of slock
@@ -19,6 +19,8 @@ i3lock \- slightly improved version of slock
 .RB [\|\-n\|]
 .RB [\|\-b\|]
 .RB [\|\-d\|]
+.RB [\|\-i
+.IR image.xpm \|]
 
 .SH DESCRIPTION
 .B i3lock
@@ -64,6 +66,11 @@ Enable turning off your screen using DPMS. Note that, when you do not specify th
 option, DPMS will turn off your screen after 15 minutes of inactivity anyways (if
 you did not disable this in your X server).
 
+.TP
+.B \-i, \-\-image
+Display the given XPM image instead of a blank screen. You can convert an image to
+XPM by using convert(1) from ImageMagick or GIMP for example.
+
 .SH AUTHOR
 Michael Stapelberg <michael+i3lock at stapelberg dot de>
 
--
cgit v0.8.3

i3lock-1.0-ef1d47ce5b663ccc75f8387021bcc4a9e75b2a5d.patch:
 i3lock.1 |   21 ++++++++++++-------
 i3lock.c |   68 ++++++++++++++++++++++++++-------------------------------------
 2 files changed, 42 insertions(+), 47 deletions(-)

--- NEW FILE i3lock-1.0-ef1d47ce5b663ccc75f8387021bcc4a9e75b2a5d.patch ---
>From ef1d47ce5b663ccc75f8387021bcc4a9e75b2a5d Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael at stapelberg.de>
Date: Sun, 02 Aug 2009 19:47:39 +0100
Subject: Some small cleanups

---
diff --git i3lock-1.0.orig/i3lock.1 i3lock-1.0/i3lock.1
index d07af67..35df6e0 100644
--- i3lock-1.0.orig/i3lock.1
+++ i3lock-1.0/i3lock.1
@@ -8,7 +8,7 @@
 .fi
 ..
 
-.TH i3lock 1 "JUNE 2009" Linux "User Manuals"
+.TH i3lock 1 "AUGUST 2009" Linux "User Manuals"
 
 .SH NAME
 i3lock \- slightly improved version of slock
@@ -38,9 +38,11 @@ improves slock by making it fork() and therefore combinable with
 commands to suspend your computer. Additionally, instead of turning off
 your screen via DPMS and/or displaying a black screen,
 .B i3lock
-displays a white screen so you can see if your computer failed to resume
-from suspend or if your screen is just locked. Also, when entering a wrong
-password,
+displays a white (or colored in your favorite color) screen so you can see
+if your computer failed to resume from suspend or if your screen is just
+locked. Since version 1.1,
+.B i3lock
+can display images in XPM file format. Also, when entering a wrong password,
 .B i3lock
 does not call XBell(). This is important because
 .B i3lock/slock
@@ -76,14 +78,17 @@ XPM by using convert(1) from ImageMagick or GIMP for example.
 
 .TP
 .B \-c, \-\-color
-Turns the screen into the given color instead of white. Color must be given in 6-byte format: rrggbb (i.e. ff0000 is red)
+Turns the screen into the given color instead of white. Color must be given in 6-byte
+format: rrggbb (i.e. ff0000 is red)
 
 .TP
-.B \-t, \-\-tiling
-If an image is specified (via -i) it will display the image tiled all over the screen (if it is a multi-monitor setup, the image is visible on all screens)
->>>>>>> adding option to enable tiling of images:i3lock.1
+.B \-t, \-\-tile
+If an image is specified (via -i) it will display the image tiled all over the screen
+(if it is a multi-monitor setup, the image is visible on all screens).
 
 .SH AUTHOR
 Michael Stapelberg <michael+i3lock at stapelberg dot de>
 
+Jan-Erik Rediger <badboy at archlinux.us>
+
 forked from slock-0.9 by Anselm R Garbe <garbeam at gmail dot com>
diff --git i3lock-1.0.orig/i3lock.c i3lock-1.0/i3lock.c
index adb7020..d136ad2 100644
--- i3lock-1.0.orig/i3lock.c
+++ i3lock-1.0/i3lock.c
@@ -4,6 +4,7 @@
  * i3lock - an improved version of slock
  *
  * i3lock © 2009 Michael Stapelberg and contributors
+ * i3lock © 2009 Jan-Erik Rediger
  * slock  © 2006-2008 Anselm R Garbe
  *
  * See file LICENSE for license information.
@@ -32,6 +33,7 @@
 #include <X11/extensions/dpms.h>
 #include <stdbool.h>
 #include <getopt.h>
+#include <err.h>
 
 #include <security/pam_appl.h>
 
@@ -43,32 +45,19 @@ static char passwd[256];
  * when using a multi monitor setup)
  *
  */
-void tiling_image(XpmImage *image,
-        int disp_height, int disp_width,
-        Display *dpy,
-        Pixmap pix,
-        Window w,
-        GC gc) {
-    int rows = (int)ceil(disp_height / (float)image->height),
-        cols = (int)ceil(disp_width / (float)image->width);
-
-    int x = 0,
-        y = 0;
-
-    for(y = 0; y < rows; y++) {
-        for(x = 0; x < cols; x++) {
-            XCopyArea(dpy, pix, w, gc, 0, 0, image->width, image->height, image->width * x, image->height * y);
+static void tile_image(XpmImage *image, int disp_height, int disp_width,
+                       Display *dpy, Pixmap pix, Window w, GC gc)
+{
+        int rows = (int)ceil(disp_height / (float)image->height),
+            cols = (int)ceil(disp_width / (float)image->width);
+
+        for (int y = 0; y < rows; y++) {
+                for (int x = 0; x < cols; x++) {
+                        XCopyArea(dpy, pix, w, gc, 0, 0,
+                                  image->width, image->height,
+                                  image->width * x, image->height * y);
+                }
         }
-    }
-}
-
-static void die(const char *errstr, ...) {
-        va_list ap;
-
-        va_start(ap, errstr);
-        vfprintf(stderr, errstr, ap);
-        va_end(ap);
-        exit(EXIT_FAILURE);
 }
 
 /*
@@ -80,7 +69,7 @@ static void die(const char *errstr, ...) {
  * This has to be done by the caller.
  *
  */
-uint32_t get_colorpixel(char *hex) {
+static uint32_t get_colorpixel(char *hex) {
         char strgroups[3][3] = {{hex[0], hex[1], '\0'},
                                 {hex[2], hex[3], '\0'},
                                 {hex[4], hex[5], '\0'}};
@@ -95,7 +84,7 @@ uint32_t get_colorpixel(char *hex) {
  * Check if given file can be opened => exists
  *
  */
-bool file_exists(const char *filename)
+static bool file_exists(const char *filename)
 {
         FILE * file = fopen(filename, "r");
         if(file)
@@ -110,7 +99,7 @@ bool file_exists(const char *filename)
  * Puts the given XPM error code to stderr
  *
  */
-void print_xpm_error(int err)
+static void print_xpm_error(int err)
 {
         switch (err) {
                 case XpmColorError:
@@ -137,7 +126,8 @@ void print_xpm_error(int err)
  *
  */
 static int conv_callback(int num_msg, const struct pam_message **msg,
-                         struct pam_response **resp, void *appdata_ptr) {
+                         struct pam_response **resp, void *appdata_ptr)
+{
         if (num_msg == 0)
                 return 1;
 
@@ -163,7 +153,8 @@ static int conv_callback(int num_msg, const struct pam_message **msg,
         return 0;
 }
 
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
         char curs[] = {0, 0, 0, 0, 0, 0, 0, 0};
         char buf[32];
         char *username;
@@ -208,7 +199,7 @@ int main(int argc, char *argv[]) {
         while ((opt = getopt_long(argc, argv, "vnbdi:c:t", long_options, &optind)) != -1) {
                 switch (opt) {
                         case 'v':
-                                die("i3lock-"VERSION", © 2009 Michael Stapelberg\n"
+                                errx(0, "i3lock-"VERSION", © 2009 Michael Stapelberg\n"
                                     "based on slock, which is © 2006-2008 Anselm R Garbe\n");
                         case 'n':
                                 dont_fork = true;
@@ -231,7 +222,7 @@ int main(int argc, char *argv[]) {
                                         arg++;
 
                                 if (strlen(arg) != 6 || sscanf(arg, "%06[0-9a-fA-F]", color) != 1)
-                                        die("color is invalid, color must be given in 6-byte format: rrggbb\n");
+                                        errx(1, "color is invalid, color must be given in 6-byte format: rrggbb\n");
 
                                 break;
                         }
@@ -239,19 +230,19 @@ int main(int argc, char *argv[]) {
                                 tiling = true;
                                 break;
                         default:
-                                die("i3lock: Unknown option. Syntax: i3lock [-v] [-n] [-b] [-d] [-i image.xpm] [-c color] [-t]\n");
+                                errx(1, "i3lock: Unknown option. Syntax: i3lock [-v] [-n] [-b] [-d] [-i image.xpm] [-c color] [-t]\n");
                 }
         }
 
         if ((username = getenv("USER")) == NULL)
-                die("USER environment variable not set, please set it.\n");
+                errx(1, "USER environment variable not set, please set it.\n");
 
         int ret = pam_start("i3lock", username, &conv, &handle);
         if (ret != PAM_SUCCESS)
-                die("PAM: %s\n", pam_strerror(handle, ret));
+                errx(1, "PAM: %s\n", pam_strerror(handle, ret));
 
         if(!(dpy = XOpenDisplay(0)))
-                die("i3lock: cannot open display\n");
+                errx(1, "i3lock: cannot open display\n");
         screen = DefaultScreen(dpy);
         root = RootWindow(dpy, screen);
 
@@ -294,9 +285,9 @@ int main(int argc, char *argv[]) {
                 }
 
                 if (tiling)
-                    tiling_image(&xpm_image, disp_height, disp_width, dpy, pix, w, gc);
+                        tile_image(&xpm_image, disp_height, disp_width, dpy, pix, w, gc);
                 else
-                    XCopyArea(dpy, pix, w, gc, 0, 0, disp_width, disp_height, 0, 0);
+                        XCopyArea(dpy, pix, w, gc, 0, 0, disp_width, disp_height, 0, 0);
         }
 
         for(len = 1000; len; len--) {
--
cgit v0.8.3


Index: i3lock.spec
===================================================================
RCS file: /cvs/pkgs/rpms/i3lock/devel/i3lock.spec,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -p -r1.2 -r1.3
--- i3lock.spec	13 Jan 2010 16:37:09 -0000	1.2
+++ i3lock.spec	5 Feb 2010 19:59:16 -0000	1.3
@@ -1,6 +1,6 @@
 Name:           i3lock
 Version:        1.0
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        Simple X display locker
 
 Group:          User Interface/Desktops
@@ -10,9 +10,31 @@ Source0:        http://i3.zekjur.net/%{n
 Source1:        %{name}.pam
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
+# i3lock now can use xpm images as background
+Patch0: %{name}-1.0-189ee55bc074c14d61a900d428401580614a5618.patch
+# Handle error codes when loading the pixmap
+Patch1: %{name}-1.0-69a987db550678b640d0f59246e6ac2cd7ce2657.patch
+# Document the new option in the manpage
+Patch2: %{name}-1.0-c1a91badbed68ab63e1109bf74902e2f88bae008.patch
+# adding option to choose background color
+Patch3: %{name}-1.0-9c4dee2e8633d4ff2c9787fc3f1b6591338c41f5.patch
+# Skip leading # signs for the color, fix input validation
+Patch4: %{name}-1.0-206036a852e3d9c598e3fe82d84fd2ac54bbaa55.patch
+# adding option to enable tiling of images
+Patch5: %{name}-1.0-1cddfc4a98efa54203f48de30b9937aaf66a95b4.patch
+# Some small cleanups
+Patch6: %{name}-1.0-ef1d47ce5b663ccc75f8387021bcc4a9e75b2a5d.patch
+# Document dependency on libpam in README
+Patch7: %{name}-1.0-25fe0bf00d7519db5c514cdb320870fa52265e2e.patch
+# Skip keypresses without entering a password, they cause a delay
+Patch8: %{name}-1.0-2e5bee59d5444f84126df845bfb8e02cd252576f.patch
+
+
+
 BuildRequires:  libX11-devel
 BuildRequires:  pam-devel
 BuildRequires:  libXext-devel
+BuildRequires:  libXpm-devel
 
 
 %description
@@ -28,6 +50,16 @@ resuming from suspend, at least sometime
 %prep
 %setup -q
 
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
+%patch4 -p1
+%patch5 -p1
+%patch6 -p1
+%patch7 -p1
+%patch8 -p1
+
 sed -e 's|CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}|CFLAGS = -std=c99 -pedantic %{optflags} ${INCS} ${CPPFLAGS}|g' \
     -e 's|LDFLAGS = -s ${LIBS}|LDFLAGS = ${LIBS}|g' \
     -i config.mk
@@ -61,6 +93,18 @@ rm -rf %{buildroot}
 
 
 %changelog
+* Sat Feb 05 2010 Simon Wesp <cassmodiah at fedoraproject.org> - 1.0-3
+- Some bugfixes (sync with upstream)
+- Add patch http://code.stapelberg.de/git/i3lock/commit/?id=189ee55bc074c14d61a900d428401580614a5618
+- Add patch http://code.stapelberg.de/git/i3lock/commit/?id=69a987db550678b640d0f59246e6ac2cd7ce2657
+- Add patch http://code.stapelberg.de/git/i3lock/commit/?id=c1a91badbed68ab63e1109bf74902e2f88bae008
+- Add patch http://code.stapelberg.de/git/i3lock/commit/?id=9c4dee2e8633d4ff2c9787fc3f1b6591338c41f5
+- Add patch http://code.stapelberg.de/git/i3lock/commit/?id=206036a852e3d9c598e3fe82d84fd2ac54bbaa55
+- Add patch http://code.stapelberg.de/git/i3lock/commit/?id=1cddfc4a98efa54203f48de30b9937aaf66a95b4
+- Add patch http://code.stapelberg.de/git/i3lock/commit/?id=ef1d47ce5b663ccc75f8387021bcc4a9e75b2a5d
+- Add patch http://code.stapelberg.de/git/i3lock/commit/?id=25fe0bf00d7519db5c514cdb320870fa52265e2e
+- Add patch http://code.stapelberg.de/git/i3lock/commit/?id=2e5bee59d5444f84126df845bfb8e02cd252576f
+
 * Sat Jan 09 2010 Simon Wesp <cassmodiah at fedoraproject.org> - 1.0-2
 - Add a PAM configfile as SOURCE1
 



More information about the scm-commits mailing list