summaryrefslogtreecommitdiffstats
path: root/set-background.sh
blob: e21fbea863995dec679f818b852ba9c6499e8819 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh
#----------------------------------------------------
# Version:      0.2.0
# Author:       Florian "Bluewind" Pritz <f-p@gmx.at>
#
# Copyright (C) 2008-2009 Florian Pritz
#
# Licensed under GNU General Public License v3
#   (see COPYING for full license text)
#    
#----------------------------------------------------
# Usage: set-background.sh <image-file>
# Sets background using feh and creates 
# symlink for slim
#----------------------------------------------------

if [ "" = $DISPLAY ]; then
	export DISPLAY=:0.0
fi

if [ "$1" = "" ] || [ "$1" = "-h" ]; then 
	notify-send -t 10000 "Background" "Usage: set-background &lt;file&gt;";
	exit 1
fi

cd "$(dirname "$1")"

FILE="$(pwd)/$(basename "$1")"

if [ -f $FILE ]; then
	echo "feh --bg-center ${FILE}" > "$HOME/.fehbg";
	rm "$HOME/backgrounds/current_bg";
	ln -sf "${FILE}" "$HOME/backgrounds/current_bg";
	source $HOME/.fehbg
else
	notify-send -t 10000 "Background" "Error: File \"${FILE}\" doesn't exist";
	exit 1  
fi