Skip to content

Instantly share code, notes, and snippets.

@ideaflare
Last active November 23, 2024 22:39
Show Gist options
  • Select an option

  • Save ideaflare/73e2bb2af7565863fa1bbf237e39205e to your computer and use it in GitHub Desktop.

Select an option

Save ideaflare/73e2bb2af7565863fa1bbf237e39205e to your computer and use it in GitHub Desktop.
Update background to random unsplash image (Ubuntu /w Gnome Desktop)
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
@ideaflare
Copy link
Author

chmod +x
set shortcut to:
./Documents/unsplash-background.sh

@ideaflare
Copy link
Author

ideaflare commented May 25, 2018

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