tMerge branch 'master' of z3bra.org:scripts - scripts - various script and utils
(HTM) git clone git://z3bra.org/scripts
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) commit e4d2736ef249b55bab8dc8ae7210661bf190597e
(DIR) parent cc749062d567281112acce98d419c0aeb5424f8a
(HTM) Author: z3bra <willy@mailoo.org>
Date: Thu, 23 Oct 2014 16:50:11 +0200
Merge branch 'master' of z3bra.org:scripts
Diffstat:
M cdump | 4 ++--
M dm | 3 ++-
M imgurup | 2 +-
M instagram | 13 +++++--------
M menu | 5 ++---
M mkbar | 38 ++++++++++++++++----------------
M popup | 9 ++++-----
M prtmk | 6 ++++++
M prtup | 9 ++++++++-
A setwall | 18 ++++++++++++++++++
A todo | 32 +++++++++++++++++++++++++++++++
A wrapbar | 20 ++++++++++++++++++++
A xwait | 30 ++++++++++++++++++++++++++++++
13 files changed, 149 insertions(+), 40 deletions(-)
---
(DIR) diff --git a/cdump b/cdump
t@@ -1,7 +1,7 @@
#!/bin/sh
FILE=$HOME/etc/Xresources
-FILE=$HOME/etc/theme/bow
+FILE=$HOME/etc/theme/flashy
for NUM in $(seq 0 7); do
CN=$(grep "^\*color${NUM}:" $FILE | cut -d':' -f2 | tr -d ' ')
t@@ -17,7 +17,7 @@ for NUM in $(seq 0 7); do
done
echo
for NUM in $(seq 0 7); do
- CN=$(grep "^\*color${NUM}:" $FILE | cut -d':' -f2 | tr -d ' ')
+ CN=$(grep "^\*color$((${NUM} + 8)):" $FILE | cut -d':' -f2 | tr -d ' ')
printf "\e[1;3${NUM}m%s " $CN
done
printf "\e[0m\n"
(DIR) diff --git a/dm b/dm
t@@ -4,6 +4,7 @@
# Create/list/attach/detach applications using dtach
sockdir=~/var/run
+keyseq=
list() {
# change colors, for fun!
t@@ -35,4 +36,4 @@ shift
socket="${sockdir}/${name}"
-dtach -${method} ${socket} -r winch $@
+dtach -${method} ${socket} -e ${keyseq} -r winch $@
(DIR) diff --git a/imgurup b/imgurup
t@@ -25,7 +25,7 @@ for IMG in "$@"; do
URL=$(echo $RESP | sed 's|.*<original_image>\(.*\)</original_image>.*|\1|')
DELETEURL=$(echo $RESP | sed 's|.*<delete_page>\(.*\)</delete_page>.*|\1|')
- echo $URL" | tee $LOG | $CLIP
+ echo "$URL" | tee $LOG | $CLIP
echo "$DELETEURL" >> $LOG
echo "$URL"
done
(DIR) diff --git a/instagram b/instagram
t@@ -9,7 +9,6 @@
VIEWER=meh
EXEC_UPLOAD=~/bin/imgurup
-SSHOT_DIR=$PWD
WMNAME=`xprop -root WM_NAME|cut -d\" -f2`
upload() {
t@@ -33,7 +32,6 @@ Configuration:
You can set variables here, so that they will overide the default ones:
IMAGE_DIR : Where images are stored
- SSHOT_DIR : Where to save your shots
EXEC_UPLOAD : Path to the script/program used to upload your shot
SHBLAH
}
t@@ -43,17 +41,16 @@ headshot() {
xdpyinfo -ext XINERAMA | sed 's/^ head #//p' |
while IFS=' :x@,' read i w h x y; do
if [[ $1 = "$i" ]]; then
- import -window $WINDOW -crop ${w}x${h}+${x}+${y} $SSHOT_DIR/$OUTPUT
+ import -window $WINDOW -crop ${w}x${h}+${x}+${y} $OUTPUT
fi
done
}
[[ "$1" = "--help" ]] && usage && exit 0
-while getopts ":htmuwd:gs:" opt; do
+while getopts ":htmuwgs:" opt; do
case $opt in
t) THUMB=1 ;;
- d) SSHOT_DIR=$OPTARG ;;
s) SCREEN=$OPTARG ;;
u) UPLOAD=1 ;;
w) WINDOW=`xprop|grep 'window id'|cut -d\ -f7`;;
t@@ -70,12 +67,12 @@ test -z "$WINDOW" && WINDOW='root'
if [ -n "$SCREEN" ]; then
headshot $SCREEN
else
- import -window ${WINDOW} $SSHOT_DIR/$OUTPUT
+ import -window ${WINDOW} $OUTPUT
fi
-test -n "$THUMB" && import -window ${WINDOW} -thumbnail 25% $SSHOT_DIR/thumb-${OUTPUT}
+test -n "$THUMB" && import -window ${WINDOW} -thumbnail 25% thumb-$(basename ${OUTPUT})
-$VIEWER $SSHOT_DIR/$OUTPUT
+$VIEWER $OUTPUT
test "$UPLOAD" = "1" && upload ${OUTPUT}
(DIR) diff --git a/menu b/menu
t@@ -12,8 +12,7 @@ X=`expr ${w} - 120 - 10`
Y=`expr ${h} - 120 - 20`
thingmenu -g 120x120 \
- "pop a terminal" "urxvt" \
- "browse the web" "dwb" \
- "view a pdf" "mupdf || zathura" \
"play a game" "steam" \
+ "pop a term" "urxvt" \
+ "surf the web" "dwb" \
"restart 2bwm" "pkill 2bwm; 2bwm" 2> /dev/null
(DIR) diff --git a/mkbar b/mkbar
t@@ -16,20 +16,20 @@
# configuration variables
refresh_rate=0.75 # how often will the bar update
datefmt="%d %b %H:%M" # date time format
-maildir=~/var/mail/INBOX/new # where do new mails arrive ?
+maildir=~/var/mail/inbox/new # where do new mails arrive ?
alsactl=Master # which alsa channel to display
#battery=BAT0 # battery index
# find battery name in a smart way
battery=$(ls /sys/class/power_supply | grep BAT)
barch=''
-barfg='%{F#ff666666}'
-barmg='%{F#ff2288cc}'
+barfg='%{F#ff888888}'
+barmg='%{F#ffffffff}'
barbg='%{F#00888888}'
-grpfg='%{F#ff111111} '
+grpfg='%{F#ffffff00} '
grpmg='%{F#ff2288cc} '
-grpbg='%{F#ffbbbbbb} '
+grpbg='%{F#ffffffff} '
# no need to modify anything else here
t@@ -75,10 +75,16 @@ netstate() {
}
netip() {
- # local ip
- #ip addr show $(netint) | grep 'inet ' | awk '{print $2}'
- # extern ip
- curl http://canihazip.com/s
+ case $1 in
+ local)
+ # local ip
+ ip addr show $(netint) | grep 'inet ' | awk '{print $2}'
+ ;;
+ *)
+ # extern ip
+ curl http://canihazip.com/s
+ ;;
+ esac
}
nettrafic() {
t@@ -165,9 +171,9 @@ makebar() {
for v in $(seq 0 $((max - 1))); do
if [ "$v" -lt "$cur" ]; then
- bar="${bar}${barfg}${barch}"
+ bar="${bar}${barmg}${barch}"
else
- bar="${bar}${barbg}${barch}"
+ bar="${bar}${barfg}${barch}"
fi
done
t@@ -179,14 +185,8 @@ buf="%{l} "
# Set icon depending on the interface that is up
buf="${buf}${barmg} "
-if test "$(netint)" = "eth0"; then
- buf="${buf}${barfg}"
-elif test "$(netint)" = "wlan0"; then
- buf="${buf}${barfg}"
-else
- buf="${buf}${barfg}"
-fi
-buf="$buf $(netstate) "
+buf="${buf}${barfg}"
+buf="$buf $(netip local) "
buf="${buf}${barmg} ${barfg} $(nettrafic down) "
buf="${buf}${barmg} ${barfg} $(nettrafic up) "
(DIR) diff --git a/popup b/popup
t@@ -9,17 +9,16 @@ SLEEP=3
# bar options
font='-*-stlarch-medium-r-*-*-10-*-*-*-*-*-*-*'
font="$font,-*-gohufont-medium-*-*--11-*-*-*-*-*-iso10646-1"
-bg="#ff333333"
+bg="#ff1d1d1d"
fg="#ffffffff"
-hl="#ff6ac0fd"
+hl="#ff2288cc"
IFS=' x' read x y <<< `xrandr | grep '*' | sed 1q | awk '{print $1}'`
width=300
height=30
-offx=$(( x/2 - $width - 74 ))
-offx=1610
-offy=1040
+offx=$(( x - $width - 10 ))
+offy=$(( y - $height - 10 ))
title=""
geom=${width}x${height}+${offx}+${offy}
(DIR) diff --git a/prtmk b/prtmk
t@@ -26,9 +26,14 @@ read -p 'Depends on : ' depends
PORTDIR=$PORTDIR/$name
if test "$version" = "git"; then
+
git_url=$sources
sources=''
+ read -p 'Git commit : ' sversion
+
+ version=git-$(echo $sversion | cut -c-7)
+
PKGFILE=${PKGFILE}-git
PORTDIR=${PORTDIR}-git
else
t@@ -66,6 +71,7 @@ sed \
-e "s__VERSION__$version" \
-e "s__SOURCE__$sources" \
-e "s__GIT_URL__$git_url" \
+ -e "s__GIT_HASH__$sversion" \
-i $PORTDIR/Pkgfile
echo_color 2 OK
(DIR) diff --git a/prtup b/prtup
t@@ -28,6 +28,7 @@ get_version() {
# enter the git directory
if cd $name; then
+ git pull origin master
# get the git hash and its minimized version
version=$(git log --oneline --format="git-%h" | sed 1q)
t@@ -45,7 +46,7 @@ update_pkgfile() {
sed -i "s/^version=.*$/version=$version/" Pkgfile
# update sversion if it exists
- if grep 'sversion' Pkgfile; then
+ if grep -q 'sversion' Pkgfile; then
sed -i "s/^sversion=.*$/sversion=$sversion/" Pkgfile
# create it otherwise
t@@ -65,6 +66,12 @@ main() {
# update Pkgfile accordingly
update_pkgfile
+
+ if [ ! "$1" = "-q" ]; then
+ echo "port : $name"
+ echo "version: $version"
+ echo "commit : $sversion"
+ fi
}
main
(DIR) diff --git a/setwall b/setwall
t@@ -0,0 +1,18 @@
+#!/bin/sh
+
+bgdir="$HOME/usr/img/bg"
+wall="$bgdir/default.jpg"
+
+test -z "$1" && return
+
+# get screen dir
+IFS='x ' read sw sh <<< `xrandr | awk '/*/ {print $1}'`
+
+# get image dimensions (needs two lines because of IFS, no idea why)
+IFS=' ' isize=`identify $1 | awk '{print $3}'`
+IFS='x ' read iw ih <<< `echo $isize`
+
+test $iw -lt $sw && mode='tile' || mode='fill'
+
+test -L $1 && wall=$1 || ln -sf $1 $wall
+hsetroot -${mode} $wall
(DIR) diff --git a/todo b/todo
t@@ -0,0 +1,32 @@
+#!/bin/bash
+#
+# z3bra - (c) wtfpl 2014
+# Manage a todo list.
+# The file is just plain text, with one line per task.
+# This script just provide "shorter" commands to append to the file and display
+# its content. For more complex tasks, use other tools like `sed`.
+
+#Where's the file ?
+TODO=${TODO:-$HOME/.todo}
+
+# List the content of the file with some fancy headers
+list() {
+ test -f $TODO || { echo "nothing to do, enjoy."; exit 0; }
+ echo
+ echo "TODO:"
+ echo "====="
+ echo
+ # WOAH, MUCH CLEVER !
+ cat -n $TODO
+ echo
+}
+
+append() {
+ # append all arguments "as-is" to the file
+ echo "$*" >> $TODO
+}
+
+# append arguments to the file, or print it otherwise
+test -n "$*" && append $* || list
+
+exit 0
(DIR) diff --git a/wrapbar b/wrapbar
t@@ -0,0 +1,20 @@
+#!/bin/sh
+#
+# spawn a status bar
+
+set -e
+
+# get screen size
+IFS='x' read w h <<< "$(xrandr | awk '/\*/ {print $1}')"
+
+icon="-*-stlarch-medium-*-*--10-*-*-*-*-*-*-*"
+font="*-gohufont-medium-*-*--11-*-*-*-*-*-iso10646-1"
+
+# two "useless" bars, for multi borders
+echo | bar -p -B\#ff1d1d1d -g $((w - 20))x32+10+10 & sleep 0.1
+echo | bar -p -B\#ff4c4c4c -g $((w - 26))x26+13+13 & sleep 0.1
+
+# and the actual bar
+while :; do
+ ~/bin/mkbar
+done | bar -f "$icon,$font" -B\#ff1d1d1d -g $((w - 30))x22+15+15 &
(DIR) diff --git a/xwait b/xwait
t@@ -0,0 +1,30 @@
+#!/bin/tcc -run
+
+/*
+ * use it to hold your X session.
+ * You can either compile it, or run it through tcc using it's special shebang,
+ * that's up to you, really.
+ *
+ * echo "exec xwait" >> ~/.xinitrc
+ *
+ */
+
+#include <unistd.h>
+#include <sys/wait.h>
+
+int
+main ( c, v, e )
+ int c;
+ char **v;
+ char **e;
+ {
+ for( ;; )
+ {
+ wait( NULL );
+ sleep( 1 );
+ }
+
+ return 0;
+ }
+
+/* vim: set ft=c: */