Created
April 25, 2021 02:50
-
-
Save dhbradshaw/335332d4cbc473e0c0b3c6750a07f947 to your computer and use it in GitHub Desktop.
Command to rotate to the next image on gnome desktop (if I save images I want to rotate through to Pictures/rotate_background)
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 | |
DIR="/home/doug/Pictures/rotate_background" | |
# Get full path | |
FULL_PATH=$(gsettings get org.gnome.desktop.background picture-uri) | |
# Clean off quotes. | |
FULL_PATH=$(echo $FULL_PATH | sed 's/.$//' | sed 's/^.//') | |
# Get base filename for comparison with ls output. | |
FILE_NAME=$(basename $FULL_PATH) | |
# Find the next file after this using grep. | |
NEXT_LINE=$(ls $DIR/* | grep $FILE_NAME -A1 | tail -n 1) | |
NEW_FULL_PATH="file://$NEXT_LINE" | |
# If we were already on the last line, we're stuck. So loop to the beginning. | |
if [ $NEW_FULL_PATH = $FULL_PATH ] | |
then | |
NEXT_LINE=$(ls $DIR/* | head -n 1) | |
fi | |
# Now set that image! | |
gsettings set org.gnome.desktop.background picture-uri "file://$NEXT_LINE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For some reason I like curating and then rotating through desktop backgrounds manually. I have this command connected to CTR-SHIFT-ALT-n, where n stands for
next
.