tupdate some scripts - scripts - random scripts HTML git clone git://parazyd.org/scripts.git DIR Log DIR Files DIR Refs --- DIR commit ef9abc4c0fd15669f6b0e925163140cc849b60c3 DIR parent 4f85b36b2cbe91c3af84f0e30ac7b7a9f40ead1f HTML Author: parazyd <parazyd@dyne.org> Date: Sun, 13 Nov 2016 13:59:08 +0100 update some scripts Diffstat: M apk | 9 +++++---- A blink.sh | 10 ++++++++++ A bright | 22 ++++++++++++++++++++++ A btcticker | 42 +++++++++++++++++++++++++++++++ A g | 2 ++ A getmagnet | 4 ++++ M p | 4 ++-- A rn | 3 +++ M supadd | 42 +++++++++++++------------------ M susp | 6 +++--- A touchpad-toggle | 8 ++++++++ M ys | 6 +++--- 12 files changed, 122 insertions(+), 36 deletions(-) --- DIR diff --git a/apk b/apk t@@ -1,13 +1,14 @@ #!/bin/sh # wtfpl (c) parazyd _arch="x86_64";_query="$@" + test -n "$_query" || exit 1 _url="http://pkgs.alpinel" - _url="${_url}inux.org" #dog + _url="${_url}inux.org" # | _url="${_url}/packages?" # - _page="$(elinks -dump \ + _page="$(links -dump \ "${_url}name=${_query}&arch=${_arch}")" pkgtable="$(echo "$_page"|sed 34q | - grep $_query | grep '^\[')"; # wut| + grep $_query | grep '^\[')"; # xxx| test -n "$pkgtable" || { echo "(*) no packages found"; exit 1 }; pkgurl="$(echo "$_page" | grep http | t@@ -19,7 +20,7 @@ "echo $pkgurl | grep community >/dev/null"\ && pkgname=community;eval \ "echo $pkgurl | grep testing >/dev/null" \ - && pkgname=testing # biatch + && pkgname=testing # random pkgver="$(echo "$pkgtable"| awk -F']' '{print $3}' | awk -F'[' '{print $1}' | DIR diff --git a/blink.sh b/blink.sh t@@ -0,0 +1,10 @@ +#!/bin/sh + +thinklight="/sys/class/leds/tpacpi::thinklight/brightness" + +for i in 1 2 3; do + echo 255 > "$thinklight" + sleep 0.6 + echo 0 > "$thinklight" + sleep 0.6 +done DIR diff --git a/bright b/bright t@@ -0,0 +1,22 @@ +#!/bin/sh + +syspath="/sys/class/backlight/intel_backlight" + +step=300 + + +case "$1" in + +) + curr="$(cat $syspath/brightness)" + let curr=$curr+$step + printf "%s" "$curr" > "$syspath"/brightness + ;; + -) + curr="$(cat $syspath/brightness)" + let curr=$curr-$step + printf "%s" "$curr" > "$syspath"/brightness + ;; + *) + return 0 + ;; +esac DIR diff --git a/btcticker b/btcticker t@@ -0,0 +1,42 @@ +#!/usr/bin/env python2 + +import json +import sys +import urllib + +## Bitkonan +## https://bitkonan.com/api/ticker + + +def dump(name, url): + ticker = json.load(urllib.urlopen(url)) + + print("(*) " + name + " ticker") + print("\tLast: " + ticker['last'] + " USD") + print("\tHigh: " + ticker['high'] + " USD") + print("\tLow: " + ticker['low'] + " USD") + print("\tVolume: " + ticker['volume'] + " BTC\n") + + +def main(): + try: + market = sys.argv[1] + except: + print("specify a market") + exit(1) + + bitkonanurl = "https://bitkonan.com/api/ticker" + bitstampurl = "https://www.bitstamp.net/api/ticker/" + + if market == "bitkonan": + dump("Bitkonan", bitkonanurl) + elif market == "bitstamp": + dump("Bitstamp", bitstampurl) + elif market == "all": + dump("Bitkonan", bitkonanurl) + dump("Bitstamp", bitstampurl) + else: + print("unsupported market") + exit(1) + +main() DIR diff --git a/g b/g t@@ -0,0 +1,2 @@ +#!/bin/sh +surf "https://google.com/search?q=$*" DIR diff --git a/getmagnet b/getmagnet t@@ -0,0 +1,4 @@ +#!/bin/bash + +[[ "$1" =~ xt=urn:btih:([^&/]+) ]] || exit 1 +echo "d10:magnet-uri${#1}:${1}e" > "meta-${BASH_REMATCH[1]}.torrent" DIR diff --git a/p b/p t@@ -1,9 +1,9 @@ #!/bin/sh -palemoon=/usr/bin/palemoon +palemoon=/usr/bin/firefox profile="$1" -ps ax | grep '[p]alemoon' > /dev/null +ps ax | grep '[f]irefox' > /dev/null [ $? = 0 ] && { # one is already running, run next with -no-remote opts=" -no-remote " DIR diff --git a/rn b/rn t@@ -0,0 +1,3 @@ +#!/bin/sh + +/usr/local/bin/st-notrans -e ranger DIR diff --git a/supadd b/supadd t@@ -32,7 +32,7 @@ EOF printentry() { cat <<EOF - { USER, GROUP, "$bin", "$binpath", "$shasum" }, + { USER, GROUP, "$(basename $bin)", "$bin", "$shasum" }, EOF } t@@ -47,27 +47,21 @@ EOF } getsha() { - shasum=`sha256sum $binpath | awk '{print $1}'` - [ -n $shasum ] || exit 1 + shasum=$(sha256sum $bin | awk '{print $1}') + test -n "$shasum" || exit 1 } -case $1 in - -l) grep -v -i -e '//' -e '^#' $supsrc/allowed.txt ;; - *) - binpath="$1" - bin=`echo $binpath | awk -F"/" '{print $NF}'` - [ $binpath == /* ] || binpath="$PWD/$bin" - getsha || exit 1 - - if [ `grep $binpath $supsrc/allowed.txt` ]; then - grep -v $binpath $supsrc/allowed.txt > /tmp/allowed.txt - mv /tmp/allowed.txt $supsrc/allowed.txt - fi - printentry >> $supsrc/allowed.txt - printsettings | cat - $supsrc/allowed.txt > $supsrc/config.h - printrest >> $supsrc/config.h - - `basename $0` -l - ;; -esac - -cd $supsrc + +bin="$PWD/$1" +getsha + +if grep "$bin" $supsrc/allowed.txt >/dev/null ; then + grep -v "$bin" $supsrc/allowed.txt > /tmp/allowed.txt + mv /tmp/allowed.txt $supsrc/allowed.txt +fi + +printentry >> $supsrc/allowed.txt +printsettings | cat - $supsrc/allowed.txt > $supsrc/config.h +printrest >> $supsrc/config.h +cat $supsrc/allowed.txt + +cd $supsrc && exec sh -c 'sudo make clean install' DIR diff --git a/susp b/susp t@@ -3,7 +3,7 @@ # parazyd - (c) wtfpl 2016 case "$1" in - on) sed -i '30,34s/#//' /etc/acpi/default.sh ;; - off) sed -i '30,34s/^/#/' /etc/acpi/default.sh ;; - *) echo mem > /sys/power/state ;; + on) /bin/sed -i '30,35s/#//' /etc/acpi/default.sh ;; + off) /bin/sed -i '30,35s/^/#/' /etc/acpi/default.sh ;; + *) printf mem > /sys/power/state ;; esac DIR diff --git a/touchpad-toggle b/touchpad-toggle t@@ -0,0 +1,8 @@ +#!/bin/sh + +if [ $(synclient -l | grep TouchpadOff | gawk -F '= ' '{ print $2 }') -eq 0 ]; +then + synclient TouchpadOff=1 +else + synclient TouchpadOff=0 +fi DIR diff --git a/ys b/ys t@@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # perform a search on youtube and return the best result (title + link) t@@ -15,7 +15,7 @@ usage() { EOF } -num=5 +num=10 regex='^.*<a href="\(/watch[^"]*\)"[^>]*>\([^<]*\)</a>.*$' output='\2 - https://youtube.com\1' t@@ -34,4 +34,4 @@ shift $((OPTIND - 1)) query=$(echo $@ | tr ' ' '+') url="https://www.youtube.com/results?search_query=${query}" -curl -s "$url" | sed -n "s,$regex,$output,p" | sed ${num}q +curl -k -s "$url" | sed -n "s,$regex,$output,p" | sed ${num}q