tMerge branch 'master' of git:scripts - scripts - various script and utils
(HTM) git clone git://z3bra.org/scripts
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) commit 4d476eae72ab414319cbf895144df077a297d5bf
(DIR) parent 1e6a7dafdc61d7c52fbfabf2eb750da9c9db655d
(HTM) Author: z3bra <willy@mailoo.org>
Date: Mon, 12 May 2014 19:37:04 +0200
Merge branch 'master' of git:scripts
Diffstat:
M cdump | 12 ++++++------
A hmgr | 129 +++++++++++++++++++++++++++++++
M popup | 9 +++++----
M prtmk | 5 ++---
M volume | 1 +
A wrappop | 25 +++++++++++++++++++++++++
6 files changed, 168 insertions(+), 13 deletions(-)
---
(DIR) diff --git a/cdump b/cdump
t@@ -3,20 +3,20 @@
FILE=$HOME/etc/Xresources
for NUM in {0..7}; do
- CN=$(grep "color${NUM}:" $FILE | cut -d':' -f2 | tr -d ' ')
- echo -en "\e[0;3${NUM}m$CN\033[m "
+ CN=$(grep "^\*color${NUM}:" $FILE | cut -d':' -f2 | tr -d ' ')
+ echo -en "\e[0;3${NUM}m$CN\e[m "
done
echo
for NUM in {0..7}; do
- echo -en "\033[0;3${NUM}m▉▉▉▉▉▉▉\033[m "
+ echo -en "\e[0;3${NUM}m▉▉▉▉▉▉▉\e[m "
done
echo
for NUM in {0..7}; do
- echo -en "\033[1;3${NUM}m▉▉▉▉▉▉▉\033[m "
+ echo -en "\e[1;3${NUM}m▉▉▉▉▉▉▉\e[m "
done
echo
for NUM in {0..7}; do
- CN=$(grep "color$((${NUM}+8)):" $FILE| cut -d':' -f2 | tr -d ' ')
- echo -en "\e[1;3${NUM}m$CN\033[m "
+ CN=$(grep "^\*color$((${NUM}+8)):" $FILE| cut -d':' -f2 | tr -d ' ')
+ echo -en "\e[1;3${NUM}m$CN\e[m "
done
echo
(DIR) diff --git a/hmgr b/hmgr
t@@ -0,0 +1,129 @@
+#!/bin/sh
+#
+# z3bra - (c) wtfpl 2014
+# Manage your config.h files on a per program basis. Store defaults and user
+# configs, and restore them easily.
+
+# Directory where configs are saved
+basedir=~/.hmgr.d
+
+# Default names for configs
+default=config.def.h
+
+# How to list files managed by hmgr
+#listcmd='ls -1 --color=auto'
+listcmd='tree -L 1 --noreport'
+
+# Change output colors ?
+color_conf='1;37' # colors for config files
+color_dirs='0;33' # colors for directory names
+
+
+usage() {
+echo "usage: $(basename $0) [-uh] [-l [dir]] [-ni <file>] [-csr <dir>]"
+
+test -z "$1" && return
+
+cat <<EOF
+ -h : help
+ -u : shortcut for -n ${USER}.h
+ -n <name> : deal with file as <name> (defaults to config.def.h)
+ -i <file> : input file to use (defaults to ./config.h)
+ -l [dir] : list currently managed applications/files
+ -c <dir> : check which config is in use
+ -s <dir> : store \`config.h\` to <dir>
+ -r <dir> : restore \`config.h\` from <dir>
+EOF
+}
+
+store() {
+ test -z "$1" && return 1
+ test ! -d ${basedir}/$1 && mkdir ${basedir}/$1
+
+ # Copy from current dir to base directory
+ cp -i ${cin} ${basedir}/$1/${cout}
+}
+
+restore() {
+ test -z "$1" && return 1
+
+ # Copy from base dir to current directory
+ cp ${basedir}/$1/${cout} ${cin}
+}
+
+list() {
+
+ # Go to the base directory
+ cd ${basedir}
+
+ ${listcmd} $1
+}
+
+check() {
+ found=0
+
+ test ! -f ${cin} && echo "cannot find file ${cin}" && exit 1
+
+ for dir in ${basedir}/*; do
+ for file in ${dir}/*; do
+ if diff $file ${cin} >/dev/null; then
+ echo -en "${fgd}`basename ${dir}`${nofg}: "
+ echo -e "${fgh}`basename ${file}`${nofg}"
+ found=1
+ fi
+ done
+ done
+ test ${found} -eq 0 && echo ${cin} is different from stored configs
+}
+
+# No arguments? give usage
+test $# -eq 0 && list && exit 0
+
+# Create $basedir if it does not exists
+test ! -d ${basedir} && mkdir ${basedir}
+
+# Set the default file names
+cin=config.h
+cout=${default}
+list=0
+
+# standardize colors for shell output
+fgd="\e[${color_dirs}m"
+fgh="\e[${color_conf}m"
+nofg="\e[0m"
+
+# change colors, for fun!
+LS_COLORS="di=${color_dirs}:*.h=${color_conf}"
+export LS_COLORS
+
+# Parse options
+while getopts "chi:ln:s:r:u" opt; do
+ case $opt in
+ # Check which config is in use
+ c) check;;
+
+ # Wether to use default config or user config
+ u) cout=${usercfg};;
+ n) cout=${OPTARG};;
+
+ # Change the input file
+ i) cin=$OPTARG;;
+
+ # List currently managed config.h
+ l) list=1; break;;
+
+ # Whether to store or restore a config.h
+ s) store $OPTARG;;
+ r) restore $OPTARG;;
+
+ # WHAAT?!
+ h) usage full; exit 0;;
+ *) usage; exit 1;;
+ esac
+done
+
+# In case we want to list files managed...
+shift $(( OPTIND - 1 ))
+
+# List either the whole dir or a specific one
+test $list -eq 1 && list $1
(DIR) diff --git a/popup b/popup
t@@ -15,9 +15,10 @@ hl="#ff333333"
IFS=' x' read x y <<< `xrandr | grep '*' | sed 1q | awk '{print $1}'`
-width=120
+width=144
height=20
offx=$(( x/2 - $width - 74 ))
+offx=740
offy=10
geom=${width}x${height}+${offx}+${offy}
t@@ -27,8 +28,8 @@ usage() {
}
spawn() {
- prefix='%{F#fffffe00} %{F-}'
- (echo "%{c}${prefix} $@";sleep $SLEEP) | bar -g $geom -f $font -B $bg -F $fg
+ prefix='%{F#fffffe00} %{F-}'
+ (echo "%{l}${prefix} $@";sleep $SLEEP) | bar -g $geom -f $font -B $bg -F $fg
}
loop() {
t@@ -127,6 +128,6 @@ case $1 in
;;
esac
-# can be *REALLY* annoying
+# that beep can be *REALLY* annoying
test -n "$BEEP" && beep -f 1500 -d 20 -l 100
test -n "$LOOP" && loop "$FUNC" || spawn "$TEXT"
(DIR) diff --git a/prtmk b/prtmk
t@@ -17,11 +17,10 @@ test -n "$1" && name=$1 || read -p 'Name : ' name
read -p 'Description : ' description
read -p 'Version : ' version
read -p 'URL : ' url
-read -p 'Maintainer : ' daddy
-read -p 'Depends on : ' depends
read -p 'Source : ' sources
+read -p 'Depends on : ' depends
-source=${source/$name/\$name}
+source=${source//$name/\$name}
source=${source/$version/\$version}
PORTDIR=$PORTDIR/$name
(DIR) diff --git a/volume b/volume
t@@ -18,6 +18,7 @@ test $# -eq 0 && echo "`level` `state`" && exit 0
case $1 in
+) amixer set Master 5%+ >/dev/null;;
-) amixer set Master 5%- >/dev/null;;
+ level|state) $1;;
!) amixer set Master toggle >/dev/null;;
*) amixer set Master $1 >/dev/null;;
esac
(DIR) diff --git a/wrappop b/wrappop
t@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# fifo that we'll use to feed the popups
+test -p /tmp/popup.fifo || mkfifo /tmp/popup.fifo
+
+w=150
+h=20
+x=1930
+y=10
+
+n=-1
+
+# get messages from the fifo
+tail -f /tmp/popup.fifo |
+while IFS= read -r message; do
+ # increment the counter
+ n=$((n + 1))
+
+ # display the popup under the others
+ {
+ ~/bin/popup -g ${w}x${h}+${x}+$((y + (h+y) * n)) $n ${message}
+ # decrement the counter
+ n=$((n - 1))
+ } &
+done