Skip to content

Instantly share code, notes, and snippets.

@X4
Forked from tomoe-mami/imgtoedj.sh
Last active December 15, 2015 13:38
Show Gist options
  • Save X4/5268367 to your computer and use it in GitHub Desktop.
Save X4/5268367 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e
# Set the path to your own wallpaper directory
WALLPAPER_PATH="$HOME/Bilder/Sample Pictures"
NEXT_WALLPAPER="$HOME/Bilder/Sample Pictures/006.jpg"
FILENAME="006.jpg"
OUTPUT_DIR="$HOME/.e/e/backgrounds"
TEMPLATE='
images { image: "@IMAGE@" USER; }
collections {
group {
name: "e/desktop/background";
data { item: "style" "4"; item: "noanimation" "1"; }
max: @WIDTH@ @HEIGHT@;
parts {
part {
name: "bg";
mouse_events: 0;
description {
state: "default" 0.0;
aspect: @ASPECT@ @ASPECT@;
aspect_preference: NONE;
image { normal: "@IMAGE@"; scale_hint: STATIC; }
}
}
}
}
}
'
DIMENSION="$(identify -format "%w/%h" "$NEXT_WALLPAPER")"
if [ -z "$DIMENSION" ]; then
continue
fi
WIDTH=$(echo $DIMENSION | cut -d/ -f1)
HEIGHT=$(echo $DIMENSION | cut -d/ -f2)
IMAGE="$(echo "NEXT_WALLPAPER" | sed 's/[^[:alnum:]_-]/\\&/g')"
if [ -z "$HEIGHT" -o "$HEIGHT" = "0" ]; then
ASPECT="0.0"
else
ASPECT=$(echo "scale=9; $DIMENSION" | bc)
fi
echo "$TEMPLATE" | \
sed "s/@ASPECT@/$ASPECT/g; s/@WIDTH@/$WIDTH/g; s/@HEIGHT@/$HEIGHT/g; s|@IMAGE@|$IMAGE|g" > tmp.edc
edje_cc tmp.edc -o "$OUTPUT_DIR/${FILENAME%.*}.edj"
rm tmp.edc
echo "$OUTPUT_DIR/${FILENAME%.*}.edj"
# Output is: /home/user/.e/backgrounds/006.edj
enlightenment_remote -desktop-bg-add 0 0 0 0 "$OUTPUT_DIR/${FILENAME%.*}.edj"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment