commit 4587c6473046a4c62c2f6ac9fbbdbf5a2b1d8425
parent dc436276c43849835c7c2374194a0128c9857984
Author: Janis Pagel <janis.pagel@ims.uni-stuttgart.de>
Date: Sat, 12 Sep 2020 13:06:10 +0200
Add scripts
Diffstat:
10 files changed, 245 insertions(+), 0 deletions(-)
diff --git a/bin/.local/bin/audiosplit b/bin/.local/bin/audiosplit
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+# Modified from https://github.com/LukeSmithxyz/voidrice
+# Requires ffmpeg (audio splitting)
+
+[ ! -f "$2" ] && printf "The first file should be the audio, the second should be the timecodes.\\n" && exit
+
+inputaudio="$1"
+
+filename="${1%.*}"
+ext="${1#*.}"
+
+# Get the total number of tracks from the number of lines.
+total="$(wc -l < "$2")"
+
+while read -r x;
+do
+ end="$(echo "$x" | cut -d' ' -f1)"
+ [ -n "$start" ] &&
+ echo "From $start to $end; $track $title"
+ file="./${filename}_-_${esctitle}.${ext}"
+ [ -n "$start" ] && ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -to "$end" -vn "$file"
+ title="$(echo "$x" | cut -d' ' -f 2-)"
+ esctitle="$(echo "$title" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '_' | sed "s/_\+/_/g;s/\(^_\|_\$\)//g")"
+ track="$((track+1))"
+ start="$end"
+done < "$2"
+# The last track must be done outside the loop.
+echo "From $start to the end: $title"
+file="./${filename}_-_${esctitle}.${ext}"
+ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -vn "$file"
diff --git a/bin/.local/bin/cst b/bin/.local/bin/cst
@@ -0,0 +1,3 @@
+#!/bin/dash
+
+export TMUXAUTOATTACH=1 && st -e zsh
diff --git a/bin/.local/bin/dirsize b/bin/.local/bin/dirsize
@@ -0,0 +1,3 @@
+#!/bin/env dash
+
+du -h --max-depth=1 | sort -hr
diff --git a/bin/.local/bin/dmenu_path b/bin/.local/bin/dmenu_path
@@ -0,0 +1,12 @@
+#!/bin/sh
+#
+# dmenu_path: Override dmenu_path sorting results by atime.
+#
+# By default, dmenu_path sorts executables alphabetically. It seems to make
+# more sense to sort them by atime in an effort to reduce the number of
+# keystrokes needed to start a program.
+
+echo $PATH | tr ':' '\n' | uniq | sed 's#$#/#' | # List directories in $PATH
+ xargs ls -lu --time-style=+%s | # Add atime epoch
+ awk '/^(-|l)/ { print $6, $7 }' | # Only print timestamp and name
+ sort -rn | cut -d' ' -f 2+
\ No newline at end of file
diff --git a/bin/.local/bin/fcsearch b/bin/.local/bin/fcsearch
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+find . | xargs grep --color=auto "$1" 2>/dev/null
diff --git a/bin/.local/bin/maintenance.sh b/bin/.local/bin/maintenance.sh
@@ -0,0 +1,70 @@
+#!/bin/dash
+echo ''
+echo '########################################################'
+echo '################ systemctl --failed ####################'
+echo '########################################################'
+echo ''
+systemctl --failed
+echo ''
+echo '########################################################'
+echo '################ journalctl -p 0 -xb ###################'
+echo '########################################################'
+echo ''
+journalctl -p 0 -xb
+echo ''
+echo '#########################################################'
+echo '################ journalctl -p 1 -xb ####################'
+echo '#########################################################'
+echo ''
+journalctl -p 1 -xb
+echo ''
+echo '#########################################################'
+echo '################ journalctl -p 2 -xb ####################'
+echo '#########################################################'
+echo ''
+journalctl -p 2 -xb
+echo ''
+echo '#########################################################'
+echo '################ journalctl -p 3 -xb ####################'
+echo '#########################################################'
+echo ''
+journalctl -p 3 -xb
+echo ''
+echo '#########################################################'
+echo '################ journalctl -xb | grep -i ufw ###########'
+echo '#########################################################'
+echo ''
+journalctl -xb | grep -i ufw
+echo ''
+echo '#########################################################'
+echo '################ find -xtype l -print ###################'
+echo '#########################################################'
+echo ''
+#find -xtype l -print
+#echo ''
+#echo '#########################################################'
+#echo '### pacman -Qqen > /root/pacman/pkglist.txt #############'
+#echo '#########################################################'
+echo ''
+pacman -Qqen > /root/pacman/pkglist.txt
+echo 'Saved package list to /root/pacman/pkglist.txt'
+echo ''
+echo '#########################################################'
+echo '### pacman -Qqem > /home/pagel/.pacman/pkglist_aur.txt ##'
+echo '#########################################################'
+echo ''
+pacman -Qqem > /root/pacman/pkglist_aur.txt
+echo 'Saved aur package list to /root/pacman/pkglist_aur.txt'
+echo ''
+echo '#########################################################'
+echo '################ paccache -rvk 2 ########################'
+echo '#########################################################'
+echo ''
+paccache -r -v -k 2
+echo ''
+echo '##########################################################################################'
+echo '####### reflector --verbose -l 15 --sort rate --save /etc/pacman.d/mirrorlist #############'
+echo '##########################################################################################'
+echo ''
+reflector --verbose -l 15 --sort rate --save /etc/pacman.d/mirrorlist
+echo ''
diff --git a/bin/.local/bin/tor b/bin/.local/bin/tor
@@ -0,0 +1,4 @@
+#!/bin/dash
+
+cd $HOME/build/tor-browser_en-US/
+./start-tor-browser.desktop
diff --git a/bin/.local/bin/tst b/bin/.local/bin/tst
@@ -0,0 +1,3 @@
+#!/bin/dash
+
+tabbed -n st -c st -w & disown
diff --git a/bin/.local/bin/wifi b/bin/.local/bin/wifi
@@ -0,0 +1,4 @@
+#!/bin/env dash
+
+WIFI=$(ls ~/.local/bin/wifi-* | dmenu -c -l 5)
+[ ! -z "$WIFI" ] && st -t "wifi" -g 120x34 -e sudo "$WIFI"
diff --git a/bin/.local/bin/zerohosts b/bin/.local/bin/zerohosts
@@ -0,0 +1,111 @@
+#!/bin/sh
+# prx -- prx@ybad.name.
+# Idea from https://sebsauvage.net/wiki/doku.php?id=dns-blocklist
+# Licence: MIT
+# Script to generate a /etc/hosts file to blacklist ads
+# Add yours in $MYHOSTS in a file passed as argument
+# zerohosts file.txt
+
+set -e
+
+# DOWNLOADER (to standard output)
+D="wget -O-" # mosts linux
+#D="curl -L" # with curl
+#D="ftp -o-" # OpenBSD
+
+
+# Number of days befor updating the list
+DAYS=7
+
+# Run only if older than $DAYS
+#test -z "$(find /etc/hosts -mtime +${DAYS} )" && exit
+
+if [ -f "${1}" ]; then
+ MYHOSTS=$(cat "${1}")
+else
+ MYHOSTS=""
+fi
+
+# https://hosts-file.net/ad_servers.txt # Does not work anymore
+HOSTSSRC="
+https://adaway.org/hosts.txt
+https://someonewhocares.org/hosts/zero/hosts
+https://www.malwaredomainlist.com/hostslist/hosts.txt
+http://winhelp2002.mvps.org/hosts.txt
+https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext
+https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
+"
+
+#https://raw.githubusercontent.com/disconnectme/disconnect/b27abbf033c6f80f157fe9d98cb767c87065fbf4/firefox/content/disconnect.safariextension/opera/chrome/scripts/data.js
+#https://easylist-downloads.adblockplus.org/easylist.txt
+#https://easylist-downloads.adblockplus.org/easyprivacy.txt
+#https://easylist-downloads.adblockplus.org/antiadblockfilters.txt
+#https://easylist-downloads.adblockplus.org/fanboy-annoyance.txt
+#https://easylist-downloads.adblockplus.org/fanboy-social.txt
+#https://easylist-downloads.adblockplus.org/malwaredomains_full.txt
+
+DOMAINSSRC="
+https://mirror.cedia.org.ec/malwaredomains/justdomains
+https://mirror.cedia.org.ec/malwaredomains/immortal_domains.txt
+https://ransomwaretracker.abuse.ch/downloads/RW_DOMBL.txt
+https://feodotracker.abuse.ch/blocklist/?download=domainblocklist
+https://zeustracker.abuse.ch/blocklist.php?download=baddomains
+"
+
+
+
+echo ""
+echo "[zerohosts]: running"
+
+TMP=$(mktemp)
+
+echo "[zerohosts]: download lists"
+for URL in ${HOSTSSRC}; do
+ echo "$URL"
+ ${D} "${URL}" >> "$TMP"
+done
+
+for URL in ${DOMAINSSRC}; do
+ echo "$URL"
+ ${D} "${URL}" | \
+ awk '{print "0.0.0.0 " $1}' >> "$TMP"
+done
+
+# The following call sed several times. It is necessary because the
+# filter must be applied in order.
+
+echo "[zerohosts]: filter lists"
+sed -i -e 's/#.*$//g' $TMP
+# Remove ^M
+sed -i -e 's/\r//g' $TMP
+# Remove empty lines
+sed -i -e '/^[[:space:]]*$/d' $TMP
+# remove localhosts and ip6
+sed -i -e '/^.*:.*$/d' \
+ -e '/^127\.0\.0\.1[[:space:]]*localhost.*$/d' \
+ -e '/^255.*$/d' $TMP
+# remove surrounding quotation marks
+sed -i -e 's/\"//g' $TMP
+# 127.0.0.1 to 0.0.0.0
+sed -i -e 's/127.0.0.1/0.0.0.0/g' $TMP
+# remove lines with only one field, somes lists have this.
+sed -i -e '/^0\.0\.0\.0[[:space:]]*$/d' $TMP
+
+echo "[zerohosts]: write /etc/hosts"
+cat << EOF > /etc/hosts
+$(date '+# %Y-%m-%d %H:%M:%S')
+127.0.0.1 localhost
+::1 localhost
+0.0.0.0 0.0.0.0
+${MYHOSTS}
+
+$(tr -s '[:blank:]' < $TMP | sort -u)
+EOF
+
+chmod 0644 /etc/hosts
+
+echo "[zerohosts]: delete tmp file $TMP"
+rm $TMP
+
+echo "[zerohosts]: Bye :)"
+exit 0