summaryrefslogtreecommitdiffstats
path: root/set-background.sh
blob: 780b0dedb68d1800712bc2320924aa41e955c7c9 (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
#!/bin/sh
#----------------------------------------------------
# Version:      0.2.0
# Author:       Florian "Bluewind" Pritz <f-p@gmx.at>
#
# Licensed under WTFPL v2
#   (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