Last active
November 23, 2024 22:39
-
-
Save ideaflare/73e2bb2af7565863fa1bbf237e39205e to your computer and use it in GitHub Desktop.
Update background to random unsplash image (Ubuntu /w Gnome Desktop)
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
| readonly THEME='sky' | |
| readonly PIC_PATH='/home/'"$USER"'/Pictures/Unsplash/' | |
| readonly PIC_FILE=''"$PIC_PATH"'today.jpeg' | |
| setupDirectory() { | |
| mkdir -p $PIC_PATH | |
| } | |
| downloadToday() { | |
| local RES=$(xdpyinfo | awk '/dimensions/{print $2}') | |
| local URL='https://source.unsplash.com/'"$RES"'/?'"$THEME"'' | |
| # echo 'saving from ["'"$URL"'"] to ['"$PIC_FILE"'] ' | |
| wget -O ''"$PIC_FILE"'' ''"$URL"'' | |
| } | |
| updateBackground() { | |
| local PIC_URI='file://'"$PIC_FILE"'' | |
| gsettings set org.gnome.desktop.background draw-background false | |
| gsettings set org.gnome.desktop.background picture-uri "$PIC_URI" | |
| gsettings set org.gnome.desktop.background draw-background true | |
| } | |
| setupDirectory | |
| downloadToday | |
| updateBackground |
Author
Author
Improvement ideas:
- add to bash_aliases : 'paper'
- take input : 'paper cat' (to update with cat theme)
- compatibility with MacOS
- also make local variables readonly
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
chmod +x
set shortcut to:
./Documents/unsplash-background.sh