summaryrefslogtreecommitdiff
path: root/themer.sh
blob: b36c444afa6d2e0677b0315f43fd5a9a8de8acfb (plain) (blame)
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
#!/bin/sh

add_theme() {
	indir="$1"
	[ -z "$indir" ] && indir=$HOME/downloads
	outdir=$HOME/.local/share/wallpapers
	[ ! -d "$indir" ] && exit 1
	[ ! -d "$outdir" ] && mkdir -p "$outdir"
	sxiv -rot "$indir" | while read infile; do
		outfile="$outdir"/$(basename "$infile")
		convert "$infile" -geometry '1920x1080^' -gravity center -crop 1920x1080+0+0 "$outfile"
		wpg -a "$outfile"
	done
}

set_theme() {
	theme=$(sxiv -rot $HOME/.config/wpg/wallpapers)
	[ -z "$theme" ] && exit 4
	wpg -s "$theme" &
	convert -verbose -background black -vignette 100x65000 "$theme" $HOME/.local/share/wallpapers/lock.png &
}

reapply_theme() {
	wpg -s "$(wpg -c)"
}

[ "$1" = "-r" ] && reapply_theme && exit
[ "$1" = "-a" ] && add_theme "$2"
[ "$1" = "-s" ] && set_theme
wait