Skip to content

Instantly share code, notes, and snippets.

@raidzero
raidzero / blocklist-update.sh
Created February 25, 2014 04:13
Script to update transmission blocklists using a list of blocklists from iblocklist.com
#!/bin/sh
:<<END_DOC
blocklist updater - for transmission
Written by raidzero for linux
BLOCKLIST_HOME is the directory where transmission keeps its blocklists
END_DOC
BLOCKLIST_HOME=~/.config/transmission/blocklists
@raidzero
raidzero / paswitch.sh
Created March 3, 2014 00:08
Pulseaudio: switch all apps playing sound to play on a specific device
#!/bin/sh
# switch all apps playing sound to a given device.
# usage: paswitch.sh [HEADPHONES|SPEAKERS] (really meant to be bound a key shortcut)
# these are the sink names of the devices we want to use
HEADPHONES="alsa_output.usb-FiiO_DigiHug_USB_Audio-01-Audio.analog-stereo"
SPEAKERS="alsa_output.pci-0000_00_1b.0.analog-stereo"
# get a list of ID's of everything playing sound
INPUTS=`pacmd list-sink-inputs | grep index | cut -d ':' -f2 | sed 's/^ *//g'`
@raidzero
raidzero / hottestcore.sh
Created March 3, 2014 00:15
CPU core temperature monitoring utility
#!/bin/sh
# cpu core temp monitor tool for my i7 4930k
SENSOR="coretemp-isa-0000"
COLUMNS=`tput cols`
if [ "$COLUMNS" -lt 106 ]; then
echo "Terminal needs to be 106 columns wide for hottestcore to work correctly."
exit 1
fi
@raidzero
raidzero / getID.sh
Created March 3, 2014 00:22
Print game ID of wii/gamecube file and download game cover artwork
#!/bin/sh
# this script will print internal game name and ID to the screen for gamecube/wii games and download artwork
ARTWORK_DIR=~/storage/ROMs/artwork
function die()
{
rm /tmp/game{Name,ID,WBFS} &> /dev/null
echo $1
exit $2
@raidzero
raidzero / grub2-reboot-do.sh
Last active August 29, 2015 13:56
Openbox pipe menu: grub2 reboot/hibernate
#!/bin/sh
CHOICE=$1
HIBERNATE=$2
if [ "$CHOICE" == 9999 ]; then
STAYOFF="STAYOFF"
fi
if [ -z "$HIBERNATE" ]; then
#su raidzero -c '/home/raidzero/bin/sess.sh save'
@raidzero
raidzero / vb_launch.py
Created March 3, 2014 00:29
Openbox pipe menu: launch Virtualbox VM's
#!/usr/bin/python
import os
"""Pipe Menu to launch VirtualBox Machines"""
# build the list of VM's
VM_LIST = os.listdir("/home/raidzero/.VirtualBox/Machines")
print """<openbox_pipe_menu>
@raidzero
raidzero / kbd_repeat_dialog.sh
Created March 3, 2014 00:32
Xdialog for adjusting keyboard repeat options
#!/bin/sh
FILE=~/.tmp/kbdfile
DELAY=$1
RATE=$2
DEFAULTDELAY=`xset q | grep "auto repeat delay" | awk '{print $1" "$2" "$3" "$4}' | cut -d ':' -f2 | sed 's/ //g'`
DEFAULTRATE=`xset q | grep "repeat rate" | awk '{print $7}'`
@raidzero
raidzero / weather.sh
Created March 3, 2014 00:35
Get weather data from yahoo weather (meant for conky)
#!/bin/sh
# USAGE: weather.sh [NULL|both|forecast]
LOCATION_URL="http://weather.yahooapis.com/forecastrss?p=USCO0105&u=" #Denver
WEATHER=`curl -s "$LOCATION_URL" | grep "F<BR" | awk -F ' F<BR' '{print$1}'`
TOMORROW=`date --date="tomorrow" +%a`
FORECAST=`curl -s "$LOCATION_URL" | grep -oE "^[A-Z][a-z]{2} - .*-?[0-9]{1,3}" | grep "^$TOMORROW" | sed -r 's_High: \<(-?[0-9]{1,3})\> Low: \<(-?[0-9]{1,3})\>_\2\/\1_'`
FORECAST=`echo $FORECAST | sed -r ' \
@raidzero
raidzero / lastboot.sh
Created March 3, 2014 00:38
Get last boot time
#!/bin/sh
# get the last boot time and display it in 12 hour format
# USAGE: lastboot.sh [date|time|both]
LASTBOOT_LINE=`last | grep reboot | head -n 1`
DATE=`echo $LASTBOOT_LINE | awk '{print$5,$6,$7}'`
TIME=`echo $LASTBOOT_LINE | awk '{print$8}'`
#convert to 12 hour
HOUR=`echo $TIME | cut -d : -f1`
@raidzero
raidzero / verscomp.c
Last active August 29, 2015 13:56
Version number comparator
/*
* Uses stdin to evaluate a statement such as "2.5.3" <= 2.4". Returns strings "True" or "False" to terminal
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#define DEBUG 0