URI: 
       tAdd updates. - scripts - random scripts
  HTML git clone git://parazyd.org/scripts.git
   DIR Log
   DIR Files
   DIR Refs
       ---
   DIR commit 887f0ddd54bfef30dae856e94ead965df308ccf8
   DIR parent 37fb7497d2762018f87c74f04ffe258c3fdbafcb
  HTML Author: parazyd <parazyd@dyne.org>
       Date:   Sat,  7 Apr 2018 11:22:53 +0200
       
       Add updates.
       
       Diffstat:
         M autoup                              |       2 +-
         A bitreich-paste                      |      34 +++++++++++++++++++++++++++++++
         T blck                                |       0 
         A cheat                               |       2 ++
         D define                              |       5 -----
         A dict                                |      17 +++++++++++++++++
         M extmon                              |      12 ++++++------
         M hex-contrast.py                     |      10 ++--------
         A irssi                               |       8 ++++++++
         M maclookup                           |       7 +------
         M macspoof.sh                         |       2 ++
         M net                                 |       8 ++++++--
         R apk -> notinpath/apk                |       0 
         R blackholedns -> notinpath/blackhol… |       0 
         R genhtpasswd -> notinpath/genhtpass… |       0 
         R catfact -> notinpath/obsolete/catf… |       0 
         R supadd -> notinpath/obsolete/supadd |       0 
         R rsync_backup.sh -> notinpath/rsync… |       0 
         D parcimonie.sh                       |     227 -------------------------------
         M ptpb                                |       3 +++
         D sacc                                |       0 
         M setwall                             |       6 ++++--
         A urban                               |      34 +++++++++++++++++++++++++++++++
         M wave.lua                            |       6 +++++-
         A wttr                                |       2 ++
       
       25 files changed, 127 insertions(+), 258 deletions(-)
       ---
   DIR diff --git a/autoup b/autoup
       t@@ -34,7 +34,7 @@ case "$filename" in
                        filename="screenshot${num}.png"
                        goph=I
                        ;;
       -        *.png|*.jpg)
       +        *.png|*.jpg|*.jpeg|.JPG|.JPEG)
                        goph=I
                        ;;
                *.txt|*.html|*.css|*.sh)
   DIR diff --git a/bitreich-paste b/bitreich-paste
       t@@ -0,0 +1,34 @@
       +#!/bin/sh
       +
       +DST="parazyd@bitreich.org"
       +DSTDIR="/bitreich/gopher/paste"
       +
       +if [ -z "$DST" ];
       +then
       +        printf "You forgot to set DST in %s. Please do so.\n" \
       +                "$(basename "$0")" >&2
       +        exit 1
       +fi
       +
       +if [ $# -gt 0 ];
       +then
       +        file="$@"
       +else
       +        file=
       +fi
       +
       +cd $HOME/tmp
       +tmpfile="$(mktemp p-XXXXXXXXXXXXX.txt)"
       +if [ -z "$file" ];
       +then
       +        cat > $tmpfile
       +else
       +        cat "$file" > $tmpfile
       +fi
       +
       +[ $(stat -c %s $tmpfile) -eq 0 ] && exit 1
       +
       +tar cf - $tmpfile | ssh ${DST} "cd $DSTDIR; tar xf -; chmod g+rw $tmpfile"
       +name="$(basename $tmpfile)"
       +echo "gopher://bitreich.org/0/p/$name" | xclip
       +echo "gopher://bitreich.org/0/p/$name"
   DIR diff --git a/blck b/blck
   DIR diff --git a/cheat b/cheat
       t@@ -0,0 +1 @@
       +dict
       +\ No newline at end of file
   DIR diff --git a/define b/define
       t@@ -1,5 +0,0 @@
       -#!/bin/dash
       -
       -[ -n "$TORIFY" ] && proxy="--proxy socks5://127.0.0.1:9050"
       -
       -curl -s ${proxy} dict://dict.org/d:${1} | grep -E -v '^[0-9]|\[*\]' | less
   DIR diff --git a/dict b/dict
       t@@ -0,0 +1,17 @@
       +#!/bin/sh
       +
       +case "$(basename $0)" in
       +
       +        cheat)
       +                curl -s http://cheat.sh/$1
       +                ;;
       +
       +        dict)
       +                curl -s dict://dict.org/d:$1
       +                ;;
       +
       +        wttr)
       +                curl -s http://wttr.in/$1
       +                ;;
       +
       +esac
   DIR diff --git a/extmon b/extmon
       t@@ -3,13 +3,13 @@
        # parazyd - (c) wtfpl 2017
        # skreenz
        
       - IN="${IN:-DP-3}"
       -EXT="${EXT:-HDMI-1}"
       + IN="${IN:-eDP-1}"
       +EXT="${EXT:-HDMI-2}"
        
        
        setmon() {
                pos="$1"
       -        xrandr --output LVDS-1 --off
       +        #xrandr --output LVDS-1 --off
                xrandr --output $IN --auto --primary --output $EXT --auto --${pos} $IN
                setwall
        }
       t@@ -19,19 +19,19 @@ case "$1" in
                right|r) setmon right-of ;;
                above|a) setmon above ;;
                dup|d)
       -                xrandr --output LVDS-1 --off
       +                #xrandr --output LVDS-1 --off
                        xrandr --output $EXT --same-as $IN --output $IN --primary
                        feh --no-fehbg --bg-fill "$WALL"
                        ;;
                tv)
       -                xrandr --output LVDS-1 --off
       +                #xrandr --output LVDS-1 --off
                        xrandr --output $IN --auto --primary --output $EXT --mode 1920x1080 --above $IN
                        xrandr --output $EXT --set "Broadcast RGB" "Full"
                        setwall
                        ;;
                off|o)
                        xrandr --output $IN --auto --output $EXT --off --output HDMI-1 --off
       -                xrandr --output LVDS-1 --auto
       +                xrandr --output $IN --auto
                        #xrandr --output HDMI1 --off
                        setwall
                        ;;
   DIR diff --git a/hex-contrast.py b/hex-contrast.py
       t@@ -24,14 +24,8 @@ hexmap = {
            'f': '0',
        }
        
       -args = stdin.read().split('\n')
       -
       -out = []
       -for i in args:
       +for i in stdin.read().split('\n'):
            val = ''
            for j in i:
                val += hexmap[j.lower()]
       -    out.append(val)
       -
       -for i in out:
       -    print(i)
       +    print(val)
   DIR diff --git a/irssi b/irssi
       t@@ -0,0 +1,8 @@
       +#!/bin/sh
       +
       +abduco -a irssi || {
       +        gpg --decrypt ~/.irssi/config.gpg > ~/.irssi/config && \
       +        abduco -c irssi /usr/bin/irssi
       +}
       +
       +rm -f ~/.irssi/config
   DIR diff --git a/maclookup b/maclookup
       t@@ -1,11 +1,6 @@
        #!/bin/sh
        
        MACFILE="/usr/share/nmap/nmap-mac-prefixes"
       -
       -MACADDR="$@"
       -
       -MACADDR="$(printf "%s" "$MACADDR" | tr -d ":" | cut -c1-6)"
       +MACADDR="$(printf "%s" "$*" | tr -d ":" | cut -c1-6)"
        
        grep -i "^$MACADDR" "$MACFILE"
       -
       -
   DIR diff --git a/macspoof.sh b/macspoof.sh
       t@@ -7,10 +7,12 @@ case "$1" in
                -p)
                        sup net "$2" stop
                        sudo macchanger -A "$2"
       +                sup net "$2" start
                        ;;
                -r)
                        sup net "$2" stop
                        sudo macchanger -p "$2"
       +                sup net "$2" start
                        ;;
                *)
                        printf "usage: %s {-p [orig]|-r [random]} netdev\n" "$(basename $0)"
   DIR diff --git a/net b/net
       t@@ -1,5 +1,9 @@
        #!/bin/sh
        
       -act=restart
       -test -n "$2" && act="$2"
       +case "$2" in
       +        stop|start) act="$2" ;;
       +        restart) act=restart ;;
       +        *) exit 1 ;;
       +esac
       +
        /etc/init.d/net."$1" "$act"
   DIR diff --git a/apk b/notinpath/apk
   DIR diff --git a/blackholedns b/notinpath/blackholedns
   DIR diff --git a/genhtpasswd b/notinpath/genhtpasswd
   DIR diff --git a/catfact b/notinpath/obsolete/catfact
   DIR diff --git a/supadd b/notinpath/obsolete/supadd
   DIR diff --git a/rsync_backup.sh b/notinpath/rsync_backup.sh
   DIR diff --git a/parcimonie.sh b/parcimonie.sh
       t@@ -1,227 +0,0 @@
       -#!/usr/bin/env bash
       -
       -# Copyright © 2015 Etienne Perot <etienne at perot dot me>
       -# This work is free. You can redistribute it and/or modify it under the
       -# terms of the Do What The Fuck You Want To Public License, Version 2,
       -# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
       -
       -if [ -n "$PARCIMONIE_CONF" ]; then
       -        source "$PARCIMONIE_CONF" || exit 'Bad configuration file.'
       -        export PARCIMONIE_CONF='' # Children spawned by this script (if any) should not inherit those values
       -fi
       -
       -parcimonieUser="${PARCIMONIE_USER:-$(whoami)}"
       -gnupgBinary="${GNUPG_BINARY:-}"
       -torsocksBinary="${TORSOCKS_BINARY:-torsocks}"
       -gnupgHomedir="${GNUPG_HOMEDIR:-}"
       -gnupgKeyserver="${GNUPG_KEYSERVER:-}"
       -gnupgKeyserverOptions="${GNUPG_KEYSERVER_OPTIONS:-http-proxy=}"
       -torAddress="${TOR_ADDRESS:-127.0.0.1}"
       -torPort="${TOR_PORT:-9050}"
       -minWaitTime="${MIN_WAIT_TIME:-900}" # 15 minutes
       -targetRefreshTime="${TARGET_REFRESH_TIME:-604800}" # 1 week
       -computerOnlineFraction="${COMPUTER_ONLINE_FRACTION:-1.0}" # 100% of the time
       -useRandom="${USE_RANDOM:-false}"
       -dirmngrPath="${DIRMNGR_PATH-}"
       -dirmngrClientPath="${DIRMNGR_CLIENT_PATH-}"
       -
       -# -----------------------------------------------------------------------------
       -
       -if [ "$(whoami)" != "$parcimonieUser" ]; then
       -        if [ "$parcimonieUser" == '*' ]; then # If user requested the script to run for all users
       -                if [ "$(id -u)" != 0 ]; then
       -                        echo 'Error: Must be run as root in order to support PARCIMONIE_USER="*".'
       -                        exit 1
       -                fi
       -                gnupgUsers=()
       -                for user in $(cut -d ':' -f 1 < /etc/passwd); do
       -                        if [ -d "$(eval "echo ~$user")/.gnupg" ]; then
       -                                gnupgUsers+=("$user")
       -                        fi
       -                done
       -                # If we have 0 users, error out
       -                if [ "${#gnupgUsers[@]}" -eq 0 ]; then
       -                        echo 'Error: No users found with a ~/.gnupg directory.'
       -                        exit 1
       -                fi
       -                # If we just have one user, just su to it
       -                if [ "${#gnupgUsers[@]}" -eq 1 ]; then
       -                        export PARCIMONIE_USER="${gnupgUsers[0]}"
       -                        export GNUPG_HOMEDIR="$(eval "echo ~"${gnupgUsers[0]}"")/.gnupg"
       -                        exec su -c "$0" "${gnupgUsers[0]}"
       -                fi
       -                # If we have more than one, spawn children processes for each
       -                childrenPids=()
       -                for user in "${gnupgUsers[@]}"; do
       -                        PARCIMONIE_USER="$user" GNUPG_HOMEDIR="$(eval "echo ~$user")/.gnupg" su -c "$0" "$user" &
       -                        childrenPids+=("$!")
       -                done
       -                for childPid in "${childrenPids[@]}"; do
       -                        wait "$childPid"
       -                done
       -                exit 0
       -        else # If the user requested the script to run for a specific user which is not the current one
       -                exec su -c "$0" "$parcimonieUser"
       -        fi
       -fi
       -
       -# If we get here, we know that we are the right user.
       -
       -# Find the gpg binary.
       -if [ -n "$gnupgBinary" ]; then
       -        if [ ! -x "$gnupgBinary" ]; then
       -                echo "Error: GNUPG_BINARY '$GNUPG_BINARY' does not exist or is not executable."
       -                exit 1
       -        fi
       -elif which gpg2 &> /dev/null; then
       -        # Try to find it in $PATH.
       -        gnupgBinary="$(which gpg2)"
       -        echo "Detected gpg2 at '$gnupgBinary'."
       -elif which gpg &> /dev/null; then
       -        gnupgBinary="$(which gpg)"
       -        echo "Detected gpg at '$gnupgBinary'."
       -else
       -        echo 'gpg not found. Please make sure you have installed GnuPG.'
       -        echo 'You may manually specify the full path to gpg with GNUPG_BINARY.'
       -        exit 1
       -fi
       -
       -# Test for dirmngr, used in GnuPG >= 2.1 for keyserver communication.
       -if [ -n "$dirmngrPath" ]; then
       -        if [ ! -x "$dirmngrPath" ]; then
       -                echo "Error: DIRMNGR_PATH '$DIRMNGR_PATH' does not exist or is not executable."
       -                exit 1
       -        fi
       -elif which dirmngr &> /dev/null; then
       -        # Try to find dirmngr in $PATH.
       -        dirmngrPath="$(which dirmngr)"
       -        echo "Detected dirmngr at '$dirmngrPath'; assuming GnuPG >= 2.1."
       -else
       -        echo 'dirmngr not specified, and not found in $PATH. Assuming GnuPG < 2.1.'
       -fi
       -
       -if [ -n "$dirmngrPath" ]; then
       -        # If we are using dirmngr, we must also have dirmngr-client.
       -        if [ -n "$dirmngrClientPath" ]; then
       -                if [ ! -x "$dirmngrClientPath" ]; then
       -                        echo "Error: DIRMNGR_CLIENT_PATH '$DIRMNGR_CLIENT_PATH' does not exist or is not executable."
       -                        exit 1
       -                fi
       -        elif which dirmngr-client &> /dev/null; then
       -                # Try to find it in $PATH. Unlike dirmngr, it is a fatal error if we cannot find it,
       -                # because we need it to handle dirmngr properly.
       -                dirmngrClientPath="$(which dirmngr-client)"
       -                echo "Detected dirmngr-client at '$dirmngrClientPath'."
       -        else
       -                echo "dirmngr-client not found, while dirmngr was found at '$dirmngrPath'."
       -                echo 'Please make sure your installation of GnuPG is complete.'
       -                echo 'You may manually specify the full path to dirmngr-client with DIRMNGR_CLIENT_PATH.'
       -                exit 1
       -        fi
       -fi
       -
       -gnupgExec=("$gnupgBinary" --batch --with-colons)
       -if [ -n "$gnupgHomedir" ]; then
       -        gnupgExec+=(--homedir "$gnupgHomedir")
       -fi
       -if [ -n "$gnupgKeyserver" ]; then
       -        gnupgExec+=(--keyserver "$gnupgKeyserver")
       -fi
       -if [ -n "$gnupgKeyserverOptions" ]; then
       -        gnupgExec+=(--keyserver-options "$gnupgKeyserverOptions")
       -fi
       -
       -# Test for GNU `sed`, or use a `sed` fallback in sedExtRegexp
       -sedExec=(sed)
       -if [ "$(echo 'abc' | sed -r 's/abc/def/' 2> /dev/null || true)" == 'def' ]; then
       -        # GNU Linux sed
       -        sedExec+=(-r)
       -else
       -        # Mac OS X sed
       -        sedExec+=(-E)
       -fi
       -
       -sedExtRegexp() {
       -        "${sedExec[@]}" "$@"
       -}
       -
       -keepDigitsOnly() {
       -        sedExtRegexp -e 's/[^[:digit:]]//g' -e '/^$/d'
       -}
       -
       -getRandom() {
       -        if [ -z "$useRandom" -o "$useRandom" == 'false' ]; then
       -                od -vAn -N4 -tu4 < /dev/urandom | keepDigitsOnly
       -        else
       -                od -vAn -N4 -tu4 < /dev/random | keepDigitsOnly
       -        fi
       -}
       -
       -nontor_gnupg() {
       -        "${gnupgExec[@]}" "$@"
       -        return "$?"
       -}
       -
       -tor_gnupg() {
       -        "$torsocksBinary" --isolate "${gnupgExec[@]}" "$@"
       -}
       -
       -getPublicKeys() {
       -        nontor_gnupg --list-public-keys --with-colons --fixed-list-mode --with-fingerprint --with-fingerprint --with-key-data |
       -                grep -a -A 1 '^pub:' |                       # only allow fingerprints of public keys (not subkeys)
       -                grep -E   '^fpr:+[0-9a-fA-F]{40,}:' |        # only allow fingerprints of v4 pgp keys
       -                                                             # (v3 fingerprints consist of 32 hex characters)
       -                sedExtRegexp 's/^fpr:+([0-9a-fA-F]+):+$/\1/' # extract the fingerprint
       -}
       -
       -getNumKeys() {
       -        getPublicKeys | wc -l | keepDigitsOnly
       -}
       -
       -getRandomKey() {
       -        local allPublicKeys fingerprint
       -        allPublicKeys=()
       -        for fingerprint in $(getPublicKeys); do
       -                allPublicKeys+=("$fingerprint")
       -        done
       -        echo "${allPublicKeys[$(expr "$(getRandom)" % "${#allPublicKeys[@]}")]}"
       -}
       -
       -getTimeToWait() {
       -        # The target refresh time is scaled by the fraction of time that the computer is expected to be online.
       -        # expr or bash's $(()) don't support fractional math. Use awk.
       -        local scaledRefreshTime
       -        scaledRefreshTime="$targetRefreshTime"
       -        if [ "$computerOnlineFraction" != '1.0' -a "$computerOnlineFraction" != '1' ]; then
       -                scaledRefreshTime="$(echo "$scaledRefreshTime" "$computerOnlineFraction" | awk 'BEGIN {print sprintf("%.0f", $1 * $2)}')"
       -        fi
       -        #   minimum wait time + rand(2 * (refresh time / number of pubkeys))
       -        # = $minWaitTime + $(getRandom) % (2 * $scaledRefreshTime / $(getNumKeys))
       -        # But if we have a lot of keys or a very short refresh time (2 * refresh time < number of keys),
       -        # then we can encounter a modulo by zero. In this case, we use the following as fallback:
       -        #   minimum wait time + rand(minimum wait time)
       -        # = $minWaitTime + $(getRandom) % $minWaitTime
       -        if [ "$(expr '2' '*' "$scaledRefreshTime")" -le "$(getNumKeys)" ]; then
       -                expr "$minWaitTime" '+' "$(getRandom)" '%' "$minWaitTime"
       -        else
       -                expr "$minWaitTime" '+' "$(getRandom)" '%' '(' '2' '*' "$scaledRefreshTime" '/' "$(getNumKeys)" ')'
       -        fi
       -}
       -
       -if [ "$(getNumKeys)" -eq 0 ]; then
       -        echo 'No GnuPG keys found.'
       -        exit 1
       -fi
       -
       -if [ "$(echo "$computerOnlineFraction" | awk '{ print ($1 < 0.1 || $1 > 1.0) ? "bad" : "good" }')" == 'bad' ]; then
       -        echo 'COMPUTER_ONLINE_FRACTION must be between 0.1 and 1.0.' >&2
       -        exit 1
       -fi
       -
       -while true; do
       -        keyToRefresh="$(getRandomKey)"
       -        timeToSleep="$(getTimeToWait)"
       -        echo "> Sleeping $timeToSleep seconds before refreshing key $keyToRefresh..."
       -        sleep "$timeToSleep"
       -        tor_gnupg --recv-keys "$keyToRefresh"
       -done
   DIR diff --git a/ptpb b/ptpb
       t@@ -10,4 +10,7 @@ case "$(basename $0)" in
                sprunge)
                        curl -F 'sprunge=<-' http://sprunge.us
                        ;;
       +        blck)
       +                curl -F "url=$1" https://blck.cf
       +                ;;
        esac
   DIR diff --git a/sacc b/sacc
       Binary files differ.
   DIR diff --git a/setwall b/setwall
       t@@ -3,9 +3,11 @@
        # simple wallpaper setter
        
        WALLPAPER_PATH="$HOME/.config/wallpapers"
       +f="$1"
        
       -if [ $1 ]; then
       -        [ -L "$1" ] || ln -sfv "$1" "$WALLPAPER_PATH/current"
       +if [ -n "$f" ]; then
       +        [ -f "$(basename $f)" ] && f="$PWD/$f"
       +        [ -L "$f" ] || ln -sfv "$f" "$WALLPAPER_PATH/current"
        fi
        
        feh --no-fehbg --bg-fill "$WALLPAPER_PATH/current"
   DIR diff --git a/urban b/urban
       t@@ -0,0 +1,34 @@
       +#!/bin/sh
       +#
       +# Copy me if you can.
       +# By parazyd
       +#
       +# Grab urbandictionary definitions
       +
       +api="https://api.urbandictionary.com/v0/define?term="
       +
       +term="$*"
       +printf "Getting definition for \"%s\"...\n" "$term"
       +term="$(echo $term | sed 's/ /%20/g')"
       +
       +data="$(curl -s "${api}${term}" | jq '.list')"
       +
       +for i in $(seq 1 3); do
       +        def="$(echo "$data" | jq '.['$i'].definition')"
       +        [ "$def" = null ] && break
       +        def="$(tput bold)$(tput setaf 4)Definition:$(tput sgr0) $def"
       +
       +        exa="$(echo "$data" | jq '.['$i'].example')"
       +        exa="$(tput bold)$(tput setaf 4)Example:$(tput sgr0) $exa"
       +
       +        plu="$(echo "$data" | jq '.['$i'].thumbs_up')"
       +        plu="$(tput bold)$(tput setaf 2)$plu+$(tput sgr0)"
       +
       +        min="$(echo "$data" | jq '.['$i'].thumbs_down')"
       +        min="$(tput bold)$(tput setaf 1)$min-$(tput sgr0)"
       +
       +        printf "\n---------------------------------------\n\n"
       +        printf "%s\n%s\n%s | %s\n" "$def" "$exa" "$plu" "$min" | \
       +                        sed -e 's/\\r\\n/\n/g' -e 's/\\"/"/g'
       +
       +done
   DIR diff --git a/wave.lua b/wave.lua
       t@@ -1,4 +1,8 @@
        #!/usr/bin/env lua
       +--
       +-- Copy me if you can.
       +-- by parazyd
       +--
        
        local clock = os.clock
        
       t@@ -12,7 +16,7 @@ t = {"*","*","*","*","*"," ","+","+","+"," "}
        
        while true do
                print("")
       -        for j = 1, math.floor(math.sin(wave)*20+20) do
       +        for j = 1, math.floor(math.sin(wave)*50+50) do
                        io.write(" ")
                end
                for i = 1, 10 do
   DIR diff --git a/wttr b/wttr
       t@@ -0,0 +1 @@
       +dict
       +\ No newline at end of file