Archive

Gnome Background Rotator

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading ... Loading ...

Version: v0.5

Summary: This is an easy way to make your desktop rotate images. All you need to do is specify a background location, and it will find all the *.jpg, *.png, and *.svg files in that folder and display them in a random order.

Requirements:

  • Gnome
  • find
  • sed
  • wc
  • whoami

Code:

#!/bin/bash
 
#User Settable Variables (Defaults)
BACKGROUND_PATH="/usr/share/.backgrounds/"
BACKGROUND_STYLE="zoom" ## 'zoom', 'tiled', 'scaled', 'stretched', 'centered'
CYCLE_TIME="7"
TEMP_LOG="/tmp/rotate${RANDOM}.log"
LOG="/tmp/.`whoami`-gnome-background-rotator"
 
##Write Date & Time to Log File
echo "-------------------------------------" > "${LOG}"
echo "`date +\%B\ \%d,\ \%Y`" >> "${LOG}"
echo "-------------------------------------" >> "${LOG}"
 
USAGE="Usage: ${0} -p <SOURCE_DIRECTORY> -t <CYCLE_TIME> -k <KEYWORD>"
 
echo "Gnome Background Rotator"
echo "Scripted by Blake Johnson"
echo "http://www.simplescripts.net/"
echo
 
while getopts ':p:k:t:h' OPTION; do
	case ${OPTION} in
		p) BGPATH="${OPTARG}";;
		k) KEYWORD="${OPTARG}";;
		t) CTIME="${OPTARG}";;
		h) echo "${USAGE}" >&2
			exit 2;;
		\?) echo "Unknown option \"-${OPTARG}\"." >&2
			echo ${USAGE};;
		:) echo "Option \"-${OPTARG}\" needs an argument." >&2
  			echo ${USAGE}
  			exit 2;;
  		*) echo ${USAGE}
  			exit 2;;
  	esac
done
 
if [ "$BGPATH" ] #Check to see if another background source was given.
then
	if [ -d "$BGPATH" ]
	then
		BACKGROUND_PATH="${BGPATH}"
	else
		echo "Unable to continue.  Source specified is not a (readable) directory."
		exit
	fi
fi
 
if [ "$CTIME" ] #Check to see if another cycle time was given.
then
	if [ "$CTIME" -gt 0 ]
	then
		CYCLE_TIME="${CTIME}"
	else
		echo "Unable to continue.  Time given is not a valid number."
		exit
	fi
fi
 
gconftool-2 -s --type=string /desktop/gnome/background/picture_options ${BACKGROUND_STYLE}
 
#Search for images and create a temporary logfile of all matches
if [ "$KEYWORD" ]
then
	find ${BACKGROUND_PATH} -iname "*${KEYWORD}*.jpg" -or -iname "*${KEYWORD}*.png" -or -iname "*${KEYWORD}*.svg" > ${TEMP_LOG}
else
	find ${BACKGROUND_PATH} -iname "*.jpg" -or -iname "*.png" -or -iname "*.svg" > ${TEMP_LOG}
fi
 
LowerBound=1
RandomMax=32767
UpperBound=$(cat ${TEMP_LOG} | wc -l)
 
if [ $UpperBound -gt 0 ] #Check to make sure 1 or more results have been returned.
then
	echo "Starting to rotate through ${UpperBound} images(s)."
else
	echo "No images found.  Please change directories, or try another keyword."
	exit
fi
 
while [ "true" ]
	do
		# Choose a random line number (any number from 1 to the length of the file)
		RandomLine=$(( ${LowerBound} + (${UpperBound} * ${RANDOM}) / (${RandomMax} + 1) ))
 
		# Use sed to grab the random line
		IMAGE=$(sed -n "$RandomLine{p;q;}" "${TEMP_LOG}")
 
		if [ -r $IMAGE ]
		then	
        		echo "Changing background to: ${IMAGE}"
        		gconftool-2 -s --type=string /desktop/gnome/background/picture_filename "${IMAGE}"
        		sleep ${CYCLE_TIME}
        	else
        		echo "Unable to change the background to: ${IMAGE}"
        		echo "The background either does not exist anymore, or the permissions to it are denied."
        	fi
	done
done

Changes:
v0.5: Ability to adjust cycle-time and background directory at command line, and also specify a background keyword. More checks added to make sure everything works as expected.
v0.4: Minor fixes.
v0.3: Backgrounds are now randomized.
v0.2: Minor fixes.
v0.1: Initial release.

Credits: Special thanks to Kevin Warns for implementing the randomization feature.

FirefoxUpdater (v0.2)

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Summary: Want an easy way to update Firefox to the latest (nightly) build? Want it to automatically update itself? Set this script as a cron job to run nightly, and all that will be taken care of. This can also be used as a way of pushing out Firefox to other computers.

Requirements:

  • Firefox
  • wget

Code:

#!/bin/bash
MARDIRURL="http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk"
MARFILENAME="firefox-3.0b3pre.en-US.linux-i686.complete.mar"
 
cd /tmp
wget "${MARDIRURL}/${MARFILENAME}"
mv "${MARFILENAME}" "/usr/lib/firefox-updater/update.mar"
cd "/usr/lib/firefox/"
../firefox-updater/updater ../firefox-updater 0
rm "/usr/lib/firefox-updater/update.mar"

Rockbox Updater (v0.2)

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Summary: Use this simple shell script to update the build of Rockbox on your DAP. Just change the variables at the top, and you should be good to go.

Requirements:

  • Linux
  • wget
  • unzip

Code:

#!/bin/bash
RBMOUNTPOINT="/media/IHP-100"
RBZIPURL="http://build.rockbox.org/dist/build-h300/rockbox.zip"  ##Filename must be rockbox.zip.
cd "${TMPDIR}"
wget "${RBZIPURL}"
cd "${RBMOUNTPOINT}/"
unzip -o "${TMPDIR}/rockbox.zip"
rm "${TMPDIR}/rockbox.zip"

Fix Hosts File (v1.0)

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 4.00 out of 5)
Loading ... Loading ...

Summary: This batch file will make it a bit easier to fix your ‘hosts’ file.

Requirements:

  • Windows 2000 / XP / Vista

Code:

@echo off
cls
echo Fix the Host File
echo By Blake Johnson
echo http://www.blakeanthonyjohnson.com
echo.
echo.
echo Are you blocked from a specific web site?  Find the domain name and
echo if it is in the list, remove it.  Problem should then be solved.
echo. 
pause
echo.
echo Remove Read-only and System attributes from the Hosts file...
attrib -s -r %windir%\system32\drivers\etc\hosts
echo Done.
echo.
echo Open the Hosts file for editing...
notepad %windir%\system32\drivers\etc\hosts
echo Done.
echo.
echo Apply the Read-only and System attributes to the Hosts file...
attrib +s +r %windir%\system32\drivers\etc\hosts
echo Done.
echo.
echo.
echo Assuming you made the changes you intended to make, you should
echo be good to go.
echo.
pause




User Agent: CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
Character Encoding: UTF-8
Generated: 09/07/2010 22:59:12 UTC
Rendering Time: 0.905 seconds.