scripts

various script and utils
git clone git://z3bra.org/scripts
Log | Files | Refs

commit b8339904da2b7f4c4be81dc822d8ee879c66ab4f
parent fe4d70f9e802ea8401d7d71401700bc5ffeebfcf
Author: z3bra <willyatmailoodotorg>
Date:   Tue Nov  3 01:09:43 +0100

changed bars position

Diffstat:
bars | 25+++++++++++++++++++++++++
beepop | 19++++++++-----------
human | 130-------------------------------------------------------------------------------
mailbar | 21+++++++++++++--------
volumebar | 9---------
5 files changed, 46 insertions(+), 158 deletions(-)
diff --git a/bars b/bars @@ -0,0 +1,25 @@ +#!/bin/sh + +. $HOME/.wmrc +COL2="%{B#66ffffff}" +COL1="%{B#66000000}" + +START=$COL1 +SEP=$COL2 +END=%{B-} +CHAR1=" " +CHAR2=" " +SIZE=20 +export SIZE CHAR1 CHAR2 START END SEP + +mailbar & + +while :; do + mkb $(volume) + sleep 1 +done | lemonbar -d -g 114x7+1306+40 & + +while :; do + mkb $(mpc | sed '2s/.*(\([0-9]\+\)%.*/\1/p;d') + sleep 1 +done | lemonbar -d -g 114x7+1306+60 & diff --git a/beepop b/beepop @@ -10,8 +10,10 @@ default_geometry() { width=256 height=28 - offy=32 - offx=$(( x - $width )) + offy=10 + offx=20 + #offy=64 + #offx=$(( x - $width )) echo "${width}x${height}+${offx}+${offy}" } @@ -20,22 +22,17 @@ FIFO=/tmp/beepop.fifo GEOM=$(default_geometry) SLEEP=3 -# bar options -ICON='-*-stlarch-medium-r-*-*-10-*-*-*-*-*-*-*' -FONT='-*-codingfonttobi1-medium-r-*--12-90-96-96-c-70-iso8859-1' -BG="#00000000" -FG="#ffffffff" -HL="%{F#ff666666}" - case $(basename $0) in beepop) test -p $FIFO || mkfifo $FIFO tail -f $FIFO | while read LINE; do + . $HOME/.wmrc ( - echo "%{r}$LINE ${HL} " + + echo "%{l}%{F${HL}} %{F-}$LINE" sleep $SLEEP - ) | lemonbar -d -g "$GEOM" -f $FONT -f $ICON -B $BG -F $FG + ) | lemonbar -d -g "$GEOM" -f "$FONT" -f "$ICON" -B "#00000000" -F "$FG" done ;; popup) diff --git a/human b/human @@ -1,130 +0,0 @@ -#!/usr/bin/tcc -run -/* - * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - * Version 2, December 2004 - * - * Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> - * - * Everyone is permitted to copy and distribute verbatim or modified - * copies of this license document, and changing it is allowed as double - * as the name is changed. - * - * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - * TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - * - * 0. You just DO WHAT THE FUCK YOU WANT TO. - * - */ - -#include <err.h> -#include <stdio.h> -#include <stdlib.h> -#include <getopt.h> -#include <limits.h> - -#define TERA 1099511627776 -#define GIGA 1073741824 -#define MEGA 1048576 -#define KILO 1024 - -#define DEFAULT_SCALE 0 - -/* dumb user is dumb.. */ -void usage (char *progname) -{ - printf("usage: %s [-hkmgt] <number>\n", progname); - return; /* void */ -} - -/* - * calculate a power of number - * disclaimers: return no more than a "long" so use wisely... - * - */ -long power (long number, int pow) -{ - return pow > 0 ? number * power(number, pow - 1) : number; -} - -/* - * read the environment varaible "SCALE" and returns its value. - * returns DEFAULT_SCALE if it does not return a number. - * - */ -int getscale() -{ - /* would you rather use getenv() twice ? or allocate a pointer ? */ - char *scale = NULL; - scale = getenv("SCALE"); - - /* in atoi, we trust. maybe. */ - return scale ? atoi(scale) : DEFAULT_SCALE; -} - -/* - * calculate the best factorization for a number, depending on its value. - * actual max factorisation is 1024^3 (TiB) - * - */ -char factorize (double number) -{ - return number >= TERA ? 'T' : - number >= GIGA ? 'G' : - number >= MEGA ? 'M' : - number >= KILO ? 'K' : - 0; -} - -/* - * calculate a human-readable version of the given number, depending of the - * factorisation level given. - * - */ -double humanize (double number, char factor) -{ - int pow = 0; - - /* cascading switch. note a lack of "break" statements */ - switch (factor) { - case 'T' : pow++; - case 'G' : pow++; - case 'M' : pow++; - case 'K' : break; - default : return number; - } - - /* return the number divided by the correct factorization level */ - return number /= power(1024, pow); -} - -int main (int argc, char **argv) -{ - char ch, fac = 0; - double number = 0; - - /* only switches are use to force factorization */ - while ((ch = getopt(argc, argv, "hkmgt")) != -1) { - switch (ch) { - case 'h': usage(argv[0]); exit(0); break; - case 't': fac ='T'; break; - case 'g': fac ='G'; break; - case 'm': fac ='M'; break; - case 'k': fac ='K'; break; - } - } - - /* get the number. if there is not, strtold will return 0 */ - number = strtold(argv[argc - 1], NULL); - - if (number <= 0) { - errx(EXIT_FAILURE, "I ain't gonna do it. Deal with it."); - } - - /* use explicit factorization. otherwise, guess the best one */ - fac = fac > 0 ? fac : factorize(number); - - /* actually print the result, isn't that what we're here for after all ? */ - printf("%.*f%c\n", getscale(), humanize(number, fac), fac); - - return 0; -} diff --git a/mailbar b/mailbar @@ -3,10 +3,10 @@ MAILDIR=$HOME/var/mail MAILBOX='inbox crux lobsters' -C1=%{F#ffffffff} -C2=%{F#ff666666} -F1='-windows-codingfonttobi1-medium-r-normal--12-90-96-96-c-70-iso8859-1' -F2='-misc-stlarch-medium-r-normal--10-100-75-75-c-80-iso10646-1' +. $HOME/.wmrc + +COL1="%{F$HL}" +COL2="%{F$FG}" mailcount() { case $1 in @@ -18,7 +18,7 @@ mailcount() { COUNT=$(fcount $DIR) - printf '%s%s%s %s%d%s\n' "$C1" "%{A:$1:}" "$CHAR" "$C2" "$COUNT" "%{A}" + printf '%s%s%s %s%d%s\n' "$COL1" "%{A:$1:}" "$CHAR" "$COL2" "$COUNT" "%{A}" } formatbar() { @@ -34,12 +34,17 @@ showtitles() { find $MAILDIR -type d -name $BOX \ | xargs -I% grep -r '^Subject: ' %/new \ | cut -d\ -f2- \ - | ifne xmessage -center -file - & - compton-trans -n xmessage -O 0.8 + | xmessage -file - & + done +} + +openbox() { + while read BOX; do + urxvt -e mutt -f $(find $MAILDIR -type d -name $BOX) & done } while :; do formatbar sleep 5 -done | lemonbar -d -B"#00000000" -f"$F1" -f"$F2" -g128x32+1312 | showtitles +done | lemonbar -d -B"#00000000" -f"$FONT" -f"$ICON" -g130x32+1300 | openbox diff --git a/volumebar b/volumebar @@ -1,9 +0,0 @@ -#!/bin/sh - -C1='%{F#ffffffff}|' -C2='%{F#ff333333}|' -C3='%{F#ffcc6464}|' - -test "$(volume -s)" = "off" && C1="$C3" - -volume | SIZE=24 CHAR1=$C1 CHAR2=$C2 mkb