summaryrefslogtreecommitdiffstats
path: root/set-background.sh
blob: 903de1cd00f03a1ae3a19e1b1ef3b7bf0a05c49b (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 <flo@xssn.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