From b3b25f1b6a7a9abfc139b3aadee4bcc0a12ab389 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Wed, 13 Sep 2023 12:37:16 -0400 Subject: [PATCH] [systemd] Add gnome wallpaper infra --- bin/.bin/gnome-changepaper | 66 +++++++++++++++++++ .../systemd/user/gnome-changepaper.service | 8 +++ .../systemd/user/gnome-changepaper.timer | 9 +++ 3 files changed, 83 insertions(+) create mode 100755 bin/.bin/gnome-changepaper create mode 100644 systemd/.config/systemd/user/gnome-changepaper.service create mode 100644 systemd/.config/systemd/user/gnome-changepaper.timer diff --git a/bin/.bin/gnome-changepaper b/bin/.bin/gnome-changepaper new file mode 100755 index 0000000..48ab200 --- /dev/null +++ b/bin/.bin/gnome-changepaper @@ -0,0 +1,66 @@ +#!/bin/sh +# This Script downloads National Geographic Photo of the day, and sets it as desktop background (gnome, unity) +# Copyright (C) 2012 Saman Barghi - All Rights Reserved +# Permission to copy, modify, and distribute is granted under GPLv3 +# Last Revised 22 May 2019 +####################### + +# For feh, we need display set properly +export DISPLAY=:0.0 +export XAUTHORITY=/home/powellc/.Xauthority + +if [ -n "$1" ]; then + SOURCE=$1 +else + SOURCE='bing' +fi + +# Choices: astrobin,natgeo,nasa,unsplash,bing +BASEDIR="$HOME/var/media/backgrounds/$SOURCE" +SEARX_BASEDIR="$HOME/var/media/backgrounds/bing" + +# Get daily NatGeo POTD +#python3 ~/.bin/get_natgeo_potd.py +#python3 ~/.bin/get_astrobin_potd.py +#python3 ~/.bin/get_unsplash_potd.py +~/.asdf/installs/python/3.11.4/bin/python ~/.bin/get_bing_potd.py + +date=$(date '+%Y-%m-%d') + +#set the current image as wallpaper +echo "Setting desktop background" +gsettings set org.gnome.desktop.background picture-uri $BASEDIR/$date.jpg +gsettings set org.gnome.desktop.background picture-uri-dark $BASEDIR/$date.jpg + +#link slim background to new image +#SLIM_BG_FILE=/usr/share/slim/themes/default/background.jpg +#echo "Setting Slim background image" +#rm $SLIM_BG_FILE +#cp $BASEDIR/$date.jpg $SLIM_BG_FILE + +#SEARX_BG_FILE=/usr/local/src/searx/searx/static/themes/oscar/img/bg.jpg +#echo "Setting Searx background image" +#scp $BASEDIR/$date.jpg search.local:$SEARX_BG_FILE + +# Then grab our APOD image and store it for now +#Change directory to where the script resides. +#BASEDIR="$HOME/var/inbox/apod_photos" +#cd $BASEDIR +######################## +# +## Get the APoD image from NASA +#img="$(curl https://api.nasa.gov/planetary/apod\?api_key=AdfgdnmmInYgpDMEq3ShMLKjJ7DZ7jyUcgLHWdgw | jq .hdurl | tr -d \")" +# +##check to see if there is any wallpaper to download +#if [ -n "$img" ] +#then +# img_file=`echo $img | cut -d/ -f 7 | tr -d \"` +# curl $img > $img_file +# #set the current image as wallpaper +# #hsetroot -sane $BASEDIR/$img_file +# ##link slim background to new image +# #rm /usr/share/slim/themes/default/background.jpg +# #ln -s $BASEDIR/$img_file /usr/share/slim/themes/default/background.jpg +#else +# echo "No Wallpaper today" +#fi diff --git a/systemd/.config/systemd/user/gnome-changepaper.service b/systemd/.config/systemd/user/gnome-changepaper.service new file mode 100644 index 0000000..29044bc --- /dev/null +++ b/systemd/.config/systemd/user/gnome-changepaper.service @@ -0,0 +1,8 @@ +[Unit] +Description=Change wallpaper + +[Service] +ExecStart=/home/powellc/.bin/gnome-changepaper + +[Install] +WantedBy=default.target diff --git a/systemd/.config/systemd/user/gnome-changepaper.timer b/systemd/.config/systemd/user/gnome-changepaper.timer new file mode 100644 index 0000000..5b19795 --- /dev/null +++ b/systemd/.config/systemd/user/gnome-changepaper.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Change wallpaper + +[Timer] +OnCalendar=hourly +Unit=gnome-changepaper.service + +[Install] +WantedBy=default.target