diff options
author | John Vogel <jvogel4@stny.rr.com> | 2014-03-27 14:07:04 -0500 |
---|---|---|
committer | Erik Hanson <erik@slackbuilds.org> | 2014-04-12 13:59:47 -0500 |
commit | e7695c5163dc2e7abd8e1b8e49a0e47604ca3958 (patch) | |
tree | 7425bc003a60c89895b3740602a723c185ef1a91 | |
parent | 6a8c7f714423fd3a94d2e8bb368679494a7c1b93 (diff) | |
download | slackbuilds-e7695c5163dc2e7abd8e1b8e49a0e47604ca3958.tar.gz |
desktop/bar: Added (lightweight bar based on XCB)
Signed-off-by: Robby Workman <rworkman@slackbuilds.org>
-rw-r--r-- | desktop/bar/README | 5 | ||||
-rw-r--r-- | desktop/bar/bar.SlackBuild | 98 | ||||
-rw-r--r-- | desktop/bar/bar.info | 10 | ||||
-rw-r--r-- | desktop/bar/patches/bar-Makefile-CFLAGS.patch | 13 | ||||
-rw-r--r-- | desktop/bar/patches/bar-monitor-option.patch | 300 | ||||
-rw-r--r-- | desktop/bar/slack-desc | 19 |
6 files changed, 445 insertions, 0 deletions
diff --git a/desktop/bar/README b/desktop/bar/README new file mode 100644 index 0000000000..35db41b5b4 --- /dev/null +++ b/desktop/bar/README @@ -0,0 +1,5 @@ +bar - bar ain't recursive + +bar is a lightweight bar entirely based on XCB. Provides full UTF-8 support, +basic formatting, RandR and Xinerama support and EWMH compliance without +wasting your precious memory. diff --git a/desktop/bar/bar.SlackBuild b/desktop/bar/bar.SlackBuild new file mode 100644 index 0000000000..71971ed2a2 --- /dev/null +++ b/desktop/bar/bar.SlackBuild @@ -0,0 +1,98 @@ +#!/bin/sh + +# Slackware build script for bar - bar ain't recursive + +# Copyright 2014 John Vogel Corning, NY USA +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +PRGNAM=bar +VERSION=${VERSION:-1.0} +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} + +if [ -z "$ARCH" ]; then + case "$( uname -m )" in + i?86) ARCH=i486 ;; + arm*) ARCH=arm ;; + *) ARCH=$( uname -m ) ;; + esac +fi + +CWD=$(pwd) +TMP=${TMP:-/tmp/SBo} +PKG=$TMP/package-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} + +if [ "$ARCH" = "i486" ]; then + SLKCFLAGS="-O2 -march=i486 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "i686" ]; then + SLKCFLAGS="-O2 -march=i686 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "x86_64" ]; then + SLKCFLAGS="-O2 -fPIC" + LIBDIRSUFFIX="64" +else + SLKCFLAGS="-O2" + LIBDIRSUFFIX="" +fi + +set -e + +rm -rf $PKG +mkdir -p $TMP $PKG $OUTPUT +cd $TMP +rm -rf $PRGNAM-$VERSION +if [ ! -f $CWD/$PRGNAM-$VERSION.tar.gz ]; then + if [ -f $CWD/v$VERSION.tar.gz ]; then + mv $CWD/v$VERSION.tar.gz $CWD/$PRGNAM-$VERSION.tar.gz + fi +fi +tar xvf $CWD/$PRGNAM-$VERSION.tar.gz +cd $PRGNAM-$VERSION +chown -R root:root . +find -L . \ + \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ + -o -perm 511 \) -exec chmod 755 {} \; -o \ + \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ + -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; + +# add monitor option for ordering and selective inclusion +patch -p1 < $CWD/patches/bar-monitor-option.patch + +# adjust CFLAGS in Makefile to accept SLKCFLAGS +patch -p1 < $CWD/patches/bar-Makefile-CFLAGS.patch + +CFLAGS="$SLKCFLAGS" make +make doc +install -D -m 755 bar $PKG/usr/bin/bar +install -D -m 644 bar.1 $PKG/usr/man/man1/bar.1 + +gzip -9 $PKG/usr/man/man1/bar.1 + +mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION +cp -a LICENSE README.pod $PKG/usr/doc/$PRGNAM-$VERSION +cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild + +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc + +cd $PKG +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz} diff --git a/desktop/bar/bar.info b/desktop/bar/bar.info new file mode 100644 index 0000000000..dd758ad88f --- /dev/null +++ b/desktop/bar/bar.info @@ -0,0 +1,10 @@ +PRGNAM="bar" +VERSION="1.0" +HOMEPAGE="https://github.com/LemonBoy/bar" +DOWNLOAD="https://github.com/LemonBoy/bar/archive/v1.0.tar.gz" +MD5SUM="cb4a18b3784ae6f0e106b2171c2bed6e" +DOWNLOAD_x86_64="" +MD5SUM_x86_64="" +REQUIRES="" +MAINTAINER="John Vogel" +EMAIL="jvogel4@stny.rr.com" diff --git a/desktop/bar/patches/bar-Makefile-CFLAGS.patch b/desktop/bar/patches/bar-Makefile-CFLAGS.patch new file mode 100644 index 0000000000..bef2cba8ff --- /dev/null +++ b/desktop/bar/patches/bar-Makefile-CFLAGS.patch @@ -0,0 +1,13 @@ +diff --git a/Makefile b/Makefile +index ff620a8..01b6bf9 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,7 @@ + CC ?= gcc + STRIP ?= strip +-CFLAGS = -std=c99 -Os ++CFLAGS ?= -Os ++CFLAGS += -std=c99 + LDFLAGS = -lxcb -lxcb-xinerama -lxcb-randr + CFDEBUG = -g3 -pedantic -Wall -Wunused-parameter -Wlong-long\ + -Wsign-conversion -Wconversion -Wimplicit-function-declaration diff --git a/desktop/bar/patches/bar-monitor-option.patch b/desktop/bar/patches/bar-monitor-option.patch new file mode 100644 index 0000000000..d5c5fafa0d --- /dev/null +++ b/desktop/bar/patches/bar-monitor-option.patch @@ -0,0 +1,300 @@ +diff --git a/README.pod b/README.pod +index 565f188..2d2075d 100644 +--- a/README.pod ++++ b/README.pod +@@ -4,7 +4,7 @@ bar - bar ain't recursive + + =head1 SYNOPSIS + +-I<bar> [-h | -g I<width>B<x>I<height>B<+>I<x> | -b | -d | -f I<font> | -p | -u I<pixel> | -B I<color> | -F I<color>] ++I<bar> [-h | -g I<width>B<x>I<height>B<+>I<x> | -m I<monitor>B<:>I<monitor>B<:>... | -b | -d | -f I<font> | -p | -u I<pixel> | -B I<color> | -F I<color>] + + =head1 DESCRIPTION + +@@ -22,6 +22,10 @@ Display the help and exit. + + Set the window geometry. If a parameter is omitted it's filled with the default value. + ++=item B<-m> I<monitor>B<:>I<monitor>B<:>I<...> ++ ++Set monitors to be used and in what order. Positive numeric arguments only, separated by colons. ++ + =item B<-b> + + Dock the bar at the bottom of the screen. +diff --git a/bar.c b/bar.c +index 1ccc907..0f9f694 100644 +--- a/bar.c ++++ b/bar.c +@@ -17,6 +17,8 @@ + #define max(a,b) ((a) > (b) ? (a) : (b)) + #define min(a,b) ((a) < (b) ? (a) : (b)) + #define indexof(c,s) (strchr((s),(c))-(s)) ++#define MONITORS_MAX 32 ++#define N 10 + + typedef struct font_t { + xcb_font_t ptr; +@@ -39,8 +41,6 @@ typedef struct area_t { + char *cmd; + } area_t; + +-#define N 10 +- + typedef struct area_stack_t { + int pos; + area_t slot[N]; +@@ -80,6 +80,9 @@ static char *mfont, *afont; + static uint32_t fgc, bgc, ugc; + static uint32_t dfgc, dbgc; + static area_stack_t astack; ++static uint32_t mons = 0; ++static int nmons = 0; ++static int monlist[MONITORS_MAX]; + + void + update_gc (void) +@@ -302,7 +305,8 @@ parse (char *text) + + memset(&astack, 0, sizeof(area_stack_t)); + +- fill_rect(cur_mon->pixmap, gc[GC_CLEAR], 0, 0, bw, bh); ++ for (monitor_t *m = monhead; m; m = m->next) ++ fill_rect(m->pixmap, gc[GC_CLEAR], 0, 0, bw, bh); + + for (;;) { + if (*p == '\0' || *p == '\n') +@@ -356,7 +360,6 @@ parse (char *text) + + p++; + pos_x = 0; +- fill_rect(cur_mon->pixmap, gc[GC_CLEAR], 0, 0, cur_mon->width, bh); + break; + + /* In case of error keep parsing after the closing } */ +@@ -562,14 +565,40 @@ rect_sort_cb (const void *p1, const void *p2) + void + monitor_create_chain (xcb_rectangle_t *rects, const int num) + { +- int width = bw; ++ int i, cnt; ++ int width = 0; + int left = bx; + + /* Sort before use */ + qsort(rects, num, sizeof(xcb_rectangle_t), rect_sort_cb); + ++ if (nmons) { ++ xcb_rectangle_t r[num]; ++ /* Get combined width of specified monitors and set aside specified monitors */ ++ for (i = cnt = 0; i < nmons; i++) { ++ if (monlist[i] >= num) { ++ fprintf(stderr, "Specified monitor %d not found\n", monlist[i]); ++ continue; ++ } ++ width += rects[monlist[i]].width; ++ memcpy(&r[cnt++], &rects[monlist[i]], sizeof(xcb_rectangle_t)); ++ } ++ memcpy(rects, r, cnt * sizeof(xcb_rectangle_t)); ++ } ++ else { ++ /* Else default to X screen width */ ++ width = scr->width_in_pixels; ++ cnt = num; ++ } ++ ++ /* If I fits I sits */ ++ if (bw < 0) ++ bw = width - bx; ++ else ++ width = bw - bx; ++ + /* Left is a positive number or zero therefore monitors with zero width are excluded */ +- for (int i = 0; i < num; i++) { ++ for (int i = 0; i < cnt; i++) { + if (rects[i].width > left) { + monitor_t *mon = monitor_new( + rects[i].x + left, +@@ -598,7 +627,7 @@ get_randr_monitors (void) + { + xcb_randr_get_screen_resources_current_reply_t *rres_reply; + xcb_randr_output_t *outputs; +- int num, valid = 0; ++ int i, j, num, valid = 0; + + rres_reply = xcb_randr_get_screen_resources_current_reply(c, + xcb_randr_get_screen_resources_current(c, scr->root), NULL); +@@ -621,7 +650,7 @@ get_randr_monitors (void) + xcb_rectangle_t rects[num]; + + /* Get all outputs */ +- for (int i = 0; i < num; i++) { ++ for (i = 0; i < num; i++) { + xcb_randr_get_output_info_reply_t *oi_reply; + xcb_randr_get_crtc_info_reply_t *ci_reply; + +@@ -657,11 +686,11 @@ get_randr_monitors (void) + free(rres_reply); + + /* Check for clones and inactive outputs */ +- for (int i = 0; i < num; i++) { ++ for (i = 0; i < num; i++) { + if (rects[i].width == 0) + continue; + +- for (int j = 0; j < num; j++) { ++ for (j = 0; j < num; j++) { + /* Does I countain J ? */ + + if (i != j && rects[j].width) { +@@ -679,7 +708,20 @@ get_randr_monitors (void) + return; + } + ++ /* Use allocated array to pass to monitor_create_chain, the dynamic will out of scope */ ++ xcb_rectangle_t *r = malloc(valid * sizeof(xcb_rectangle_t)); ++ if (!r) { ++ fprintf(stderr, "Malloc failed!\n"); ++ exit(EXIT_FAILURE); ++ } ++ ++ /* Copy only used monitors */ ++ for (i = j = 0; i < num && j < valid; i++) ++ if (rects[i].width) ++ memcpy(&r[j++], &rects[i], sizeof(xcb_rectangle_t)); ++ + monitor_create_chain(rects, num); ++ free(r); + } + + void +@@ -695,7 +737,11 @@ get_xinerama_monitors (void) + iter = xcb_xinerama_query_screens_screen_info_iterator(xqs_reply); + screens = iter.rem; + +- xcb_rectangle_t rects[screens]; ++ xcb_rectangle_t *rects = malloc(screens * sizeof(xcb_rectangle_t)); ++ if (!rects) { ++ fprintf(stderr, "Malloc failed!\n"); ++ exit(EXIT_FAILURE); ++ } + + /* Fetch all the screens first */ + for (int i = 0; iter.rem; i++) { +@@ -709,6 +755,7 @@ get_xinerama_monitors (void) + free(xqs_reply); + + monitor_create_chain(rects, screens); ++ free(rects); + } + + xcb_visualid_t +@@ -755,10 +802,6 @@ xconn (void) + void + init (void) + { +- /* If I fits I sits */ +- if (bw < 0) +- bw = scr->width_in_pixels - bx; +- + /* Load the fonts */ + main_font = font_load(mfont ? mfont : "fixed"); + if (!main_font) +@@ -801,9 +844,14 @@ init (void) + } + } + +- if (!monhead) ++ if (!monhead) { ++ /* If I fits I sits */ ++ if (bw < 0) ++ bw = scr->width_in_pixels - bx; ++ + /* If no RandR outputs or Xinerama screens, fall back to using whole screen */ + monhead = monitor_new(0, 0, bw, scr->height_in_pixels); ++ } + + if (!monhead) + exit(EXIT_FAILURE); +@@ -921,6 +969,44 @@ parse_geometry_string (char *str, int *tmp) + return true; + } + ++bool ++parse_monitor_string (char *str) ++{ ++ char *p = str; ++ int i = 0, j; ++ ++ if (!str || !*str) ++ return false; ++ ++ while (*p) { ++ /* Skip separator */ ++ if (*p == ':' || *p == ',') ++ if (!*++p) ++ break; ++ /* A digit must follow */ ++ if (!isdigit(*p)) { ++ fprintf(stderr, "Invalid monitor specified\n"); ++ return false; ++ } ++ /* Try to parse the number */ ++ errno = 0; ++ j = strtoul(p, &p, 10); ++ if (errno || j >= MONITORS_MAX) { ++ fprintf(stderr, "Monitor value out of range\n"); ++ return false; ++ } ++ ++ if (j >= MONITORS_MAX || j < 0) { ++ fprintf(stderr, "Invalid monitor specified: %d\n", j); ++ continue; ++ } ++ mons |= 1 << j; ++ monlist[nmons++] = j; ++ } ++ ++ return true; ++} ++ + void + parse_font_list (char *str) + { +@@ -968,12 +1054,13 @@ main (int argc, char **argv) + ugc = fgc; + + char ch; +- while ((ch = getopt(argc, argv, "hg:bdf:a:pu:B:F:")) != -1) { ++ while ((ch = getopt(argc, argv, "hg:m:bdf:a:pu:B:F:")) != -1) { + switch (ch) { + case 'h': +- printf ("usage: %s [-h | -g | -b | -d | -f | -a | -p | -u | -B | -F]\n" ++ printf ("usage: %s [-h | -g | -m | -b | -d | -f | -a | -p | -u | -B | -F]\n" + "\t-h Show this help\n" + "\t-g Set the bar geometry {width}x{height})\n" ++ "\t-m Set monitors to use and in what order {0:2:1...}\n" + "\t-b Put bar at the bottom of the screen\n" + "\t-d Force docking (use this if your WM isn't EWMH compliant)\n" + "\t-f Bar font list, comma separated\n" +@@ -983,6 +1070,7 @@ main (int argc, char **argv) + "\t-F Set foreground color in #AARRGGBB\n", argv[0]); + exit (EXIT_SUCCESS); + case 'g': (void)parse_geometry_string(optarg, geom_v); break; ++ case 'm': (void)parse_monitor_string(optarg); break; + case 'p': permanent = true; break; + case 'b': topbar = false; break; + case 'd': dock = true; break; +@@ -998,12 +1086,6 @@ main (int argc, char **argv) + bh = geom_v[1]; + bx = geom_v[2]; + +- /* Check the geometry */ +- if (bx >= scr->width_in_pixels || bx + bw > scr->width_in_pixels) { +- fprintf(stderr, "The geometry specified doesn't fit the screen!\n"); +- return EXIT_FAILURE; +- } +- + /* Do the heavy lifting */ + init(); + /* Get the fd to Xserver */ diff --git a/desktop/bar/slack-desc b/desktop/bar/slack-desc new file mode 100644 index 0000000000..4a206cf45d --- /dev/null +++ b/desktop/bar/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. +# Line up the first '|' above the ':' following the base package name, and +# the '|' on the right side marks the last column you can put a character in. +# You must make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':' except on otherwise blank lines. + + |-----handy-ruler------------------------------------------------------| +bar: bar (lightweight bar based on XCB) +bar: +bar: bar - bar ain't recursive +bar: +bar: bar is a lightweight bar entirely based on XCB. Provides full UTF-8 +bar: support, basic formatting, RandR and Xinerama support and EWMH +bar: compliance without wasting your precious memory. +bar: +bar: Homepage: https://github.com/LemonBoy/bar +bar: +bar: |