about summary refs log tree commit diff stats
path: root/bin/mbsync-cron
diff options
context:
space:
mode:
authorEnsa <@>2020-05-01 17:39:45 -0700
committerEnsa <@>2020-05-01 17:39:45 -0700
commit2b52ba86897ed947976d560fc1a1eb1a8499c451 (patch)
treed1a0d2d82a7907d308b99bbd3fc827cfad20f981 /bin/mbsync-cron
parentc4632455cff4a5097a3a35ad9d0531388776d028 (diff)
downloadcfg-2b52ba86897ed947976d560fc1a1eb1a8499c451.tar.gz
cwm added, general updates, etc
bother
	made the WM detection and X startup file detection more robust
comm-sel
	replaced 6cord with cordless
	made the default case do nothing so it's less annoying
lh
	removed ipc-server garbage
	changed the audio group to allow for streaming audio to mpv
		(this works with livestream audio files)
mbsync-cron
	moved config file to $XDG_CONFIG_HOME/mbsync/mbsyncrc
	made error exits actually error (helps with crontab -n)
	renamed old popmail touch file to something more nominally
	appropriate
		same with notify-send --app-name
cwmrc
	reading it, DEPENDENCIES.md, and `man cwmrc` will more than
	explain everything in here.
	except the commented binds, these are behaviours cwm does not
	have.
completions.ksh
	self-explanatory. read it.
diraliases
	added ~bin for user binaries dir
	added ~ksh for ksh config dir
	added ~pass for password database
kshrc
	added safeguards for ensuring used directories exist
	switched lfcd source to a test and source
prompt.ksh
	better sep symbols
	git branch occupies less space
lfrc
	added auto-upload to ttm.sh, bound to t
init.vim
	switched colourscheme to zellner
	removed syntastic checker specifiers,
		now uses aggregate checks.
	syntastic_c_compiler set to cc, symlink your preferred compiler
	to ~bin/cc
	switched ectags to ctags
	enabled folds
shrc
	ALTSCR: terminal you want to use for programs that already have
	scrollback. set to "$TERMINAL" if you don't have one.
	fiddled with LESS, hopefully better now
	$TODO is the file todo(1) uses.
	ENV: file ksh sources on startup.
6cord.toml
	removed because it's abandoned now.
colors-wal-dwm.h
	removed because i don't use dwm anymore.
dunstrc, zathurarc
	now uses cozette font
Diffstat (limited to 'bin/mbsync-cron')
-rwxr-xr-xbin/mbsync-cron23
1 files changed, 12 insertions, 11 deletions
diff --git a/bin/mbsync-cron b/bin/mbsync-cron
index dd69c01..fc611c2 100755
--- a/bin/mbsync-cron
+++ b/bin/mbsync-cron
@@ -6,12 +6,13 @@
 #	there is an internet connection.
 if ! pgrep -u "${USER:=$LOGNAME}" >/dev/null; then
 	printf '%s not logged in. quitting...\n' "$USER" >/dev/stderr
-	exit
+	exit 1;
 elif pgrep -x mbsync >/dev/null; then
 	printf 'mbsync is already running. quitting...\n' >/dev/stderr
-	exit
+	exit 1;
 elif ! ping -q -c 1 1.1.1.1 >/dev/null; then
 	printf 'no internet connection, quitting...\n' >/dev/stderr
+	exit 1;
 fi
 
 export DISPLAY=:0
@@ -21,9 +22,9 @@ if ! [ -d "$XDG_DATA_HOME/neomutt" ]; then
 fi
 # check account for new mail, notify for new content
 syncandnotify() {
-    mbsync "$account">/dev/null 2>&1
-    # $new holds an index of all mail since the last time popmail ran
-    new=$(find "$XDG_DATA_HOME/mail/$account/inbox/new/" -type f -newer "$XDG_DATA_HOME/neomutt/.popmail-last" 2> /dev/null)
+    mbsync -c "$XDG_CONFIG_HOME/mbsync/mbsyncrc" "$account">/dev/null 2>&1
+    # $new holds an index of all mail since the last time mbsync-cron ran
+    new=$(find "$XDG_DATA_HOME/mail/$account/inbox/new/" -type f -newer "$XDG_DATA_HOME/neomutt/.mbsc-last" 2> /dev/null)
     # $newcount is the number of new mails
     newcount=$(printf '%s\n' "$new" | sed '/^\s*$/d' | wc -l | tr -d " ")
     # send $newcount to a file specific to $account
@@ -31,7 +32,7 @@ syncandnotify() {
     printf ' %s' "$newcount" > "$XDG_DATA_HOME/mail/$account/note"
     # don't notify if there isn't new mail
     if [ "$newcount" -gt "0" ]; then
-        notify-send --app-name="popmail" "mail fetcher" "new mail for profile $account! [$newcount]" &
+        notify-send --app-name="mbsync-cron" "mail fetcher" "new mail for profile $account! [$newcount]" &
 	# reduce output if you have a lot of new mail
 	if [ "$newcount" -lt "16" ]; then
         for file in $new; do
@@ -40,7 +41,7 @@ syncandnotify() {
 	    from=$(awk '/^From: / && ++n ==1,/^\<.*\>:/' "$file" | awk '{ $1=""; if (NF>=3)$NF=""; print $0 }' | sed '1!d'| sed '1,/From/s/From: //')
 	    # modified version of broken $subject variable, only prints the first subject line (so forwards are slightly unclear)
             subject=$(awk '/^Subject: / && ++n == 1,/^\<.*\>: / && ++i == 2' "$file" | sed '$D' | grep -m 1 '^Subject: ' | sed 's/Subject: //')
-            notify-send --app-name="popmail" "$from:" "$subject" &
+            notify-send --app-name="mbsync-cron" "$from:" "$subject" &
 	    # sleep for half a second to avoid notification clog
 	    sleep .5
         done
@@ -48,10 +49,10 @@ syncandnotify() {
     fi
 }
 
-# if popmail is given arguments, treat them as accounts to get mail from.
+# if mbsync-cron is given arguments, treat them as accounts to get mail from.
 # otherwise, scan the mbsync config to get account names
 if [ "$#" -eq "0" ]; then
-    accounts="$(awk '/^Group/ {print $2}' "$HOME/.mbsyncrc")"
+    accounts="$(awk '/^Group/ {print $2}' "$XDG_CONFIG_HOME/mbsync/mbsyncrc")"
 else
     accounts=$*
 fi
@@ -71,5 +72,5 @@ if cat "$XDG_DATA_HOME"/mail/*/note|grep -q '[1-9]'; then
 else
 	printf '\n'>"$XDG_DATA_HOME/mail/note"
 fi
-#create/update modification time on an empty file that indicates the time of the last run of popmail
-touch "$XDG_DATA_HOME/neomutt/.popmail-last"
+#create/update modification time on an empty file that indicates the time of the last run of mbsync-cron
+touch "$XDG_DATA_HOME/neomutt/.mbsc-last"