dotfiles

config files and scripts
git clone git://git.hanetzok.net/dotfiles
Log | Files | Refs

setwallpaper (957B)


      1 #!/bin/bash
      2 
      3 wallpaper="$XDG_DATA_HOME"/wallpaper.png
      4 
      5 setbg() {
      6 	# get dominant color of wallpaper image
      7 	domcol="$(dominant_colours "$1" --no-palette --max-colours=1)"
      8 
      9 	# get display and image width
     10 	dpwidth="$(xrandr | grep '*' | awk '{print $1}' | sed 's/\(.*\)x.*/\1/')"
     11 	imgwidth="$(LANG=C exiv2 -q $1 | grep "Image size" | awk '{print $4$5$6}' | sed 's/\(.*\)x.*/\1/')"
     12 	if [ "$dpwidth" -gt "$imgwidth" ]; then
     13 		# if the display width is greater then the image width, we want the image centered...
     14 		hsetroot -solid "$domcol" -center $wallpaper
     15 	else
     16 		# ...otherwise make it fit the screen
     17 		hsetroot -cover $wallpaper
     18 	fi
     19 }
     20 
     21 # check if a file is given as argument and set it as new default
     22 [[ ! -z "$1" ]] && [[ -f "$1" ]] && magick "$1" "$wallpaper" && notify-send "Set new wallpaper..."
     23 
     24 # check if there is a file at our default wallpaper location
     25 [[ -f "$wallpaper" ]] || { notify-send "No wallpaper file found!"; exit 1; }
     26 
     27 setbg $wallpaper