diff options
-rwxr-xr-x | 0x0 | 12 | ||||
-rw-r--r-- | LICENSE | 14 | ||||
-rwxr-xr-x | cflags | 5 | ||||
-rwxr-xr-x | check-world | 11 | ||||
-rwxr-xr-x | docker-ip | 8 | ||||
-rwxr-xr-x | find-broken-ln | 9 | ||||
-rwxr-xr-x | find-ebuild | 3 | ||||
-rwxr-xr-x | find-suid | 8 | ||||
-rwxr-xr-x | flac2mp3 | 4 | ||||
-rwxr-xr-x | flac2ogg | 4 | ||||
-rwxr-xr-x | ghcic | 48 | ||||
-rwxr-xr-x | hddstat | 3 | ||||
-rwxr-xr-x | ix | 12 | ||||
-rwxr-xr-x | logout-hook | 25 | ||||
-rwxr-xr-x | man2pdf | 6 | ||||
-rwxr-xr-x | mon | 12 | ||||
-rwxr-xr-x | pts-reload | 33 | ||||
-rwxr-xr-x | qr | 7 | ||||
-rw-r--r-- | readme.org | 2 | ||||
-rwxr-xr-x | screenshot | 6 | ||||
-rwxr-xr-x | screenshot-select | 6 | ||||
-rwxr-xr-x | toggle-touchpad | 10 | ||||
-rwxr-xr-x | toggle-trackpoint | 10 |
23 files changed, 258 insertions, 0 deletions
diff --git a/0x0 b/0x0 new file mode 100755 index 0000000..7e767b6 --- /dev/null +++ b/0x0 @@ -0,0 +1,12 @@ +#!/bin/sh + +url="https://0x0.st" +form="file=@" + +if [ -t 0 ] && [ -n "${1}" ]; then + form="${form}${1}" +else + form="${form}-" +fi + +curl --form "${form}" "${url}" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ee7d6a5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,14 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + diff --git a/cflags b/cflags new file mode 100755 index 0000000..ce1352e --- /dev/null +++ b/cflags @@ -0,0 +1,5 @@ +#!/bin/sh + +gcc -v -E -x c -march=native -mtune=native - </dev/null 2>&1 | + grep "cc1" | + sed -e 's/^.* - //g' diff --git a/check-world b/check-world new file mode 100755 index 0000000..cc92562 --- /dev/null +++ b/check-world @@ -0,0 +1,11 @@ +#!/bin/sh + +world="/var/lib/portage/world" + +[ -f "${world}" ] || exit + +while read -r line; do + if [ -n "$(qdepends --quiet --query "${line}")" ]; then + echo "${line}" + fi +done <"${world}" diff --git a/docker-ip b/docker-ip new file mode 100755 index 0000000..e4da369 --- /dev/null +++ b/docker-ip @@ -0,0 +1,8 @@ +#!/bin/sh + +for i in $(docker ps -q | awk '{print $1}'); do + ip=$(docker inspect --format="{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" "${i}") + name=$(docker ps | awk -v i="${i}" '/i/ {print $NF}') + + printf "%s\t%s\n" "${ip}" "${name}" +done diff --git a/find-broken-ln b/find-broken-ln new file mode 100755 index 0000000..8db7db9 --- /dev/null +++ b/find-broken-ln @@ -0,0 +1,9 @@ +#!/bin/sh + +if [ -t 1 ]; then + pattern="%p \033[38;5;4m=>\033[m \033[38;5;9m%l\033[m\n" +else + pattern="%p => %l\n" +fi + +find "${@}" -xtype l -printf "${pattern}" diff --git a/find-ebuild b/find-ebuild new file mode 100755 index 0000000..f285ebf --- /dev/null +++ b/find-ebuild @@ -0,0 +1,3 @@ +#!/bin/sh + +$EDITOR "$(portageq get_repo_path / gentoo)/$*" diff --git a/find-suid b/find-suid new file mode 100755 index 0000000..e8aa470 --- /dev/null +++ b/find-suid @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +IFS=':' read -r -a paths <<<"${PATH}" + +for directory in "${paths[@]}"; do + [ -d "${directory}" ] && + find "${directory}" -type f -perm /u+s,g+s -ls +done diff --git a/flac2mp3 b/flac2mp3 new file mode 100755 index 0000000..c3e2272 --- /dev/null +++ b/flac2mp3 @@ -0,0 +1,4 @@ +#!/bin/sh + +# shellcheck disable=SC1083 +parallel ffmpeg -i {} -qscale:a 0 -vn {.}.mp3 ::: ./*.flac diff --git a/flac2ogg b/flac2ogg new file mode 100755 index 0000000..5e586d8 --- /dev/null +++ b/flac2ogg @@ -0,0 +1,4 @@ +#!/bin/sh + +# shellcheck disable=SC1083 +parallel ffmpeg -i {} -qscale:a 6 -codec:a libvorbis -vn {.}.ogg ::: ./*.flac diff --git a/ghcic b/ghcic new file mode 100755 index 0000000..39c75e1 --- /dev/null +++ b/ghcic @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +red="$(echo -e '\033[91m')" +green="$(echo -e '\033[92m')" +yellow="$(echo -e '\033[93m')" +blue="$(echo -e '\033[94m')" +purple="$(echo -e '\033[95m')" +cyan="$(echo -e '\033[96m')" +default="$(echo -e '\033[0m')" + +arrow="s/->/${purple}&${default}/g;" +arrow_double="s/=>/${purple}&${default}/g;" +bracket_left="s/\[\([^09]\)/${blue}[${default}\1/g;" +bracket_left_double="s/\[\([^\[0-9]\)/${blue}[${default}\1/g;" +bracket_right="s/\]/${blue}&${default}/g;" +bullet="s/•/${yellow}&${default}/g;" +calc_operators="s/[+\-\/*]/${purple}&${default}/g;" +char="s/'\\?.'/${cyan}&${default}/g;" +double_colon="s/::/${purple}&${default}/g;" +error="s/error:/${red}error${default}:/g;" +fancy_quotes="s/‘[^’]*’/${cyan}&${default}/g;" +interactive="s/^<[^>]*>/${yellow}&${default}/g;" +line_numbers="s/([0-9]*):([0-9]*)/${blue}&${default}/g;" +load_done="s/done./${green}&${default}/g;" +load_failed="s/^Failed, modules loaded/${red}&${default}/g;" +parenthesis="s/[{}()]/${blue}&${default}/g;" +string="s/\"[^\"]*\"/${yellow}&${default}/g;" + +exec "$(command -v ghc)" --interactive ${1+"${@}"} 2>&1 | + sed " \ + $arrow \ + $arrow_double \ + $bracket_left \ + $bracket_left_double \ + $bracket_right \ + $bullet \ + $calc_operators \ + $char \ + $double_colon \ + $error \ + $fancy_quotes \ + $interactive \ + $line_numbers \ + $load_done \ + $load_failed \ + $parenthesis \ + $string \ + " diff --git a/hddstat b/hddstat new file mode 100755 index 0000000..a1faaa9 --- /dev/null +++ b/hddstat @@ -0,0 +1,3 @@ +#!/bin/sh + +nc localhost 7634 | sed -e 's/|//m' -e 's/||/ \n/g' | awk -F '|' '{print $1 " " $3 " " $4}' | sort diff --git a/ix b/ix new file mode 100755 index 0000000..51741d8 --- /dev/null +++ b/ix @@ -0,0 +1,12 @@ +#!/bin/sh + +url="http://ix.io" +form="f:1=" + +if [ -t 0 ] && [ -n "${1}" ]; then + form="${form}@${1}" +else + form="${form}<-" +fi + +curl --form "${form}" "${url}" diff --git a/logout-hook b/logout-hook new file mode 100755 index 0000000..9966129 --- /dev/null +++ b/logout-hook @@ -0,0 +1,25 @@ +#!/bin/sh + +to_rm=" + ${HOME}/.cache + ${HOME}/.ccls-cache + ${HOME}/.gdb_history + ${HOME}/.nvimlog + ${HOME}/.rnd + ${HOME}/.viminfo + ${HOME}/.wget-hsts + ${HOME}/VideoDecodeStats + ${HOME}/databases-incognito + ${HOME}/pgadmin.log + ${HOME}/shared_proto_db +" + +rm_existing() { + if [ -f "${1}" ] || [ -d "${1}" ]; then + rm -rf "${1}" || return + fi +} + +for i in ${to_rm}; do + rm_existing "${i}" || exit +done diff --git a/man2pdf b/man2pdf new file mode 100755 index 0000000..b8d8bd7 --- /dev/null +++ b/man2pdf @@ -0,0 +1,6 @@ +#!/bin/sh + +if command -v man >/dev/null 2>&1 && + command -v ps2pdf >/dev/null 2>&1; then + man -t "${1}" | ps2pdf -sPAPERSIZE="a4" -sOutputFile="${1}.pdf" - +fi diff --git a/mon b/mon new file mode 100755 index 0000000..8a5e667 --- /dev/null +++ b/mon @@ -0,0 +1,12 @@ +#!/bin/sh + +if command -v xrandr >/dev/null 2>&1; then + if xrandr | grep "VGA.* connected [0-9]*x[0-9]*+[0-9]*+[0-9]*" >/dev/null 2>&1; then + xrandr \ + --output VGA1 --off + else + xrandr \ + --output LVDS1 --auto \ + --output VGA1 --auto --right-of LVDS1 --rotate left + fi +fi diff --git a/pts-reload b/pts-reload new file mode 100755 index 0000000..20b1e77 --- /dev/null +++ b/pts-reload @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +if command -v xgetres >/dev/null 2>&1; then + declare BG FG + BG="$(xgetres background)" + FG="$(xgetres foreground)" + + for i in {0..15}; do + # shellcheck disable=SC2140 + declare "COLOR_${i}"="$(xgetres color"${i}")" + done + + declare SEQ= + for i in {0..15}; do + COLOR="COLOR_${i}" + SEQ+="\\e]4;${i};${!COLOR}\\e\\\\" + unset "COLOR_${i}" + done + SEQ+="\\e]10;${FG}\\e\\\\" + SEQ+="\\e]11;${BG}\\e\\\\" + SEQ+="\\e]708;${BG}\\e\\\\" + SEQ+="\\e]12;${FG}\\e\\\\" + unset BG FG + + shopt -s extglob + + for i in /dev/pts/*[0-9]; do + if [ -w "${i}" ]; then + printf %b "${SEQ}" >"${i}" + fi + done + unset SEQ +fi diff --git a/qr b/qr new file mode 100755 index 0000000..eeda047 --- /dev/null +++ b/qr @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ "${#}" -eq 0 ]; then + read -r i && set "${i}" +fi + +echo "${@}" | curl --form "f:1=<-" "qrenco.de" diff --git a/readme.org b/readme.org new file mode 100644 index 0000000..380d884 --- /dev/null +++ b/readme.org @@ -0,0 +1,2 @@ +* scripts +This will no longer be updated. Preserved for archival purposes. diff --git a/screenshot b/screenshot new file mode 100755 index 0000000..e101d3e --- /dev/null +++ b/screenshot @@ -0,0 +1,6 @@ +#!/bin/sh + +picdir="${XDG_PICTURES_DIR}/screenshots" +pic="${picdir}/$(date +%Y-%m-%d_%H-%M-%S).png" + +maim --format=png --hidecursor --quality 8 "${pic}" diff --git a/screenshot-select b/screenshot-select new file mode 100755 index 0000000..cab5947 --- /dev/null +++ b/screenshot-select @@ -0,0 +1,6 @@ +#!/bin/sh + +picdir="${XDG_PICTURES_DIR}/screenshots" +pic="${picdir}/$(date +%Y-%m-%d_%H-%M-%S).png" + +maim --format=png --hidecursor --quality 8 --select "${pic}" diff --git a/toggle-touchpad b/toggle-touchpad new file mode 100755 index 0000000..2ef7d1f --- /dev/null +++ b/toggle-touchpad @@ -0,0 +1,10 @@ +#!/bin/sh + +device="$(xinput list | grep -Eo 'TouchPad\s*id\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}')" +state="$(xinput list-props "${device}" | awk '/Device Enabled/ {print $4}')" + +if [ "${state}" -eq 1 ]; then + xinput disable "${device}" +else + xinput enable "${device}" +fi diff --git a/toggle-trackpoint b/toggle-trackpoint new file mode 100755 index 0000000..363ffa8 --- /dev/null +++ b/toggle-trackpoint @@ -0,0 +1,10 @@ +#!/bin/sh + +device="$(xinput list | grep -Eo 'TrackPoint\s*id\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}')" +state="$(xinput list-props "${device}" | awk '/Device Enabled/ {print $4}')" + +if [ "${state}" -eq 1 ]; then + xinput disable "${device}" +else + xinput enable "${device}" +fi |