Skip to content

Instantly share code, notes, and snippets.

@goodevilgenius
goodevilgenius / upload_desktop_to_picasa.sh
Last active October 26, 2017 14:42
[Desktop Upload] This script uploads your current desktop as an image to a Picasa (or Google+) album called "Desktop Images".It requires ImageMagick (import), and googlecl (https://code.google.com/p/googlecl/).I use this for this album: https://picasaweb.google.com/100936838106083783573/DesktopImages #desktop
#!/bin/bash
file=/tmp/desktop-`date +%s`.png
echo -n "Capturing image in ... "
for i in {3..1}
do
echo -n "$i ... "
sleep 1
done
@goodevilgenius
goodevilgenius / jsmin.google.sh
Last active October 26, 2017 14:40
[jsmin] Minify javascript using Google's Closure Compiler. Requires curl #web #development
#!/bin/sh
if [ -z "$1" -o ! -f "$1" ]
then
echo "you must specify a valid file" >&2
exit 1
fi
curl --data-urlencode js_code@"$1" \
-d compilation_level=SIMPLE_OPTIMIZATIONS \
@goodevilgenius
goodevilgenius / cssmin.sh
Last active October 26, 2017 14:40
[cssmin] Minify css using cssminifier.com. Requires curl #web #development
#!/bin/sh
if [ -z "$1" -o ! -f "$1" ]
then
echo "you must specify a valid file" >&2
exit 1
fi
curl --post301 --post302 -s -L \
--data-urlencode input@"$1" \
@goodevilgenius
goodevilgenius / combine_folders.sh
Last active October 26, 2017 14:40
[combine folders] At one time, I had a need to combine files from multiple directories into one directory on a Mac. #obsolete
#!/bin/bash
dest="$(readlink -f "$1")"
shift
if [ ! -d "$dest" ]
then
echo "$dest is not a valid directory" >&2
exit 1
fi
@goodevilgenius
goodevilgenius / random_wallpaper.sh
Last active October 26, 2017 14:39
[Random Wallpaper] Scraper to get a random wallpaper from various websites. Most are broken. Uses fbsetbg (fluxbox) and gsettings (Gnome 3/Unity) to set background. #desktop #obsolete
#!/bin/bash
IMG_DIRECTORY="${HOME}/.random_wallpaper"
function setit() {
fbsetbg -a "$(readlink -f "$1")"
gsettings set org.gnome.desktop.background picture-uri "file://$(readlink -f "$1")"
}
function flik() {
@goodevilgenius
goodevilgenius / pushover.sh
Last active May 15, 2021 23:32
[bash pushover] Command-line script to send a notification to your mobile device via Pushover. Requires curl. #pushover #notifications #obsolete
#!/bin/bash
# Assuming you name the file pushover.sh, place somewhere within your $PATH, then chmod +x /path/to/pushover.sh
# Invoke with: pushover.sh [-d device_name] [-t Title] [-u Url] [-ut URL Title] [-p] [-ts timestamp] "notifcation text"
token=""
user=""
test -f ~/.pushover && source ~/.pushover # Put your API token and user key here
@goodevilgenius
goodevilgenius / addTag.sh
Last active October 26, 2017 14:38
[Email tagger] Used from a procmail filter to tag email, using the X-Tags header. Reads email from stdin. Writes tagged email to stdout. Usage: addTags.sh tag1 tag2 tag3 ... #email #procmail
#!/bin/bash
if [ -z "$1" ]
then
cat
exit
fi
tmp=$(mktemp -t addTag.XXXXXX)
@goodevilgenius
goodevilgenius / addfortune.sh
Last active October 26, 2017 14:36
[Add fortune] Add a "fortune" to a fortune file, to be used with the Unix fortune program. fortune is read from stdin, and any arguments are taken to be the source of the quote. #obsolete
#!/bin/bash
# Now included in https://github.com/goodevilgenius/fortune-drj/
DIR="${HOME}/.fortune/files"
FILE="quotes-$(date +%Y-%m)"
quote=`mktemp`
[ ! -d "$DIR" ] && mkdir -p "$DIR"
@goodevilgenius
goodevilgenius / wmctrlplus.sh
Last active October 26, 2017 14:35
[wmctrlplus] A convenience script to make some things easier with wmctrl. Probably your window manager can do this stuff already, though. I don't use it anymore #desktop #obsolete
#!/bin/sh
function GetNext() {
CURR=$(wmctrl -d | grep '^[[:digit:]]*[[:blank:]]*\*' | sed 's/^\([[:digit:]]*\).*/\1/')
LAST=$(wmctrl -d | tail -1 | sed 's/^\([[:digit:]]*\).*/\1/')
TOTAL=$(expr $LAST + 1)
NEXT=$(expr $(expr $CURR + 1) % $TOTAL)
echo $NEXT
}
@goodevilgenius
goodevilgenius / shrinkMKV.sh
Last active October 26, 2017 14:35
[vid shrinker] This shrinks videos. The result is a 320x240 mkv with xvid video and ogg audio. Good for putting on a device with a small screen and limited memory. #video #obsolete
#!/bin/sh
while [ "$#" -ne 0 ]; do
EXT="${1##*.}"
FILENAME=`basename "$1" .${EXT}`
TMP=`mktemp`
ffmpeg -i "$1" -s 320x240 -vcodec xvid -an "${TMP}.avi"
ffmpeg -i "$1" -vn "${TMP}.wav"