tBunch of unrelated changes, not worth detailling - scripts - various script and utils
(HTM) git clone git://z3bra.org/scripts
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) commit 6bfdc1770207dd0b0ac3fa086f0a4b21c2315205
(DIR) parent df55668cf1e01a503897f84b9544fbb861206050
(HTM) Author: z3bra <contactatz3bradotorg>
Date: Mon, 5 Dec 2016 17:12:08 +0100
Bunch of unrelated changes, not worth detailling
Diffstat:
M cdump | 2 +-
M dm | 2 +-
M fadevid | 8 +++++---
M focus | 8 ++++----
M maillist | 3 ++-
M mkbar | 2 +-
M prtup | 2 +-
M pulsar | 2 +-
M q3dl | 6 +++---
M radio | 5 +++--
M record | 6 ++++--
M square | 9 ++++++---
M sshmenu | 2 +-
M sslget | 3 +--
M syscat | 8 +-------
M takeoffdir | 4 +---
M tile | 4 ++--
M uplaylist | 5 ++---
M ushot | 4 ++--
M vroum | 13 +++++++++----
M wrapbar | 2 +-
M yawee | 16 +++++-----------
M ydl | 10 +---------
23 files changed, 58 insertions(+), 68 deletions(-)
---
(DIR) diff --git a/cdump b/cdump
t@@ -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
(DIR) diff --git a/dm b/dm
t@@ -28,7 +28,7 @@ done
shift $((OPTIND - 1))
case $# in
- 0) usage; exit 1;;
+ 0) list; exit 0;;
1) method=a;;
*) method=A;;
esac
(DIR) diff --git a/fadevid b/fadevid
t@@ -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/'
t@@ -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
(DIR) diff --git a/focus b/focus
t@@ -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"
}
t@@ -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
(DIR) diff --git a/maillist b/maillist
t@@ -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
t@@ -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" {} +
(DIR) diff --git a/mkbar b/mkbar
t@@ -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() {
(DIR) diff --git a/prtup b/prtup
t@@ -57,7 +57,7 @@ update_pkgfile() {
# create it otherwise
else
- sed -i "/version/a\
+ sed -i "/^version=/a\
sversion=$sversion" Pkgfile
fi
}
(DIR) diff --git a/pulsar b/pulsar
t@@ -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
(DIR) diff --git a/q3dl b/q3dl
t@@ -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
(DIR) diff --git a/radio b/radio
t@@ -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}
(DIR) diff --git a/record b/record
t@@ -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
t@@ -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
(DIR) diff --git a/square b/square
t@@ -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}[0m"; done; echo
-for i in `seq 0 7`; do printf " [1;3${i}m${CHAR}[0m"; done; echo
echo
+#for i in `seq 0 7`; do printf " [0;3${i}m${CHAR}[0m"; done; echo
+#for i in `seq 0 7`; do printf " [1;3${i}m${CHAR}[0m"; done; echo
+for i in `seq 0 7`; do
+ printf " [0;3${i}m${CHAR}[1;3${i}m${CHAR}[0m\n"
+done
(DIR) diff --git a/sshmenu b/sshmenu
t@@ -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
(DIR) diff --git a/sslget b/sslget
t@@ -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'
(DIR) diff --git a/syscat b/syscat
t@@ -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
t@@ -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
(DIR) diff --git a/takeoffdir b/takeoffdir
t@@ -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'
(DIR) diff --git a/tile b/tile
t@@ -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))
(DIR) diff --git a/uplaylist b/uplaylist
t@@ -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 -"
(DIR) diff --git a/ushot b/ushot
t@@ -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
(DIR) diff --git a/vroum b/vroum
t@@ -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
t@@ -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
t@@ -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
(DIR) diff --git a/wrapbar b/wrapbar
t@@ -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
(DIR) diff --git a/yawee b/yawee
t@@ -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
(DIR) diff --git a/ydl b/ydl
t@@ -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>"
}
t@@ -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