Last active
July 14, 2023 10:12
-
-
Save andykais/919d249b90e4e30779ad to your computer and use it in GitHub Desktop.
use feh to create a slideshow, meant for i3-wm, to be launched at startup
This file contains hidden or 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 | |
#wait (in seconds) for background to change | |
wait=$((60 * 60)) | |
#in the future, could load files from a general bin/config file | |
#sed -c -i "s/\($TARGET_KEY *= *\).*/\1$REPLACEMENT_VALUE/" $CONFIG_FILE | |
dir="$(cat /home/andrew/bin/data/slideshow_all.txt)" | |
#finds the image files in $dir, optionally can add --max-depth 1 to keep from searching subdirs | |
files=$(find "$dir" -regex ".*\.\(jpg\|gif\|png\|jpeg\)" | sort -n) | |
#used to find place of last used background image | |
latest="$(cat /home/andrew/bin/data/slideshow_latest.txt)" | |
past_latest=false | |
tmp= | |
nl=$'\n' | |
for line in $files | |
do | |
if $past_latest || [[ $line == $latest ]] || [ -z "$latest" ] | |
then | |
tmp+="$line${nl}" | |
past_latest=true | |
fi | |
done | |
tmp=${tmp/%${nl}/} | |
if [ ! -z "$tmp" ] | |
then | |
files=$tmp | |
fi | |
while true | |
do | |
echo "$files" | while read -r line | |
do | |
#feh --bg-fill "$line" | |
feh --bg-max "$line" | |
echo $line > /home/andrew/bin/data/slideshow_latest.txt | |
sleep $wait | |
done | |
files=$(find "$dir" -regex ".*\.\(jpg\|gif\|png\|jpeg\)") | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment