commit 2836d2f4452b538e24ca6b85ee27df7bce0b69b2
parent 0bcca7b6808a02af3c4758c30eec9984d44dfac7
Author: Sebastiano Tronto <sebastiano.tronto@gmail.com>
Date: Wed, 9 Feb 2022 19:23:08 +0100
Simplified scripts build process (removed SDEPDATA).
Diffstat:
8 files changed, 33 insertions(+), 38 deletions(-)
diff --git a/Makefile b/Makefile
@@ -4,8 +4,7 @@ VERSION = 0.1
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man
-SDEPDATA = ${HOME}/.local/share/sdep
-SCRIPTS = sdep-add sdep-checknow sdep-clear sdep-edit sdep-list sdep-checkpast
+SCRIPTS = sdep-add sdep-checknow sdep-checkpast sdep-clear sdep-edit sdep-list
CPPFLAGS = -D_XOPEN_SOURCE=700 -DVERSION=\"${VERSION}\"
CFLAGS = -pedantic -Wall -Os ${CPPFLAGS}
@@ -21,10 +20,10 @@ options:
@echo "CC = ${CC}"
sdep:
- ${CC} ${CFLAGS} -o sdep.o sdep.c
+ ${CC} ${CFLAGS} -o sdep sdep.c
clean:
- rm -rf sdep.o sdep-${VERSION}.tar.gz scripts-build
+ rm -rf sdep sdep-${VERSION}.tar.gz
dist: clean
mkdir -p sdep-${VERSION}
@@ -35,24 +34,16 @@ dist: clean
install: all
mkdir -p ${DESTDIR}${PREFIX}/bin
- cp -f sdep.o ${DESTDIR}${PREFIX}/bin/sdep
+ cp -f sdep ${DESTDIR}${PREFIX}/bin/sdep
chmod 755 ${DESTDIR}${PREFIX}/bin/sdep
mkdir -p ${DESTDIR}${MANPREFIX}/man1
sed "s/VERSION/${VERSION}/g" < sdep.1 \
> ${DESTDIR}${MANPREFIX}/man1/sdep.1
chmod 644 ${DESTDIR}${MANPREFIX}/man1/sdep.1
-scripts:
- mkdir -p scripts-build
- mkdir -p ${SDEPDATA}
+scriptsinstall:
for s in ${SCRIPTS}; do\
- sed "s|SDEPDATA|${SDEPDATA}|g" < scripts/$$s \
- > scripts-build/$$s ;\
- done
-
-scriptsinstall: scripts
- for s in ${SCRIPTS}; do\
- cp -f scripts-build/$$s ${DESTDIR}${PREFIX}/bin ; \
+ cp -f scripts/$$s ${DESTDIR}${PREFIX}/bin ; \
chmod 755 ${DESTDIR}${PREFIX}/bin/$$s ;\
done
@@ -60,5 +51,5 @@ uninstall:
rm -rf ${DESTDIR}${PREFIX}/bin/sdep ${DESTDIR}${MANPREFIX}/man1/sdep.1
for s in ${SCRIPTS}; do rm -rf ${DESTDIR}${PREFIX}/bin/$$s; done
-.PHONY: all options clean dist install scripts uninstall
+.PHONY: all options clean dist install uninstall
diff --git a/scripts/sdep-add b/scripts/sdep-add
@@ -1,6 +1,6 @@
#!/bin/sh
-# Adds a line to SDEPDATA/once. It is possible to specify a date, which will be
+# Adds a line to $sdepdata/once. It is possible to specify a date, which will be
# read by date -d and prepended to the input text.
# -d is a non-portable option of GNU date. On some other systems one can
# accomplish the same with the -j option.
@@ -8,7 +8,9 @@
# Usage: sdep-add [date]
# Example: sdep-add "next monday"
-file="SDEPDATA/once"
+sdepdata="${XDG_DATA_HOME:-$HOME/.local}/sdep"
+
+file="$sdepdata/once"
date=""
[ -n "$1" ] && date=$(date -d "$1" +%Y-%m-%d)
diff --git a/scripts/sdep-checknow b/scripts/sdep-checknow
@@ -3,7 +3,7 @@
# Run this every minute (for example using cron) to receive a notification
# when an event happens.
#
-# The events are read from the following files in SDEPDATA folder:
+# The events are read from the following files in $sdepdata folder:
# once: events that only happen once; full date needs to be specified
# daily: events that happen every day; only specify the time in HH:MM format
# weekly: only specify Weekday + time
@@ -14,6 +14,8 @@
# might have to change if you are not on Linux (on some systems you can
# accomplish the same with -j).
+sdepdata="${XDG_DATA_HOME:-$HOME/.local}/sdep"
+
#notify="notify-send -t 3600000"
notify=herbe
title="$(date +%H:%M)"
@@ -23,17 +25,17 @@ sdepnotify() {
}
# One-off events
-sdepnotify <"SDEPDATA/once"
+sdepnotify <"$sdepdata/once"
# Daily events
-sed "s/^/$(date +%Y-%m-%d) /" <"SDEPDATA/daily" | sdepnotify
+sed "s/^/$(date +%Y-%m-%d) /" <"$sdepdata/daily" | sdepnotify
# Weekly events - needs GNU date (try -j intead of -d on BSD)
while read line; do
weekday=$(echo "$line" | sed "s/ .*$//")
echo "$line" | sed "s/^[ ]*[^ ]* /$(date -d $weekday +%Y-%m-%d) /"
-done <"SDEPDATA/weekly" | \
+done <"$sdepdata/weekly" | \
sdepnotify
# Monthly events
-sed "s/^[ ]*/$(date +%Y-%m-)/" <"SDEPDATA/daily" | sdepnotify
+sed "s/^[ ]*/$(date +%Y-%m-)/" <"$sdepdata/daily" | sdepnotify
diff --git a/scripts/sdep-checkpast b/scripts/sdep-checkpast
@@ -1,13 +1,7 @@
#!/bin/sh
# Run this at boot to receive a notification about past events that you might
-# have missed
-#
-# The events are read from the following files in SDEPDATA folder:
-# once: events that only happen once; full date needs to be specified
-# daily: events that happen every day; only specify the time in HH:MM format
-# weekly: only specify Weekday + time
-# monthly: only specify day of the month + time
+# have missed (based on sdep-list).
# Requires: a command to send notifications such as herbe or notify-send.
diff --git a/scripts/sdep-clear b/scripts/sdep-clear
@@ -1,10 +1,12 @@
#!/bin/sh
-# Removes old events from specified file (default: SDEPDATA/once).
+# Removes old events from specified file (default: $sdepdata/once).
# Usage: sdep-clear [file]
-file="SDEPDATA/${1:-once}"
+sdepdata="${XDG_DATA_HOME:-$HOME/.local}/sdep"
+
+file="$sdepdata/${1:-once}"
temp=$(mktemp)
sdep -t <"$file" >"$temp"
diff --git a/scripts/sdep-edit b/scripts/sdep-edit
@@ -5,7 +5,9 @@
# Usage: sdep-edit [file]
# No options = once
-file="SDEPDATA/${1:-once}"
+sdepdata="${XDG_DATA_HOME:-$HOME/.local}/sdep"
+
+file="$sdepdata/${1:-once}"
editor=${VISUAL:-vi}
$editor "$file"
diff --git a/scripts/sdep-list b/scripts/sdep-list
@@ -4,7 +4,7 @@
# Recurring events are listed at most once, and only if their first occurrence
# is in the range.
#
-# The events are read from the following files in the SDEPDATA folder:
+# The events are read from the following files in the $sdepdata folder:
# once: events that only happen once; full date needs to be specified
# daily: events that happen every day; only specify the time in HH:MM format
# weekly: only specify Weekday + time
@@ -15,6 +15,8 @@
# Usage: sdep-list [today|tomorrow|week|nextweek|past|future]
# No options = all
+sdepdata="${XDG_DATA_HOME:-$HOME/.local}/sdep"
+
from=""
to=""
w="%d %b %H:%M"
@@ -52,13 +54,13 @@ esac
tempfile=$(mktemp)
-cat "SDEPDATA/once" > "$tempfile"
-sed "s/^/$(date +%Y-%m-%d) /" <"SDEPDATA/daily" | >> "$tempfile"
+cat "$sdepdata/once" > "$tempfile"
+sed "s/^/$(date +%Y-%m-%d) /" <"$sdepdata/daily" | >> "$tempfile"
while read line; do
weekday=$(echo "$line" | sed "s/ .*$//")
echo "$line" | sed "s/^[ ]*[^ ]* /$(date -d $weekday +%Y-%m-%d) /"
-done <"SDEPDATA/weekly" >> "$tempfile"
-sed "s/^[ ]*/$(date +%Y-%m-)/" <"SDEPDATA/daily" >> "$tempfile"
+done <"$sdepdata/weekly" >> "$tempfile"
+sed "s/^[ ]*/$(date +%Y-%m-)/" <"$sdepdata/daily" >> "$tempfile"
sdep -w "$w" -f "$from" -t "$to" <"$tempfile"
diff --git a/sdep b/sdep
Binary files differ.