From 34dcc5b8134dd635a133edeb78bdc42428e68a38 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Tue, 21 Jan 2020 15:50:06 -0500 Subject: [PATCH] Cleaning up systemd config files --- systemd/.config/systemd/user/astronomypotd.sh | 28 -------- .../.config/systemd/user/changepaper.service | 8 --- systemd/.config/systemd/user/changepaper.sh | 66 ------------------- .../.config/systemd/user/changepaper.timer | 13 ---- .../.config/systemd/user/checkmail.service | 8 --- systemd/.config/systemd/user/checkmail.sh | 14 ---- systemd/.config/systemd/user/checkmail.timer | 13 ---- .../user/default.target.wants/emacs.service | 1 + .../default.target.wants/syncthing.service | 1 + .../.config/systemd/user/get_astrobin_potd.py | 27 -------- systemd/.config/systemd/user/syncmail.service | 8 --- systemd/.config/systemd/user/syncmail.sh | 13 ---- systemd/.config/systemd/user/syncmail.timer | 13 ---- 13 files changed, 2 insertions(+), 211 deletions(-) delete mode 100755 systemd/.config/systemd/user/astronomypotd.sh delete mode 100644 systemd/.config/systemd/user/changepaper.service delete mode 100755 systemd/.config/systemd/user/changepaper.sh delete mode 100644 systemd/.config/systemd/user/changepaper.timer delete mode 100644 systemd/.config/systemd/user/checkmail.service delete mode 100755 systemd/.config/systemd/user/checkmail.sh delete mode 100644 systemd/.config/systemd/user/checkmail.timer create mode 120000 systemd/.config/systemd/user/default.target.wants/emacs.service create mode 120000 systemd/.config/systemd/user/default.target.wants/syncthing.service delete mode 100755 systemd/.config/systemd/user/get_astrobin_potd.py delete mode 100644 systemd/.config/systemd/user/syncmail.service delete mode 100755 systemd/.config/systemd/user/syncmail.sh delete mode 100644 systemd/.config/systemd/user/syncmail.timer diff --git a/systemd/.config/systemd/user/astronomypotd.sh b/systemd/.config/systemd/user/astronomypotd.sh deleted file mode 100755 index 06e3243..0000000 --- a/systemd/.config/systemd/user/astronomypotd.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -# 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 -####################### - -#Change directory to where the script resides. -BASEDIR="$HOME/var/inbox/apod_photos" -cd $BASEDIR -####################### - -#getting the image URL -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 - #feh --bg-scale $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/changepaper.service b/systemd/.config/systemd/user/changepaper.service deleted file mode 100644 index 90fae32..0000000 --- a/systemd/.config/systemd/user/changepaper.service +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -Description=Check for new wallpaper on NG -RefuseManualStart=no -RefuseManualStop=yes - -[Service] -Type=oneshot -ExecStart=/home/powellc/.config/systemd/user/changepaper.sh diff --git a/systemd/.config/systemd/user/changepaper.sh b/systemd/.config/systemd/user/changepaper.sh deleted file mode 100755 index eae3114..0000000 --- a/systemd/.config/systemd/user/changepaper.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -# 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 -####################### - -#Change directory to where the script resides. -BASEDIR="$HOME/var/inbox/ng_photos" -cd $BASEDIR -####################### - -#getting the image URL -img="$(curl https://www.nationalgeographic.com/photography/photo-of-the-day/ -s | grep -oP '(?<="twitter:image:src" content=")\K[^"]*')" - -#check to see if there is any wallpaper to download -if [ -n "$img" ] -then - img_base=`echo $img | cut -d/ -f 5` - img_md5=`echo -n $img_base | md5sum | cut -f1 -d" "` - img_file="$img_md5.jpg" - - curl "$img" > $img_file - #set the current image as wallpaper -# feh --bg-scale $BASEDIR/$img_md5.jpg -# #link slim background to new image -# rm /usr/share/slim/themes/default/background.jpg -# ln -s $BASEDIR/$img_md5.jpg /usr/share/slim/themes/default/background.jpg -else - echo "No Wallpaper today" -fi - -# 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 -####################### - -#getting the image URL -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 - #feh --bg-scale $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 - -BASEDIR="$HOME/var/inbox/astrobin/" -# use python script to get astrobin iotd -python ~/.config/systemd/user/get_astrobin_potd.py - -date=$(date '+%Y-%m-%d') - - #set the current image as wallpaper -feh --bg-scale $BASEDIR/$date.jpg -#link slim background to new image -rm /usr/share/slim/themes/default/background.jpg -ln -s $BASEDIR/$date.jpg /usr/share/slim/themes/default/background.jpg diff --git a/systemd/.config/systemd/user/changepaper.timer b/systemd/.config/systemd/user/changepaper.timer deleted file mode 100644 index 1534d2e..0000000 --- a/systemd/.config/systemd/user/changepaper.timer +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Change background every day -RefuseManualStart=no -RefuseManualStop=no - -[Timer] -Persistent=false -OnBootSec=5min -OnUnitActiveSec=12h -Unit=changepaper.service - -[Install] -WantedBy=default.target diff --git a/systemd/.config/systemd/user/checkmail.service b/systemd/.config/systemd/user/checkmail.service deleted file mode 100644 index 20f5d94..0000000 --- a/systemd/.config/systemd/user/checkmail.service +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -Description=Check for new mail -RefuseManualStart=no -RefuseManualStop=yes - -[Service] -Type=oneshot -ExecStart=/home/powellc/.config/systemd/user/checkmail.sh diff --git a/systemd/.config/systemd/user/checkmail.sh b/systemd/.config/systemd/user/checkmail.sh deleted file mode 100755 index 8c13415..0000000 --- a/systemd/.config/systemd/user/checkmail.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -STATE=`nmcli networking connectivity` - -if [ $STATE = 'full' ] -then - afew --m --new - mbsync -a - notmuch new - afew --tag --new - exit 0 -fi -echo "No internet connection" -exit 0 diff --git a/systemd/.config/systemd/user/checkmail.timer b/systemd/.config/systemd/user/checkmail.timer deleted file mode 100644 index e83b0e3..0000000 --- a/systemd/.config/systemd/user/checkmail.timer +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Check mail every five minutes -RefuseManualStart=no -RefuseManualStop=no - -[Timer] -Persistent=false -OnBootSec=3min -OnUnitActiveSec=3min -Unit=checkmail.service - -[Install] -WantedBy=default.target diff --git a/systemd/.config/systemd/user/default.target.wants/emacs.service b/systemd/.config/systemd/user/default.target.wants/emacs.service new file mode 120000 index 0000000..bebf0b3 --- /dev/null +++ b/systemd/.config/systemd/user/default.target.wants/emacs.service @@ -0,0 +1 @@ +/home/powellc/.config/systemd/user/emacs.service \ No newline at end of file diff --git a/systemd/.config/systemd/user/default.target.wants/syncthing.service b/systemd/.config/systemd/user/default.target.wants/syncthing.service new file mode 120000 index 0000000..b64433a --- /dev/null +++ b/systemd/.config/systemd/user/default.target.wants/syncthing.service @@ -0,0 +1 @@ +/home/powellc/.config/systemd/user/syncthing.service \ No newline at end of file diff --git a/systemd/.config/systemd/user/get_astrobin_potd.py b/systemd/.config/systemd/user/get_astrobin_potd.py deleted file mode 100755 index a935ad2..0000000 --- a/systemd/.config/systemd/user/get_astrobin_potd.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python3 -from datetime import datetime -import requests -import subprocess - -root = "https://www.astrobin.com" -api_key = "3f542cbb23407bde6f20490f377366582dd1a54c" -api_secret = subprocess.check_output( - "pass personal/apikey/astrobin", shell=True -).decode("utf-8").strip() -fmt = "json" -iotd_uri = f"{root}/api/v1/imageoftheday/?limit=1&api_key={api_key}&api_secret={api_secret}&format={fmt}" -r = requests.get(iotd_uri) -image_info_uri = r.json()["objects"][0]["image"] -r = requests.get( - f"{root}{image_info_uri}?api_key={api_key}&api_secret={api_secret}&format={fmt}" -) -image_uri = r.json()["url_real"] -img = requests.get(image_uri, stream=True) - -today = datetime.today().strftime("%Y-%m-%d") -target_path = f"/home/powellc/var/inbox/astrobin/{today}.jpg" - -handle = open(target_path, "wb") -for chunk in img.iter_content(chunk_size=512): - if chunk: # filter out keep-alive new chunks - handle.write(chunk) diff --git a/systemd/.config/systemd/user/syncmail.service b/systemd/.config/systemd/user/syncmail.service deleted file mode 100644 index 0f1835a..0000000 --- a/systemd/.config/systemd/user/syncmail.service +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -Description=Sync mail with Rhea -RefuseManualStart=no -RefuseManualStop=yes - -[Service] -Type=oneshot -ExecStart=/home/powellc/.config/systemd/user/syncmail.sh diff --git a/systemd/.config/systemd/user/syncmail.sh b/systemd/.config/systemd/user/syncmail.sh deleted file mode 100755 index 1f93fd9..0000000 --- a/systemd/.config/systemd/user/syncmail.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -STATE=`nmcli networking connectivity` - -if [ $STATE = 'full' ] -then - notmuch search --output=files tag:deleted | xargs -l rm - notmuch new - muchsync rhea.unbl.ink - exit 0 -fi -echo "No internet connection" -exit 0 diff --git a/systemd/.config/systemd/user/syncmail.timer b/systemd/.config/systemd/user/syncmail.timer deleted file mode 100644 index ea35d59..0000000 --- a/systemd/.config/systemd/user/syncmail.timer +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Sync mail with rhea every 3 minutes -RefuseManualStart=no -RefuseManualStop=no - -[Timer] -Persistent=false -OnBootSec=3min -OnUnitActiveSec=3min -Unit=syncmail.service - -[Install] -WantedBy=default.target