Created
September 3, 2011 03:13
-
-
Save brycied00d/1190483 to your computer and use it in GitHub Desktop.
Multi-monitor background splitter and setter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Easy to use! | |
# awsetbg -u /path/to/multi-bg-set.sh -r /path/to/images | |
# Or, just call it by itself: /path/to/multi-bg-set.sh /path/to/some/image.ext | |
INPUT=$1 | |
if [ ! -f "$INPUT" ] | |
then | |
echo "Input file must exist!" | |
exit 1 | |
fi | |
# Can we use the md5sum caching? | |
if md5sum --version &> /dev/null | |
then | |
# Checking to see if there's already a complete split image ready | |
MD5=$(md5sum "$INPUT" 2>/dev/null | cut -f1 -d\ ) | |
if [ ! -f "/tmp/wallpaper-$MD5-0.jpg" -o \ | |
! -f "/tmp/wallpaper-$MD5-1.jpg" -o \ | |
! -f "/tmp/wallpaper-$MD5-2.jpg" -o \ | |
! -f "/tmp/wallpaper-$MD5-3.jpg" ] | |
then | |
# No file yet, or incomplete cache, so we'll build a new set. | |
nice -n 19 convert -crop 50%x50% +repage "$INPUT" /tmp/wallpaper-$MD5.jpg | |
fi | |
DISPLAY=:0.0 feh --bg-scale /tmp/wallpaper-$MD5-1.jpg & | |
DISPLAY=:0.1 feh --bg-scale /tmp/wallpaper-$MD5-3.jpg & | |
DISPLAY=:0.2 feh --bg-scale /tmp/wallpaper-$MD5-2.jpg & | |
DISPLAY=:0.3 feh --bg-scale /tmp/wallpaper-$MD5-0.jpg | |
# Nope, cannot use cached copies, do it all from scratch | |
else | |
nice -n 19 convert -crop 50%x50% +repage "$INPUT" /tmp/wallpaper.jpg | |
DISPLAY=:0.0 feh --bg-scale /tmp/wallpaper-1.jpg & | |
DISPLAY=:0.1 feh --bg-scale /tmp/wallpaper-3.jpg & | |
DISPLAY=:0.2 feh --bg-scale /tmp/wallpaper-2.jpg & | |
DISPLAY=:0.3 feh --bg-scale /tmp/wallpaper-0.jpg | |
fi |
Now with "caching"! No longer re-converts an image every single time. Instead, it checks for a cached set in /tmp/.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just a quick note:
I wrote this to split a 3840x2160 image into 4 pieces, one for each 1920x1080 display (2x2 configuration), and apply them (using "feh")