diff options
author | GI_Jack | 2020-06-18 20:01:49 -0400 |
---|---|---|
committer | GI_Jack | 2020-06-18 20:01:49 -0400 |
commit | b18d5c466bd07584f3ac87424008b2e808fd962d (patch) | |
tree | e92e259cffbe5f0633782b9100c8435aef2056b2 | |
download | aur-b18d5c466bd07584f3ac87424008b2e808fd962d.tar.gz |
initial commit
-rw-r--r-- | .SRCINFO | 17 | ||||
-rw-r--r-- | PKGBUILD | 39 | ||||
-rw-r--r-- | slock-image.patch | 137 |
3 files changed, 193 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..65018c335f74 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,17 @@ +pkgbase = slock-bgimage + pkgdesc = A simple screen locker for X(patched to allow background images) + pkgver = 1.4 + pkgrel = 1 + url = https://tools.suckless.org/slock + arch = x86_64 + license = MIT + depends = libxext + depends = libxrandr + conflicts = slock + source = https://dl.suckless.org/tools/slock-1.4.tar.gz + source = slock-image.patch + sha256sums = b53849dbc60109a987d7a49b8da197305c29307fd74c12dc18af0d3044392e6a + sha256sums = 2eb67544256fc1e036e844b87779914e77327aabf23036b0c6a0895fc878378a + +pkgname = slock-bgimage + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..30b0c8ee7afe --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,39 @@ +# Maintainer: GI_Jack <GI_Jack@hackermail.com> + +# Original: Sergej Pupykin <pupykin.s+arch@gmail.com> +# Contributor: Sebastian A. Liem <sebastian at liem dot se> + +pkgname=slock-bgimage +_pkgname=slock +pkgver=1.4 +pkgrel=1 +pkgdesc="A simple screen locker for X(patched to allow background images)" +arch=('x86_64') +url="https://tools.suckless.org/slock" +license=('MIT') +depends=('libxext' 'libxrandr') +providies=("slock") +conflicts=("slock") +source=("https://dl.suckless.org/tools/${_pkgname}-$pkgver.tar.gz" "slock-image.patch") +#source=("slock-$pkgver.tar.bz2::https://hg.suckless.org/slock/archive/$_pkgver.tar.gz") +sha256sums=('b53849dbc60109a987d7a49b8da197305c29307fd74c12dc18af0d3044392e6a' + '2eb67544256fc1e036e844b87779914e77327aabf23036b0c6a0895fc878378a') + +prepare() { + cd "$srcdir/slock-$pkgver" + patch -N < ../slock-image.patch + sed -i 's|static const char \*group = "nogroup";|static const char *group = "nobody";|' config.def.h + sed -ri 's/((CPP|C|LD)FLAGS) =/\1 +=/g' config.mk +} + +build() { + cd "$srcdir/slock-$pkgver" + make X11INC=/usr/include/X11 X11LIB=/usr/lib/X11 +} + +package() { + cd "$srcdir/slock-$pkgver" + make PREFIX=/usr DESTDIR="$pkgdir" install + install -m644 -D LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" +} + diff --git a/slock-image.patch b/slock-image.patch new file mode 100644 index 000000000000..de61e7372a47 --- /dev/null +++ b/slock-image.patch @@ -0,0 +1,137 @@ +--- config.mk ++++ config.mk +@@ -12,7 +12,7 @@ + + # includes and libs + INCS = -I. -I/usr/include -I${X11INC} +-LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr ++LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr -lImlib2 + + # flags + CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE -DHAVE_SHADOW_H + +--- slock.c ++++ slock.c +@@ -18,8 +18,9 @@ + #include <X11/keysym.h> + #include <X11/Xlib.h> + #include <X11/Xutil.h> ++#include <Imlib2.h> ++#include <getopt.h> + +-#include "arg.h" + #include "util.h" + + char *argv0; +@@ -35,6 +36,7 @@ + int screen; + Window root, win; + Pixmap pmap; ++ Pixmap bgmap; + unsigned long colors[NUMCOLS]; + }; + +@@ -190,10 +192,10 @@ + color = len ? INPUT : ((failure || failonclear) ? FAILED : INIT); + if (running && oldc != color) { + for (screen = 0; screen < nscreens; screen++) { +- XSetWindowBackground(dpy, +- locks[screen]->win, +- locks[screen]->colors[color]); +- XClearWindow(dpy, locks[screen]->win); ++ if(locks[screen]->bgmap) ++ XSetWindowBackgroundPixmap(dpy, locks[screen]->win, locks[screen]->bgmap); ++ else ++ XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[0]); + } + oldc = color; + } +@@ -212,7 +214,7 @@ + } + + static struct lock * +-lockscreen(Display *dpy, struct xrandr *rr, int screen) ++lockscreen(Display *dpy, struct xrandr *rr, int screen,Imlib_Image *image, int use_bg_image) + { + char curs[] = {0, 0, 0, 0, 0, 0, 0, 0}; + int i, ptgrab, kbgrab; +@@ -233,6 +235,16 @@ + lock->colors[i] = color.pixel; + } + ++ if(image || use_bg_image == 1) { ++ lock->bgmap = XCreatePixmap(dpy, lock->root, DisplayWidth(dpy, lock->screen), DisplayHeight(dpy, lock->screen), DefaultDepth(dpy, lock->screen)); ++ imlib_context_set_image(image); ++ imlib_context_set_display(dpy); ++ imlib_context_set_visual(DefaultVisual(dpy, lock->screen)); ++ imlib_context_set_colormap(DefaultColormap(dpy, lock->screen)); ++ imlib_context_set_drawable(lock->bgmap); ++ imlib_render_image_on_drawable(0, 0); ++ imlib_free_image(); ++ } + /* init */ + wa.override_redirect = 1; + wa.background_pixel = lock->colors[INIT]; +@@ -248,6 +260,10 @@ + &color, &color, 0, 0); + XDefineCursor(dpy, lock->win, invisible); + ++ if(lock->bgmap) ++ XSetWindowBackgroundPixmap(dpy, lock->win, lock->bgmap); ++ ++ + /* Try to grab mouse pointer *and* keyboard for 600ms, else fail the lock */ + for (i = 0, ptgrab = kbgrab = -1; i < 6; i++) { + if (ptgrab != GrabSuccess) { +@@ -292,7 +308,7 @@ + static void + usage(void) + { +- die("usage: slock [-v] [cmd [arg ...]]\n"); ++ die("\nusage: slock [options]\noptions:\n\t-v\tPrint version and exit.\n\t-i\t<full path to image file to display>\n"); + } + + int +@@ -306,14 +322,25 @@ + const char *hash; + Display *dpy; + int s, nlocks, nscreens; +- +- ARGBEGIN { +- case 'v': +- fprintf(stderr, "slock-"VERSION"\n"); +- return 0; +- default: +- usage(); +- } ARGEND ++ Imlib_Image image; ++ int use_bg_image = 0; ++ int option = 0; ++ ++ while ((option = getopt(argc, argv,"vi:")) != -1) { ++ switch (option) { ++ case 'v' : ++ die("slock-"VERSION" mod-bgimage\n"); ++ break; ++ case 'i' : ++ use_bg_image = 1; ++ image = imlib_load_image(optarg); ++ if(!image) { ++ die("slock: unable to load image.\n"); ++ } ++ break; ++ default: usage(); ++ } ++ } + + /* validate drop-user and -group */ + errno = 0; +@@ -355,7 +382,7 @@ + if (!(locks = calloc(nscreens, sizeof(struct lock *)))) + die("slock: out of memory\n"); + for (nlocks = 0, s = 0; s < nscreens; s++) { +- if ((locks[s] = lockscreen(dpy, &rr, s)) != NULL) ++ if ((locks[s] = lockscreen(dpy, &rr, s, image, use_bg_image)) != NULL) + nlocks++; + else + break; |