Skip to content

Instantly share code, notes, and snippets.

@kbauer
Last active June 29, 2018 08:42
Show Gist options
  • Save kbauer/ee6860d55db1b06bc6a2443284c2ed1e to your computer and use it in GitHub Desktop.
Save kbauer/ee6860d55db1b06bc6a2443284c2ed1e to your computer and use it in GitHub Desktop.
A bash script for extracting the full-resolution lock-screen spotlight images on Windows 10. Skips images whose size and layout indicate that they are thumbnails or cropped. Invokes itself recursively in parallel, in order to achieve reasonable performance. Intended for execution with Cygwin's bash shell; Requires ImageMagick.
#!/usr/bin/env bash
# -*- coding: iso-safe-unix -*-
set -e -E -u
#### SETTINGS
SPOTLIGHT_PATH="$(cygpath $LOCALAPPDATA)/Packages/Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy/LocalState/Assets"
OUTPUT_PATH='/tmp/SPOTLIGHT_DISPLAY'
#### CODE
if [[ $# = 1 ]]; then
OLDNAME="$1"
NEWNAME="$OLDNAME.jpg"
OLDPATH="$SPOTLIGHT_PATH/$OLDNAME"
NEWPATH="$OUTPUT_PATH/$NEWNAME"
NEWPATHALT="$OUTPUT_PATH/other/$NEWNAME"
SIZE=($(convert "$OLDPATH" -format '%[fx:w] %[fx:h]' info:))
if [[ -e $NEWPATH ]]; then
echo "(E) $(printf %10s '???x???') $OLDNAME"
elif [[ -e $NEWPATHALT ]]; then
echo "(O) $(printf %10s '???x???') $OLDNAME"
else
SIZEX="${SIZE[0]}"
SIZEY="${SIZE[1]}"
SIZEF="$(printf '%10s' "${SIZEX}x${SIZEY}")"
ISLANDSCAPE=$([[ $SIZEX -gt $SIZEY ]] && echo true || echo false)
if [[ $SIZEX -le $SIZEY ]]; then
echo "(S) $SIZEF $OLDNAME (not landscape)"
cp "$OLDPATH" "$NEWPATHALT"
elif [[ $SIZEX -lt 800 ]]; then
echo "(S) $SIZEF $OLDNAME (too small)"
cp "$OLDPATH" "$NEWPATHALT"
else
echo "(N) $SIZEF $OLDNAME"
cp "$OLDPATH" "$NEWPATH"
fi
fi
else
mkdir -p "$OUTPUT_PATH"
mkdir -p "$OUTPUT_PATH/other"
(cd "$SPOTLIGHT_PATH" && ls -1 --sort=time --reverse) |\
xargs -P 4 -n 1 -d $'\n' "$0"
( cd "$OUTPUT_PATH/" && explorer . )
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment