scripts

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

commit 6bfdc1770207dd0b0ac3fa086f0a4b21c2315205
parent df55668cf1e01a503897f84b9544fbb861206050
Author: z3bra <contactatz3bradotorg>
Date:   Mon Dec  5 17:12:08 +0100

Bunch of unrelated changes, not worth detailling

Diffstat:
cdump | 2+-
dm | 2+-
fadevid | 8+++++---
focus | 8++++----
maillist | 3++-
mkbar | 2+-
prtup | 2+-
pulsar | 2+-
q3dl | 6+++---
radio | 5+++--
record | 6++++--
square | 9++++++---
sshmenu | 2+-
sslget | 3+--
syscat | 8+-------
takeoffdir | 4+---
tile | 4++--
uplaylist | 5++---
ushot | 4++--
vroum | 13+++++++++----
wrapbar | 2+-
yawee | 16+++++-----------
ydl | 10+---------
23 files changed, 58 insertions(+), 68 deletions(-)
diff --git a/cdump b/cdump @@ -1,3 +1,3 @@ #!/bin/sh -xrdb -query | grep -P '^\*color[0-9]*:' | tr -d '\t' | cut -d: -f2 | hex2col +xrdb -query | grep -P '^\*color[0-9]*:' | tr -d '\t' | cut -d: -f2 | hex2col -t diff --git a/dm b/dm @@ -28,7 +28,7 @@ done shift $((OPTIND - 1)) case $# in - 0) usage; exit 1;; + 0) list; exit 0;; 1) method=a;; *) method=A;; esac diff --git a/fadevid b/fadevid @@ -3,9 +3,11 @@ # fuck you, ffmpeg banner exec 2>/dev/null -OUTDIR=$PWD/faded +#FONT="$HOME/.fonts/bitmicro.ttf" +FONT="$HOME/.fonts/SGK001.ttf" +OUTDIR="./faded" FADELEN=30 -FONTPARAM="fontfile=$HOME/tmp/bitmicro.ttf:shadowx=4:shadowy=4:fontcolor=white:fontsize=28:x=w-tw-28:y=h-th-28" +FONTPARAM="fontfile=$FONT:shadowx=4:shadowy=4:fontcolor=white:fontsize=28:x=w-tw-28:y=h-th-28" getname() { echo $1 | sed 's/\(.*\)\.[^.]*/\L\1/' @@ -22,7 +24,7 @@ for IN in $@; do NBFRAME=$(getframes) VFILTER="fade=in:0:$FADELEN" VFILTER="$VFILTER,fade=out:$((NBFRAME - FADELEN)):$FADELEN" - VFILTER="$VFILTER,drawtext=$FONTPARAM:text=$(getname $IN)" + #VFILTER="$VFILTER,drawtext=$FONTPARAM:text=$(getname $IN)" ffmpeg -i $IN -vf "$VFILTER" -b:v 5M -y $OUTDIR/$IN printf "OK\n" done diff --git a/focus b/focus @@ -12,11 +12,11 @@ usage() { exit 1 } -next_east() { +next_west() { lsw | xargs wattr xi | sort -nr | sed "0,/$CUR/d" | sed "1s/^[0-9]* //p;d" } -next_west() { +next_east() { lsw | xargs wattr xi | sort -n | sed "0,/$CUR/d" | sed "1s/^[0-9]* //p;d" } @@ -29,8 +29,8 @@ next_south() { } case $1 in - h|a|east|left) vroum $(next_east) 2>/dev/null ;; + h|a|west|left) vroum $(next_west) 2>/dev/null ;; j|s|south|down) vroum $(next_south) 2>/dev/null ;; k|w|north|up) vroum $(next_north) 2>/dev/null ;; - l|d|west|right) vroum $(next_west) 2>/dev/null ;; + l|d|east|right) vroum $(next_east) 2>/dev/null ;; esac diff --git a/maillist b/maillist @@ -2,7 +2,7 @@ INBOX=$HOME/data/mail/inbox MBASE=$HOME/data/mail -LISTS='crux lobsters pcc' +LISTS='crux lobsters pcc suckless' crawl() { # uses the X-BeenThere header set by maillist to check from @@ -11,6 +11,7 @@ crawl() { crux) REGEX='^X-BeenThere:.*crux@lists.crux.nu' ;; lobsters) REGEX='^X-BeenThere:.*lobsters-[a-zA-Z0-9]*@lobste.rs' ;; pcc) REGEX='^X-BeenThere:.*pcc@lists.ludd.ltu.se' ;; + suckless) REGEX='^X-Original-To:.*@suckless.org' ;; esac find $INBOX -type f -exec grep -liP "$REGEX" {} + diff --git a/mkbar b/mkbar @@ -96,7 +96,7 @@ nettrafic() { esac trafic=$(awk "/$(netint)/ {print \$$col}" /proc/net/dev) - echo $(SCALE=2 ~/bin/human $trafic) + echo $(SCALE=2 human $trafic) } netint() { diff --git a/prtup b/prtup @@ -57,7 +57,7 @@ update_pkgfile() { # create it otherwise else - sed -i "/version/a\ + sed -i "/^version=/a\ sversion=$sversion" Pkgfile fi } diff --git a/pulsar b/pulsar @@ -6,7 +6,7 @@ while :; do COLORS=$(tac < ~/.colors | cat - ~/.colors | tr -d '#') for c in $COLORS; do CUR=$(pfw) - test "`wattr wh $CUR`" != "`wattr wh $(lsw -r)`" && chwb -c $c $CUR + wattr $CUR && test "`wattr wh $CUR`" != "`wattr wh $(lsw -r)`" && chwb -c $c $CUR sleep $FREQ done done diff --git a/q3dl b/q3dl @@ -8,15 +8,15 @@ R="\033[1;31m" G="\033[1;32m" N="\033[0m" -echo -ne "Fetching map ${W}${map}.pk3 ${N}.. " +printf "Fetching map ${W}${map}.pk3 ${N}.. " curl -s "${q3df}/${map}.pk3" > /tmp/q3map.zip if unzip -p /tmp/q3map.zip >/dev/null 2>&1 ; then mv /tmp/q3map.zip ~/.q3a/baseq3/${map}.pk3 - echo -e "[${G}DONE${N}]" + printf "[${G}DONE${N}]\n" else - echo -e "[${R}FAIL${N}]" + printf "[${R}FAIL${N}]\n" rm /tmp/q3map.zip fi diff --git a/radio b/radio @@ -1,5 +1,6 @@ #!/bin/sh -STREAM=${1:-http://radio.2f30.org:8000/live.ogg} +STREAM=${1:-http://radio.2f30.org:8000/live.mp3} -curl -s $STREAM | play -q - 2>/dev/null +#curl -sL $STREAM | play -q -t mp3 - #2>/dev/null +mplayer -nocache ${STREAM} diff --git a/record b/record @@ -3,6 +3,7 @@ PIDNAME=recorder FRAMERATE=25 RES=$(wattr wh `lsw -r` | tr \ x) +SND="-an" # no sound by default usage() { echo "usage: $(basename $0) [-fk] <filename>" >&2 @@ -10,11 +11,12 @@ usage() { } case $1 in + -s) SND="-f alsa -i hw:0 -c:v pcm_s16le"; shift 1 ;; -f) FRAMERATE=50; shift 1 ;; -k) kill $(pidof -s $PIDNAME); exit 0 ;; esac -test -n "$1" && WEBM=$1 || usage +test -n "$1" || usage echo Framerate: $FRAMERATE -exec -a $PIDNAME ffmpeg -f x11grab -s $RES -an -r $FRAMERATE -i :0.0 -c:v libvpx -b:v 5M -crf 10 -quality realtime -y -loglevel quiet $1 +ffmpeg -f x11grab -s $RES -r $FRAMERATE -i :0.0 ${SND} -c:v libvpx -b:v 5M -crf 10 -quality realtime -threads 0 -y $1 diff --git a/square b/square @@ -1,8 +1,11 @@ #!/bin/sh -CHAR=${1:-██} +CHAR=${1:-XXXX} echo -for i in `seq 0 7`; do printf " [0;3${i}m${CHAR}"; done; echo -for i in `seq 0 7`; do printf " [1;3${i}m${CHAR}"; done; echo echo +#for i in `seq 0 7`; do printf " [0;3${i}m${CHAR}"; done; echo +#for i in `seq 0 7`; do printf " [1;3${i}m${CHAR}"; done; echo +for i in `seq 0 7`; do + printf " [0;3${i}m${CHAR}[1;3${i}m${CHAR}\n" +done diff --git a/sshmenu b/sshmenu @@ -4,6 +4,6 @@ gethosts() { sed "/Host/s/Host //p;d" $HOME/.ssh/config | grep -v '*' | cut -d\ -f1 } -TARGET=$(gethosts | slmenu -l 8 -p "host:") +TARGET=$(gethosts | pick) test -n "$TARGET" && ssh $TARGET diff --git a/sslget b/sslget @@ -3,4 +3,4 @@ # retrieve SSL certificate of a website # it assumes 443 to be the default SSL port -echo | openssl s_client -connect $@:443 2>&1| sed '/BEGIN CERT/,/END CERT/p;d'- \ No newline at end of file +echo | openssl s_client -connect $@:443 2>&1| sed '/BEGIN CERT/,/END CERT/p;d' diff --git a/syscat b/syscat @@ -11,11 +11,7 @@ cpuinfo() { } wmname() { - xprop -root WM_NAME | cut -d\" -f2 -} - -fontname() { - xrdb -query|sed "/^*font/s/^[^-]*-\*-\([^-]*\)-.*$/\1/p;d" + test -n "$DISPLAY" && xprop -root WM_NAME | cut -d\" -f2 || tty } cat <<EOF @@ -29,5 +25,3 @@ $(c)PKGCOUNT $(d)$(pkginfo -i|wc -l) $(c)PROC $(d)$(cpu -p) $(c)MEMORY $(d)$(memory -u|xargs human) EOF -#$(c)FONT $(d)$(fontname) -n diff --git a/takeoffdir b/takeoffdir @@ -5,6 +5,4 @@ TAKEOFF_DIR=/tmp/takeoff mkdir -p $TAKEOFF_DIR # file either created or modified -wendy -m 136 -f $TAKEOFF_DIR -v | while read ev file; do - $HOME/bin/autoup "$file" -done +wendy -m 136 -f $TAKEOFF_DIR sh -c 'autoup $WENDY_INODE' diff --git a/tile b/tile @@ -29,12 +29,12 @@ MAX=$(lsw|grep -v $PFW|wc -l) # calculate usable screen size (without borders and gaps) SW=$((SW - GAP - 2*BW)) -SH=$((SH - GAP - 2*BW)) +SH=$((SH - GAP)) test "$MAX" -eq 0 && wtp $GAP $GAP $((SW - GAP)) $((SH - GAP)) $PFW && exit # put current window in master area -wtp $GAP $GAP $((MASTER - GAP - 2*BW)) $((SH - GAP)) $PFW +wtp $GAP $GAP $((MASTER - GAP - 2*BW)) $((SH - GAP - 2*BW)) $PFW # and now, stack up all remaining windows on the right Y=$((0 + GAP)) diff --git a/uplaylist b/uplaylist @@ -1,6 +1,5 @@ #!/bin/sh # # play a youtube playlist with player -curl -s "$1" | cut -d'"' -f2 | grep 'watch?v='| sort | uniq | - cut -d\& -f1 | sed 's@^@http://www.youtube.com@' | - xargs -I% sh -c 'mplayer -really-quiet -cache 1024 "$(youtube-dl -g %)"' + +curl -s $1 | grep -oP '/watch\?v=[^";]*[";]' | cut -d\" -f1 | sed 's@^@https://youtube.com@' | xargs -I% sh -c "youtube-dl -g '%'|tail -n1|xargs curl|mplayer -nocache -" diff --git a/ushot b/ushot @@ -2,5 +2,5 @@ FILE=${1:-/dev/null} -xscreenshot | ff2png | tee $FILE | imgurup | tr -d'\n' | xsel -i -img $(xsel -o) +xscreenshot | ff2png | tee $FILE | pio | tee /dev/tty | xsel -i +curl -s $(xsel -o) | png2ff | lel -a -w 720 -h 520 diff --git a/vroum b/vroum @@ -3,12 +3,12 @@ # z3bra - 2014 (c) wtfpl # window focus wrapper that sets borders and can focus next/previous window -BW=${BW:-4} # border width +BW=${BW:-2} # border width ACTIVE=${ACTIVE:-0xffffff} # active border color INACTIVE=${INACTIVE:-0x323232} # inactive border color # get current window id -CUR=$(pfw) +CUR=$(pfw || echo NONE) usage() { echo "usage: $(basename $0) <next|prev|wid>" >&2 @@ -44,7 +44,10 @@ case $1 in prev) wid=$(lsw|grep -v $CUR|sed '$ p;d') ;; - 0x*) wattr $1 && wid=$1 ;; + 0x*) + wattr $1 && wid=$1 + #test "$wid" = "$CUR" && exit;; + ;; *) usage ;; esac @@ -54,5 +57,7 @@ test -z "$wid" && { echo "$(basename $0): no window to focus" >&2; exit 1; } wtf $wid # set focus on it chwso -r $wid # raise windows setborder inactive $CUR # set inactive border on current window -#setborder active $wid # activate the new window +setborder active $wid # activate the new window chwb -s $BW $wid + +exit 0 diff --git a/wrapbar b/wrapbar @@ -16,5 +16,5 @@ echo | bar -p -B\#ff4c4c4c -g $((w - 26))x26+13+13 & sleep 0.1 # and the actual bar while :; do - ~/bin/mkbar + mkbar done | bar -f "$icon,$font" -B\#ff1d1d1d -g $((w - 30))x22+15+15 diff --git a/yawee b/yawee @@ -14,21 +14,15 @@ while IFS=: read ev wid; do 16) wattr o $wid || corner md $wid ;; - # mapping requests - 19) wattr o $wid || { - vroum $wid & - #test $(lsw|wc -l) -eq 1 && hsetroot -fill $BLUR - } + # focus next window when deleting focused window + 18) wattr $(pfw) || vroum prev 2>/dev/null ;; - # focus next window when deleting focused window - 18) wattr $(pfw) || { - vroum prev 2>/dev/null - #test -z "$(lsw)" && hsetroot -fill $WALL - } + # mapping requests + 19) wattr o $wid || vroum $wid & ;; # entering window - 7) wattr o $wid || vroum $wid ;; + 7) wattr o $wid || wtf $wid ;; esac done diff --git a/ydl b/ydl @@ -4,8 +4,6 @@ # download the audio track of the first result of a youtube search # and add it to MPD library (will end up with a .mp3, for tags) -MPD_DOWNLOAD_DIR=~/usr/msc/youtube/ - usage() { echo "`basename $0` [-h] <query>" } @@ -45,13 +43,7 @@ if test -z "$uri"; then exit 1 fi -# change to target dir if it exists -test -d $MPD_DOWNLOAD_DIR && cd $MPD_DOWNLOAD_DIR - # download and extract audio track -youtube-dl -q -x -o '%(title)s.%(ext)s' "$uri" - -# update mpd lib if running -pgrep mpd >/dev/null 2>&1&& mpc -q update +youtube-dl -q -x --audio-format mp3 -o '%(title)s.%(ext)s' "$uri" exit 0