Skip to content

Instantly share code, notes, and snippets.

@fxpires
Created February 21, 2018 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fxpires/00982cb4729a0f9ec089c0f9f5e5244b to your computer and use it in GitHub Desktop.
Save fxpires/00982cb4729a0f9ec089c0f9f5e5244b to your computer and use it in GitHub Desktop.
Change the lockscreen of Gnome with a random image from unsplash.com / Defne a imagem da tela de bloqueio do Gnome com uma imagem aleatória do site unsplash.com
#!/bin/bash
#IMG_DIR=${HOME}/.unsplash
IMG_DIR=/home/fabiano/.unsplash
URL="http://source.unsplash.com/random"
DATE_TIME=$(LANG=C date +%F_%T | sed 's/:/./g')
IMG=${IMG_DIR}/${DATE_TIME}.jpg
if [ ! -d ${IMG_DIR} ]; then
mkdir ${IMG_DIR}
fi
#wget -q ${URL} -O ${IMG} && gsettings set org.gnome.desktop.screensaver picture-uri file://${IMG}
wget -q ${URL} -O ${IMG}
if [ -s ${IMG} ]; then
PID=$(pgrep -o gnome-shell)
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)
gsettings set org.gnome.desktop.screensaver picture-uri file://${IMG}
fi
@fxpires
Copy link
Author

fxpires commented Feb 21, 2018

Don't forget to change the IMG_DIR var to a dir in your system to hold the images.
Use it in cron to change the image everyday.

Não se esqueça de alterar a variável IMG_DIR para um diretório em seu sistema para armazenar as imagens.
Utilize junto com o cron para trocar a imagem diariamente.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment