Created
February 21, 2018 16:55
-
-
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
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 | |
#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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.