# Misc scripts
-This is an assorted collection of simple scripts to be available on `$PATH`.
+This repository is used as an assorted collection of simple scripts to be
+available on `$PATH`.
+++ /dev/null
-#!/bin/bash
-#
-# Image galleries: a wrapper for sxiv(1).
-#
-
-# Parameters
-BASENAME="`basename $0`"
-IMAGES="$HOME/data/images"
-GALLERY="${1:-$IMAGES}"
-
-# Check
-if [ "$GALLERY" != "-" ] && [ ! -d "$GALLERY" ]; then
- echo "$BASENAME: path not found: $GALLERY"
- exit 1
-elif ! which sxiv &> /dev/null; then
- echo "$BASENAME: please install sxiv"
- exit 1
-fi
-
-# Dispatch
-# Option -o allows piping the selection output to other tools
-sxiv -t -q -b -o -r $GALLERY 2> /dev/null
+++ /dev/null
-#!/bin/sh
-#
-# This is a placeholder command so xcal does not give errors when calling icalbuddy
-# See https://github.com/alxppp/xcal
-# http://hasseg.org/icalBuddy/
-
-# Do nothing, successfully
-/bin/true
+++ /dev/null
-/home/rhatto/.config/luakit/contrib/luakit-plugins/tools/adblock-update.sh
\ No newline at end of file
+++ /dev/null
-#!/bin/bash
-#
-# Parses DHCP options from OpenVPN to update resolv.conf.
-# To use set as 'up' and 'down' script in your openvpn config:
-# up /etc/openvpn/update-resolv-conf
-# down /etc/openvpn/update-resolv-conf
-#
-# credit:
-# * Thomas Hood <jdthood@yahoo.co.uk>
-# * Chris Hanson
-# * chlauber@bnc.ch
-#
-# Licensed under the GNU GPL
-
-[ -x /sbin/resolvconf ] || exit 0
-
-case $script_type in
- up)
- for optionname in ${!foreign_option_*} ; do
- option="${!optionname}"
- echo $option
- part1=$(echo "$option" | cut -d " " -f 1)
- if [ "$part1" == "dhcp-option" ] ; then
- part2=$(echo "$option" | cut -d " " -f 2)
- part3=$(echo "$option" | cut -d " " -f 3)
- if [ "$part2" == "DNS" ] ; then
- IF_DNS_NAMESERVERS="$IF_DNS_NAMESERVERS $part3"
- fi
- if [ "$part2" == "DOMAIN" ] ; then
- IF_DNS_SEARCH="$part3"
- fi
- fi
- done
- R=""
- if [ "$IF_DNS_SEARCH" ] ; then
- R="${R}search $IF_DNS_SEARCH\n"
- fi
- for NS in $IF_DNS_NAMESERVERS ; do
- R="${R}nameserver $NS"
- done
- echo -n "$R" | /sbin/resolvconf -a "${dev}.inet"
- ;;
- down)
- /sbin/resolvconf -d "${dev}.inet"
- ;;
-esac
+++ /dev/null
-#!/bin/sh
-# from https://geoff.greer.fm/2017/07/16/thinkpad-x62/
-
-# Disable the NMI watchdog
-echo '0' > '/proc/sys/kernel/nmi_watchdog';
-
-# Runtime power management for I2C devices
-for i in /sys/bus/i2c/devices/*/device/power/control ; do
- echo auto > ${i}
-done
-
-# Runtime power-management for PCI devices
-for i in /sys/bus/pci/devices/*/power/control ; do
- echo auto > ${i}
-done
-
-# Runtime power-management for USB devices
-for i in /sys/bus/usb/devices/*/power/control ; do
- echo auto > ${i}
-done
-
-# Low power SATA
-for i in /sys/class/scsi_host/*/link_power_management_policy ; do
- echo min_power > ${i}
-done
-
-# Disable Wake-on-LAN on ethernet port
-#ethtool -s wlan0 wol d;
-#ethtool -s eth0 wol d
-
-#Enable Audio codec power management
-echo '1' > '/sys/module/snd_hda_intel/parameters/power_save';
-
-# Low power wireless
-iw dev wlan0 set power_save on
+++ /dev/null
-#/bin/sh
-#
-# SRI Hash Generator
-#
-
-# Parameters
-BASENAME="`basename $0`"
-URI="$1"
-
-# Check
-if [ -z "$URI" ]; then
- echo "usage: $BASENAME <file-or-url>"
- exit 1
-fi
-
-# Get file
-if echo "$URI" | grep -q '^http'; then
- echo "downloading $URI and generating hash..."
- HASH="`curl $URI | openssl dgst -sha384 -binary | openssl base64 -A`"
- echo ""
-else
- if [ -e "$URI" ]; then
- # See https://www.srihash.org/
- HASH="`openssl dgst -sha384 -binary $URI | openssl base64 -A`"
- else
- echo "file not found: $URI"
- exit 1
- fi
-fi
-
-# Generate
-cat <<EOF
-<script src="$URI" integrity="sha384-$HASH" crossorigin="anonymous"></script>
-EOF
+++ /dev/null
-#!/bin/bash
-#
-# Simple wrapper around wttr.in
-#
-
-# Parameters
-BASENAME="`basename $0`"
-PROGRAM="$1"
-CACHE="$HOME/.local/share/weather"
-
-# Load config
-source $HOME/.custom/wttr.in.conf || exit 1
-
-# weather-forecast service query
-function weather_forecast_query {
- # Make sure everything we need exists
- mkdir -p $CACHE
- touch $CACHE/weather-forecast.cur $CACHE/weather-forecast.prev
-
- # Save the previous forecast
- cp $CACHE/weather-forecast.cur $CACHE/weather-forecast.prev
- curl wttr.in/$LOCATION > $CACHE/weather-forecast.cur 2> /dev/null
-
- # Test if current forecast is empty, meaning
- # that we're probably ofline. In that case
- # we provide the previous output.
- if [ ! -s "$CACHE/weather-forecast.cur" ]; then
- cp $CACHE/weather-forecast.prev $CACHE/weather-forecast.cur
- fi
-
- # Display output
- cat $CACHE/weather-forecast.cur
-}
-
-# Main
-weather_forecast_query
+++ /dev/null
-#!/bin/bash
-#
-# Simple wrapper around brweather
-#
-
-# Parameters
-BASENAME="`basename $0`"
-PROGRAM="$1"
-CACHE="$HOME/.local/share/weather"
-
-# Command line args
-shift
-
-# Weather service query
-function weather_query {
- # Make sure everything we need exists
- mkdir -p $CACHE
- touch $CACHE/weather.cur $CACHE/weather.prev
-
- # Save the previous forecast
- cp $CACHE/weather.cur $CACHE/weather.prev
- weather $* > $CACHE/weather.cur 2> /dev/null
-
- # Test if current forecast is empty, meaning
- # that we're probably ofline. In that case
- # we provide the previous output.
- if [ ! -s "$CACHE/weather.cur" ]; then
- cp $CACHE/weather.prev $CACHE/weather.cur
- fi
-
- # Display output
- cat $CACHE/weather.cur
-}
-
-# Main
-if [ "$PROGRAM" == 'brweather' ]; then
- brweather $* | grep -v 'Erro.'
-else
- weather_query
-fi
+++ /dev/null
-#!/bin/bash
-#
-# Wifi initializer
-#
-
-#DEVICE="ath0"
-DEVICE="wlan0"
-
-if [ ! -z "$1" ]; then
- read -sp "Enter the WPA passphrase: " PASS
- echo ""
- wpa_passphrase $1 $PASS
-elif [ -f "wpa_supplicant.conf" ]; then
- sudo wpa_supplicant -B -Dwext -i$DEVICE -cwpa_supplicant.conf
- sudo dhclient $DEVICE
-fi
+++ /dev/null
-#!/bin/bash
-#
-# Youtube player from the command line
-# https://unix.stackexchange.com/questions/160212/watch-youtube-videos-in-terminal
-#
-
-# Parameters
-BASENAME="`basename $0`"
-URL="$1"
-
-# Check
-if [ -z "$1" ]; then
- echo "usage: $BASENAME <url>"
- exit 1
-fi
-
-# Run
-youtube-dl $URL -o - | mplayer -vo aa -monitorpixelaspect 0.5 -