tbump updates - scripts - random scripts HTML git clone git://parazyd.org/scripts.git DIR Log DIR Files DIR Refs --- DIR commit 477e9a548a07ce4a810765507b8c01969907a875 DIR parent b0b5f6e551e11c25cfda08111a983aa265d6b3f7 HTML Author: parazyd <parazyd@dyne.org> Date: Mon, 13 Feb 2017 02:57:07 +0100 bump updates Diffstat: A alarmclock | 16 ++++++++++++++++ M apk | 18 +++++++++--------- M dillo | 2 +- M dmenuraise | 4 ++-- M dn | 19 ++++++++++--------- M emerupd | 46 ++++++------------------------- M extmon | 26 +++++++++++--------------- M net | 4 +++- D note | 2 -- D notify-send | 2 -- R bright -> obsolete/bright | 0 A obsolete/ncmpc | 9 +++++++++ R rotmon -> obsolete/rotmon | 0 R spin -> obsolete/spin | 0 R startdwm -> obsolete/startdwm | 0 R surf.sh -> obsolete/surf.sh | 0 R ydl -> obsolete/ydl | 0 R yt -> obsolete/yt | 0 M radio | 31 +++++++++++++------------------ D rn | 3 --- A setwall | 11 +++++++++++ A slideshow | 3 +++ D spark | 103 ------------------------------- M xkcd.py | 14 +++++++++----- M xurls | 116 ++++++++++++++++++++++++++++++- D xurls.pl | 115 ------------------------------- M ys | 2 +- 27 files changed, 220 insertions(+), 326 deletions(-) --- DIR diff --git a/alarmclock b/alarmclock t@@ -0,0 +1,16 @@ +#!/bin/sh + +wattime="${1:-10:40}" + +currentime=$(date +%s) +wakeuptime=$(date -d "today $wattime" +%s) +howmuchslp=$(( $wakeuptime - $currentime )) + +printf "(*) armed at %s!\\n" "$wattime" +printf "(*) you'll be getting about %d hours of sleep\\n" "$(( $howmuchslp / 60 / 60 ))" +printf "(*) good night!\\n" + +sleep "$howmuchslp" +amixer set Master 100 +mpv --loop $HOME/music/WAKEUP.mp3 +exit 0 DIR diff --git a/apk b/apk t@@ -25,12 +25,12 @@ awk -F']' '{print $3}' | \ awk -F'[' '{print $1}' | \ tr '\n' ' ')" - home="$( printf "%s\\n" "$_page" | - grep http | awk '/18/ {print $2}')" - desc="$( printf "%s\\n" "$_page" | - awk '/16\./ { for (i=2; i<=NF; i++) print $i}' | - tr '\n' ' ')" ; pkgname="$pkgname/$(\ - printf "%s\\n" $pkgtable | awk -F']' '{print $2}' | - awk -F'[' '{print $1}')"; printf "[0;32m*[0;0m %s\\n" "$pkgname" - printf "\t[1;32mavailable versions: [0;32m%s\\n" "$pkgver"; printf "\t[1;32mhomepage: [0;0m%s\\n" "$home" - printf "\t[1;32mdescription: [0;0m%s\\n" "$desc"; printf "\t[1;32mpackage url: [0;0m%s\\n" "$pkgurl" + home="$( printf "%s\\n" "$_page" | + grep http | awk '/18/ {print $2}')" + desc="$( printf "%s\\n" "$_page" | + awk '/16\./ { for (i=2; i<=NF; i++) print $i}' | + tr '\n' ' ')" ; pkgname="$pkgname/$(\ + printf "%s\\n" $pkgtable | awk -F']' '{print $2}' | + awk -F'[' '{print $1}')"; printf "[0;32m*[0;0m %s\\n" "$pkgname" + printf "\t[1;32mavailable versions: [0;32m%s\\n" "$pkgver"; printf "\t[1;32mhomepage: [0;0m%s\\n" "$home" + printf "\t[1;32mdescription: [0;0m%s\\n" "$desc"; printf "\t[1;32mpackage url: [0;0m%s\\n" "$pkgurl" DIR diff --git a/dillo b/dillo t@@ -2,4 +2,4 @@ /usr/bin/dillo "$@" -killall dpid +pgrep dpid && killall dpid DIR diff --git a/dmenuraise b/dmenuraise t@@ -7,10 +7,10 @@ normfg="#939393" normbg="#000000" selbg="#800000" selfg="#ffffff" -font="6X13 for Powerline:size=10:antialias=true:autohint=true" +font="Terminus:size=9:antialias=true:autohint=true" height=$(wmctrl -l | wc -l) -if [[ $height -gt 30 ]]; then +if [ $height -gt 30 ]; then heightfit=30 else heightfit=$height DIR diff --git a/dn b/dn t@@ -26,15 +26,16 @@ use() { } case "$1" in - out|o) use "out" "127.0.0.1";; - home|h) use "fq" "10.0.2.1";; - bridge|b) use "bridge" "10.11.11.1";; - goog|g) use "goog" "8.8.8.8";; - dynevpn|dv) use "dyne" "10.8.0.1";; - ti) use "ti" "10.209.20.254";; - edit) chattr on; /usr/bin/vim -u NONE /etc/resolv.conf; chattr off;; - -|off) chattr off;; - +|on) chattr on;; + o) use "out" "127.0.0.1";; + h) use "fq" "10.0.2.1";; + b) use "bridge" "10.11.11.1";; + g) use "goog" "8.8.8.8";; + dv) use "dvn" "10.8.0.1";; + ti) use "ti" "10.209.20.254";; + lag) use "lag" "10.1.1.1";; + edit) chattr on; /usr/bin/vim -u NONE /etc/resolv.conf; chattr off;; + -|off) chattr off;; + +|on) chattr on;; *) /usr/bin/printf "current resolv.conf set as:\n" cat -v /etc/resolv.conf DIR diff --git a/emerupd b/emerupd t@@ -4,7 +4,7 @@ usage() { cat <<EOM $(basename $0): gentoo update wrapper usage: - $(basename $0) [-a] [-1] + $(basename $0) [step#] steps: 1) sync (runs eix-sync) t@@ -17,42 +17,12 @@ EOM exit 1 } -emersync() { - sudo eix-sync -a -} - -emerupdt() { - sudo emerge -av \ - --verbose-conflicts \ - --with-bdeps=y \ - --update \ - --newuse \ - --deep \ - @world -} - -emerglsa() { - sudo glsa-check -t all -} - -emerdeps() { - sudo emerge -av --depclean -} - -emerpres() { - sudo emerge -av @preserved-rebuild -} - -emerrevd() { - sudo revdep-rebuild.sh -v -} - case "x$1" in - x-1) emersync || exit 1;; - x-2) emerupdt || exit 1;; - x-3) emerglsa || exit 1;; - x-4) emerdeps || exit 1;; - x-5) emerpres || exit 1;; - x-6) emerrevd || exit 1;; - *) usage ;; + x1|x-1) sudo eix-sync -a ;; + x2|x-2) sudo emerge -av --verbose-conflicts --with-bdeps=y --update --newuse --deep @world ;; + x3|x-3) sudo glsa-check -t all ;; + x4|x-4) sudo emerge -av --depclean ;; + x5|x-5) sudo emerge -av @preserved-rebuild ;; + x6|x-6) sudo revdep-rebuild.sh -v ;; + *) usage ;; esac DIR diff --git a/extmon b/extmon t@@ -4,23 +4,19 @@ # skreenz IN="LVDS1" -EXT="VGA1" +EXT="${EXT:-VGA1}" -WALL="/home/parazyd/.config/wallpapers/f165f4ddcc12861aa70beb208316b2cea852193ff7b7e4b96839652656db8512.jpg" + +setmon() { + pos="$1" + xrandr --output $IN --auto --primary --output $EXT --auto --${pos} $IN + setwall +} case "$1" in - left|l) - xrandr --output $IN --auto --primary --output $EXT --auto --left-of $IN - feh --no-fehbg --bg-fill "$WALL" - ;; - right|r) - xrandr --output $IN --auto --primary --output $EXT --auto --right-of $IN - feh --no-fehbg --bg-fill "$WALL" - ;; - above|a) - xrandr --output $IN --auto --primary --output $EXT --auto --above $IN - feh --no-fehbg --bg-fill "$WALL" - ;; + left|l) setmon left-of ;; + right|r) setmon right-of ;; + above|a) setmon above ;; dup|d) xrandr --output $EXT --same-as $IN --output $IN --primary feh --no-fehbg --bg-fill "$WALL" t@@ -33,6 +29,6 @@ case "$1" in xrandr | grep \<connected\> | cut -d\ -f1 ;; *) - echo `basename $0` '{left|right|above|dup|off|list}' + printf "%s {left|right|above|dup|off|list}\\n" "$(basename $0)" ;; esac DIR diff --git a/net b/net t@@ -1,3 +1,5 @@ #!/bin/sh -/etc/init.d/net."$1" restart +act=restart +test -n "$2" && act="$2" +/etc/init.d/net."$1" "$act" DIR diff --git a/note b/note t@@ -1 +0,0 @@ -../notefy/notefy -\ No newline at end of file DIR diff --git a/notify-send b/notify-send t@@ -1 +0,0 @@ -popup -\ No newline at end of file DIR diff --git a/bright b/obsolete/bright DIR diff --git a/obsolete/ncmpc b/obsolete/ncmpc t@@ -0,0 +1,9 @@ +#!/bin/sh + +if [ -f ~/.config/mpd/pid ]; then + pgrep -F ~/.config/mpd/pid || mpd ~/.config/mpd/mpd.conf +else + mpd ~/.config/mpd/mpd.conf +fi + +exec /usr/bin/ncmpc -f ~/.config/ncmpc/config "$@" DIR diff --git a/rotmon b/obsolete/rotmon DIR diff --git a/spin b/obsolete/spin DIR diff --git a/startdwm b/obsolete/startdwm DIR diff --git a/surf.sh b/obsolete/surf.sh DIR diff --git a/ydl b/obsolete/ydl DIR diff --git a/yt b/obsolete/yt DIR diff --git a/radio b/radio t@@ -10,6 +10,9 @@ list of radios: 3. BlurFM02 4. Auroville 5. 2f30 + 6. YAMMAT + 7. KLFM + 8. NOPE EOM exit 1 } t@@ -19,22 +22,14 @@ play() { } case "$1" in - 1|ondarossa) - play "http://radio.dyne.org/ondarossa.mp3.m3u" - ;; - 2|mercadosul) - play "http://radio.dyne.org/mercadosul.ogg.m3u" - ;; - 3|blurfm) - play "http://radio.dyne.org/blurfm02.m3u" - ;; - 4|auroville) - play "http://radio.dyne.org/auroville.mp3.m3u" - ;; - 5|2f30) - play "http://radio.2f30.org:8000/live.mp3" - ;; - *) - usage - ;; + 1|ondarossa) play "http://radio.dyne.org/ondarossa.mp3.m3u" ;; + 2|mercadosul) play "http://radio.dyne.org/mercadosul.ogg.m3u" ;; + 3|blurfm) play "http://radio.dyne.org/blurfm02.m3u" ;; + 4|auroville) play "http://radio.dyne.org/auroville.mp3.m3u" ;; + 5|2f30) play "http://radio.2f30.org:8000/live.mp3" ;; + 6|yammat) play "http://192.240.102.131:9107" ;; + 7|klfm) play "http://klfm.streamradio.com.hr:5000/listen.pls" ;; + 8|nope) play "http://radionope.streamguys1.com/listen.pls" ;; + + *) usage ;; esac DIR diff --git a/rn b/rn t@@ -1,3 +0,0 @@ -#!/bin/sh - -/usr/local/bin/st-notrans -e ranger DIR diff --git a/setwall b/setwall t@@ -0,0 +1,11 @@ +#!/bin/sh +# +# simple wallpaper setter + +WALLPAPER_PATH="$HOME/.config/wallpapers" + +if [ $1 ]; then + [ -L "$1" ] || ln -sfv "$1" "$WALLPAPER_PATH/current" +fi + +feh --no-fehbg --bg-fill "$WALLPAPER_PATH/current" DIR diff --git a/slideshow b/slideshow t@@ -0,0 +1,3 @@ +#!/bin/sh + +feh -zdsrZFD 3.5 "$@" DIR diff --git a/spark b/spark t@@ -1,103 +0,0 @@ -#!/usr/bin/env bash -# -# spark -# https://github.com/holman/spark -# -# Generates sparklines for a set of data. -# -# Here's a good web-based sparkline generator that was a bit of inspiration -# for spark: -# -# https://datacollective.org/sparkblocks -# -# spark takes a comma-separated or space-separated list of data and then prints -# a sparkline out of it. -# -# Examples: -# -# spark 1 5 22 13 53 -# # => ▁▁▃▂▇ -# -# spark 0 30 55 80 33 150 -# # => ▁▂▃▅▂▇ -# -# spark -h -# # => Prints the spark help text. - -# Generates sparklines. -# -# $1 - The data we'd like to graph. -_echo() -{ - if [ "X$1" = "X-n" ]; then - shift - printf "%s" "$*" - else - printf "%s\n" "$*" - fi -} - -spark() -{ - local n numbers= - - # find min/max values - local min=0xffffffff max=0 - - for n in ${@//,/ } - do - # on Linux (or with bash4) we could use `printf %.0f $n` here to - # round the number but that doesn't work on OS X (bash3) nor does - # `awk '{printf "%.0f",$1}' <<< $n` work, so just cut it off - n=${n%.*} - (( n < min )) && min=$n - (( n > max )) && max=$n - numbers=$numbers${numbers:+ }$n - done - - # print ticks - local ticks=(▁ ▂ ▃ ▄ ▅ ▆ ▇ █) - - # use a high tick if data is constant - (( min == max )) && ticks=(▅ ▆) - - local f=$(( (($max-$min)<<8)/(${#ticks[@]}-1) )) - (( f < 1 )) && f=1 - - for n in $numbers - do - _echo -n ${ticks[$(( ((($n-$min)<<8)/$f) ))]} - done - _echo -} - -# If we're being sourced, don't worry about such things -if [ "$BASH_SOURCE" == "$0" ]; then - # Prints the help text for spark. - help() - { - local spark=$(basename $0) - cat <<EOF - - USAGE: - $spark [-h|--help] VALUE,... - - EXAMPLES: - $spark 1 5 22 13 53 - ▁▁▃▂█ - $spark 0,30,55,80,33,150 - ▁▂▃▄▂█ - echo 9 13 5 17 1 | $spark - ▄▆▂█▁ -EOF - } - - # show help for no arguments if stdin is a terminal - if { [ -z "$1" ] && [ -t 0 ] ; } || [ "$1" == '-h' ] || [ "$1" == '--help' ] - then - help - exit 0 - fi - - spark ${@:-`cat`} -fi DIR diff --git a/xkcd.py b/xkcd.py t@@ -3,8 +3,12 @@ # parazyd - (c) wtfpl # random xkcd comic -import urllib, json, random -latest = 1710 -num = str(random.randint(1,latest)) -info = json.load(urllib.urlopen("http://www.xkcd.com/" + num + "/info.0.json")) -print (info['img']) +from urllib import urlopen +from random import randint +from json import load + +latest = load(urlopen("http://www.xkcd.com/info.0.json")) +latest = latest['num'] +num = str(randint(1,latest)) +xkcd = load(urlopen("http://www.xkcd.com/" + num + "/info.0.json")) +print(xkcd['img']) DIR diff --git a/xurls b/xurls t@@ -1,3 +1,115 @@ -#!/bin/sh +#!/usr/bin/perl -grep -E -o 'https?://[^ ]+' +use warnings; + +$hostchars = '[a-z0-9-._+]'; +$pathchars = '[a-z0-9-._+#=?&:;%/!,~]'; + +sub scan($$$) +{ + my ($file, $lineno, $line) = @_; + + chomp $line; + + while($line =~ s! + ([a-z]+://)? + +# http:// + + $hostchars+\.[a-z]+/ + +# www.tim.google.com/ - the [a-z].com is the main anchor for the whole regex - incase http:// is omitted + + ($pathchars+/\?)* + +# check for the index.php? part + + ($pathchars+|\($pathchars+\))* + +# check for pathchars, or a set of nested parens + !!xoi){ # allow space + comments, compile once, strcasecmp + + my($p,$m,$e) = ($`,$&,$'); + + $e = '.' . $e if $m =~ s/\.$//; + + if($opt{fname} && $file){ + print "$col{red}$file$col{none}:"; + } + + if($opt{lineno}){ + print "$col{green}$lineno$col{none}: "; + }elsif($opt{fname} && $file){ + print ' '; + } + + if($opt{hl}){ + print "$p$col{brown}$m$col{none}$e\n"; + }else{ + print "$m\n"; + } + } +} + +sub usage(){ + $printme =<<"!"; +Usage: $0 -[Chn] [FILES...] + -h: highlight + -c: force colour on (for pipes) + -C: colour off (only makes sense with -h) + -n: show line number +! + print STDERR $printme; + exit 1; +} + + +%opt = ( + colour => 1, + lineno => 0, + fname => 0, + hl => 0 +); +%col = ( + brown => "\e[0;31m", # hl + red => "\e[0;35m", # fname + green => "\e[0;32m", # lineno + none => "\e[0;0m" +); + +for $arg (@ARGV){ + if($arg eq '-h'){ + $opt{hl} = 1; + }elsif($arg eq '-n'){ + $opt{lineno} = 1; + }elsif($arg eq '-C'){ + $opt{colour} = 0; + }elsif($arg eq '-c'){ + usage() if $opt{colour} == 0; + $opt{colour} = 2; # force on + }elsif($arg eq '--help'){ + usage(); + }else{ + push @files, $arg; + } +} + +usage() if $opt{hl} && !$opt{colour}; + +$opt{fname} = 1 if $#files > 0 || $opt{lineno}; +if(!$opt{colour} || ($opt{colour} == 1 && !-t STDOUT)){ + $col{$_} = '' for keys %col; +} + +$| = 1; + +if(@files){ + for my $f (@files){ + my $n = 1; + open F, '<', $f or warn "$f: $!\n"; + scan($f, $n++, $_) for <F>; + close F; + } +}else{ + scan(undef, $., $_) while <STDIN>; +} DIR diff --git a/xurls.pl b/xurls.pl t@@ -1,115 +0,0 @@ -#!/usr/bin/perl - -use warnings; - -$hostchars = '[a-z0-9-._+]'; -$pathchars = '[a-z0-9-._+#=?&:;%/!,~]'; - -sub scan($$$) -{ - my ($file, $lineno, $line) = @_; - - chomp $line; - - while($line =~ s! - ([a-z]+://)? - -# http:// - - $hostchars+\.[a-z]+/ - -# www.tim.google.com/ - the [a-z].com is the main anchor for the whole regex - incase http:// is omitted - - ($pathchars+/\?)* - -# check for the index.php? part - - ($pathchars+|\($pathchars+\))* - -# check for pathchars, or a set of nested parens - !!xoi){ # allow space + comments, compile once, strcasecmp - - my($p,$m,$e) = ($`,$&,$'); - - $e = '.' . $e if $m =~ s/\.$//; - - if($opt{fname} && $file){ - print "$col{red}$file$col{none}:"; - } - - if($opt{lineno}){ - print "$col{green}$lineno$col{none}: "; - }elsif($opt{fname} && $file){ - print ' '; - } - - if($opt{hl}){ - print "$p$col{brown}$m$col{none}$e\n"; - }else{ - print "$m\n"; - } - } -} - -sub usage(){ - $printme =<<"!"; -Usage: $0 -[Chn] [FILES...] - -h: highlight - -c: force colour on (for pipes) - -C: colour off (only makes sense with -h) - -n: show line number -! - print STDERR $printme; - exit 1; -} - - -%opt = ( - colour => 1, - lineno => 0, - fname => 0, - hl => 0 -); -%col = ( - brown => "\e[0;31m", # hl - red => "\e[0;35m", # fname - green => "\e[0;32m", # lineno - none => "\e[0;0m" -); - -for $arg (@ARGV){ - if($arg eq '-h'){ - $opt{hl} = 1; - }elsif($arg eq '-n'){ - $opt{lineno} = 1; - }elsif($arg eq '-C'){ - $opt{colour} = 0; - }elsif($arg eq '-c'){ - usage() if $opt{colour} == 0; - $opt{colour} = 2; # force on - }elsif($arg eq '--help'){ - usage(); - }else{ - push @files, $arg; - } -} - -usage() if $opt{hl} && !$opt{colour}; - -$opt{fname} = 1 if $#files > 0 || $opt{lineno}; -if(!$opt{colour} || ($opt{colour} == 1 && !-t STDOUT)){ - $col{$_} = '' for keys %col; -} - -$| = 1; - -if(@files){ - for my $f (@files){ - my $n = 1; - open F, '<', $f or warn "$f: $!\n"; - scan($f, $n++, $_) for <F>; - close F; - } -}else{ - scan(undef, $., $_) while <STDIN>; -} DIR diff --git a/ys b/ys t@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # perform a search on youtube and return the best result (title + link)