Skip to content

Instantly share code, notes, and snippets.

@Trucido
Last active August 29, 2015 14:22
Show Gist options
  • Save Trucido/af7befb9a86fa9befe6a to your computer and use it in GitHub Desktop.
Save Trucido/af7befb9a86fa9befe6a to your computer and use it in GitHub Desktop.
This script moves webkitgtk+ browser cache directories to /tmp/cache/, it should be run on user login.
#!/bin/bash
#
# Copyright (c) 2015 Tara Nupsumass
# This script is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# <http://www.gnu.org/licenses/>
#
# This script moves webkitgtk+ browser cache directories to /tmp/cache/, it should be run on user login.
# define our directories
EPIPH_CACHE="$HOME/.cache/epiphany-browser"
EPIPH_TMP_CACHE="/tmp/cache/epiphany-browser"
MIDO_CACHE="$HOME/.cache/midori"
MIDO_TMP_CACHE="/tmp/cache/midori"
EPIPHANY="`which "epiphany"`"
MIDORI="`which "midori"`"
function EP
{
# check if exists and is executable
if [[ -x $EPIPHANY ]]; then
echo "$EPIPHANY found."
# not found, abandoning this function.
else echo "EPIPHANY not installed, skipping."; return
fi
# check if tmp cache exists, otherwise create it.
if [ ! -e $EPIPH_TMP_CACHE ]; then
echo "$EPIPH_TMP_CACHE not found, creating it"
mkdir -p "$EPIPH_TMP_CACHE"
# if tmp cache directory already exists, skip creating it
else
echo "$EPIPH_TMP_CACHE found, not creating it."
fi
# remove any remaining cache and symlink it
if [ -d $EPIPH_CACHE ]; then
echo "existing $EPIPH_CACHE found, deleting it."
rm -Rf "$EPIPH_CACHE"
echo "symlinking $EPIPH_TMP_CACHE to $EPIPH_CACHE"
ln -s "$EPIPH_TMP_CACHE" "$EPIPH_CACHE"
else
echo "existing $EPIPH_CACHE not found, good to go! symlinking $EPIPH_TMP_CACHE to $EPIPH_CACHE"
ln -s "$EPIPH_TMP_CACHE" "$EPIPH_CACHE"
fi
}
function MD
{
# check if exists and is executable
if [[ -x $MIDORI ]]; then
echo "$MIDORI found."
# not found, abandoning this function.
else echo "MIRODI not installed, skipping"; return
fi
# check if tmp cache exists, otherwise create it.
if [ ! -e $MIDO_TMP_CACHE ]; then
echo "$MIDO_TMP_CACHE not found, creating it"
mkdir -p "$MIDO_TMP_CACHE"
# if tmp cache directory already exists, skip creating it
else
echo "$MIDO_TMP_CACHE found, not creating it."
fi
# remove any remaining cache and symlink it
if [ -d $MIDO_CACHE ]; then
echo "existing $MIDO_CACHE found, deleting it."
rm -Rf "$MIDO_CACHE"
echo "symlinking $MIDO_TMP_CACHE to $MIDO_CACHE"
ln -s "$MIDO_TMP_CACHE" "$MIDO_CACHE"
else
echo "existing $MIDO_CACHE not found, good to go! symlinking $MIDO_TMP_CACHE to $MIDO_CACHE"
ln -s "$MIDO_TMP_CACHE" "$MIDO_CACHE"
fi
}
# functions loaded, running them!
EP
MD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment