#!/bin/bash # $Id: /mirror/bin/trunk/ifliftwall 94 2008-07-28T13:44:06.642967Z thuswa $ # Version: 0.6.1 # Last modified Mon Jul 28 15:43:39 2008 on violator # Update count: 303 # # Copyright (C) 2008 by Albert Thuswaldner, thuswa gmail com # # This program 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 3 of the License, or # (at your option) any later version. # # This program 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. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the # Free Software Foundation, Inc., # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # Purpose: # # Ifliftwall is a bash script which will choose and set a picture # from www.interfacelift.com as your KDE desktop wallpaper. # If you set it to autostart it will give you a new fresh background # as you login in, on a daily basis. # The wallpaper pictures are saved in the /tmp directory, a history of one # week back in time is kept. The script does some basic checking # if the site is reachable and if the wallpaper already is the current one. # A config file ~/.ifliftwall is used to store your desktop settings. # # Usage: # 1.) put in ~/bin or somewhere in your path # 2.) make executable # 3.) Save your desktop settings by running: # ifliftwall --setting # 3.1) See Note #2 below for valid desktop settings # 3.2) See also Note #3 below for valid values for # 4.) test it! # 5.) (at your option) run: ifliftwall --set-auto # to make it autostart at login # 6.) Have a great time - all the time! ;) # # Tested: # # On OpenSUSE 10.3, should work on most Linux distros, and other UNIX flavours # too albeit the arguments for the ping command have to be modified. # # # Note #1: The picture files that are downloaded will be stored in the # /tmp/kde- directory as default. The location can # however be changed with the "--set-tmp" option. This script # does not delete any of these files, so it is up to you. # However, the way the file name is constructed: # "ifliftwall.00N", where N equals the current weekday (N=1..7), # does so that only a maximum of one week of wallpapers will be # stored on your computer. # # Note #2: List of resolution. If your desktop size is not listed below # try using the closest higher resolution. # # Aspect Desktop Resolution # -------- ------------------ # widescreen: 2560x1600 1920x1200 1680x1050 1440x900 1280x800 # fullscreen: 1600x1200 1400x1050 1280x1024 1280x960 1024x768 # # Note #3: Sort can have the following values: # date = latest wallpapers # downloads = most downloaded # ratings = highest rating # comments = most commented # random = random sort # # Note #4: The wallpapers that are downloaded may be used in accordance with # http://interfacelift.com/site/license.html # please read this. # Get date in correct format # ------------------------------------------------------------------------ WDN=`date +%u` #Weekday number PDN=$(expr 8 - $WDN) #Picture number # Set temp file name # ------------------------------------------------------------------------ TMPTPL=/ifliftwall.00 CONFILE=$HOME/.ifliftwall # Default settings # ------------------------------------------------------------------------ MYSELF= ASPECT="widescreen" #screen aspect RESWTH=1280 #screen width RESHGT=800 #screen height SORT="date" #correspons to latest TMPDIR=/tmp/kde-$USER #dir where wallpapers are stored FORCE=0 #No unconditional update #"--auser $3 --all-sessions" # Options section # ------------------------------------------------------------------------ while [ $# -gt 0 ]; do case "$1" in "--force") # Update wallpaper anyway FORCE=1 shift ;; "--set-auto") # Set ifliftwall to autostart ln -s `which $0` $HOME/.kde/Autostart/ifliftwall shift ;; "--user") MYSELF="--user $2 --all-sessions" shift; continue; ;; "--set-tmp") # Set tmp dir where pictures are stored if [ -f $CONFILE ] then . $CONFILE fi echo -e "ASPECT=$ASPECT\nRESWTH=$RESWTH\nRESHGT=$RESHGT\nSORT=$SORT\nTMPDIR=$2" > $HOME/.ifliftwall shift; shift; shift; shift; shift; ;; "--revert") # Revert back to yesterdays picture WDN=`expr $WDN - 1` if [ $WDN -eq 0 ] then WDN=7 fi TMPFILE=$TMPDIR$TMPTPL$WDN dcop $MYSELF kdesktop KBackgroundIface setWallpaper $TMPFILE 8 # 8=Scale and crop exit ;; "--settings") # Set resolution if [ $# -eq 5 ] then if [ -f $CONFILE ] then . $CONFILE fi echo -e "ASPECT=$2\nRESWTH=$3\nRESHGT=$4\nSORT=$5\nTMPDIR=$TMPDIR" > $HOME/.ifliftwall shift; shift; shift; shift; shift; else echo Please enter your screen settings: aspect width height echo Example: ifliftwall --settings widescreen 1280 800 date exit fi ;; *) shift ;; esac done; # Read config file # ------------------------------------------------------------------------ if [ -f $CONFILE ] then . $CONFILE else echo No config file ~/.ifliftwall found echo Please enter your screen settings: aspect width height sort echo Example: ifliftwall --settings widescreen 1280 800 random exit fi # Set link specifics # ------------------------------------------------------------------------ SITE=interfacelift.com PAGE=$SITE"/wallpaper_beta/downloads/"$SORT"/"$ASPECT"/"$RESWTH"x"$RESHGT"/" echo $PAGE # Get current wallpaper # ------------------------------------------------------------------------ CURRPIC=`dcop $MYSELF kdesktop KBackgroundIface currentWallpaper 0` TMPFILE=$TMPDIR$TMPTPL$WDN echo $CURRPIC echo $TMPFILE if [ "$CURRPIC" != "$TMPFILE" ] || [ $FORCE -eq 1 ]; then # Check if interfacelift.com is reachable # ------------------------------------------------------------------------ if ping -c 1 -q -W 2 -w 2 $SITE >/dev/null then # extract picture of the day url POTD=`wget -qO - $PAGE | grep "href=\"/dl/wallpaper" | \ gawk -F'