aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2022-06-21 09:07:11 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2022-06-21 09:07:11 +0200
commite76b410b860cefe5f0a3f6c744f317899186e96b (patch)
treefd310dda1cfe6bc341058cf8e03f442e661aa373
parentb68c98a74cec75946eb29ae814da9fe6ae732cf8 (diff)
downloadsdep-e76b410b860cefe5f0a3f6c744f317899186e96b.tar.gz
sdep-e76b410b860cefe5f0a3f6c744f317899186e96b.zip
Changed folder for scripts (see README.md diff)
-rw-r--r--Makefile7
-rw-r--r--README.md5
-rwxr-xr-xscripts/sdep-add6
-rwxr-xr-xscripts/sdep-checknow12
-rwxr-xr-xscripts/sdep-clear6
-rwxr-xr-xscripts/sdep-edit4
-rwxr-xr-xscripts/sdep-list12
7 files changed, 22 insertions, 30 deletions
diff --git a/Makefile b/Makefile
index d7a4660..4586beb 100644
--- a/Makefile
+++ b/Makefile
@@ -41,9 +41,10 @@ install: all
41 > ${DESTDIR}${MANPREFIX}/man1/sdep.1 41 > ${DESTDIR}${MANPREFIX}/man1/sdep.1
42 chmod 644 ${DESTDIR}${MANPREFIX}/man1/sdep.1 42 chmod 644 ${DESTDIR}${MANPREFIX}/man1/sdep.1
43 43
44scriptsinstall: 44scripts:
45 for s in ${SCRIPTS}; do\ 45 for s in ${SCRIPTS}; do\
46 cp -f scripts/$$s ${DESTDIR}${PREFIX}/bin ; \ 46 sed "s|SDEPDATA|${SD}|g" < scripts/$$s > \
47 ${DESTDIR}${PREFIX}/bin/$$s ; \
47 chmod 755 ${DESTDIR}${PREFIX}/bin/$$s ;\ 48 chmod 755 ${DESTDIR}${PREFIX}/bin/$$s ;\
48 done 49 done
49 50
@@ -51,5 +52,5 @@ uninstall:
51 rm -rf ${DESTDIR}${PREFIX}/bin/sdep ${DESTDIR}${MANPREFIX}/man1/sdep.1 52 rm -rf ${DESTDIR}${PREFIX}/bin/sdep ${DESTDIR}${MANPREFIX}/man1/sdep.1
52 for s in ${SCRIPTS}; do rm -rf ${DESTDIR}${PREFIX}/bin/$$s; done 53 for s in ${SCRIPTS}; do rm -rf ${DESTDIR}${PREFIX}/bin/$$s; done
53 54
54.PHONY: all options clean dist install uninstall 55.PHONY: all options clean dist install scripts uninstall
55 56
diff --git a/README.md b/README.md
index 1abbbde..97d2aed 100644
--- a/README.md
+++ b/README.md
@@ -88,8 +88,9 @@ between multiple devices using something like
88The `scripts` folder contains the few scripts that I use. They are 88The `scripts` folder contains the few scripts that I use. They are
89basically just a more elaborate version of the calendar system described 89basically just a more elaborate version of the calendar system described
90above, with support for recurring events (e.g. weekly, daily). You 90above, with support for recurring events (e.g. weekly, daily). You
91can install them with `make scripts` and then `make scriptsinstall`, 91can install them with `sudo SD=/path/to/scripts/folder make scripts`,
92but first make sure to adjust them to match your local configuration. 92where `SD` specifies the path where the directory where you want your sdep
93files to be saved; for example it can be `/home/username/.sdep`.
93For example check that the folder SDEPDATA in Makefile suits you. 94For example check that the folder SDEPDATA in Makefile suits you.
94 95
95Most of the scripts rely on the `-d` option of the GNU date utility, so you 96Most of the scripts rely on the `-d` option of the GNU date utility, so you
diff --git a/scripts/sdep-add b/scripts/sdep-add
index b5f1a8c..bb0b2c8 100755
--- a/scripts/sdep-add
+++ b/scripts/sdep-add
@@ -1,6 +1,6 @@
1#!/bin/sh 1#!/bin/sh
2 2
3# Adds a line to $sdepdata/once. It is possible to specify a date, which will be 3# Adds a line to SDEPDATA/once. It is possible to specify a date, which will be
4# read by date -d and prepended to the input text. 4# read by date -d and prepended to the input text.
5# -d is a non-portable option of GNU date. On some other systems one can 5# -d is a non-portable option of GNU date. On some other systems one can
6# accomplish the same with the -j option. 6# accomplish the same with the -j option.
@@ -8,9 +8,7 @@
8# Usage: sdep-add [date] 8# Usage: sdep-add [date]
9# Example: sdep-add "next monday" 9# Example: sdep-add "next monday"
10 10
11sdepdata="${XDG_DATA_HOME:-$HOME/.local/}/sdep" 11file="SDEPDATA/once"
12
13file="$sdepdata/once"
14date="" 12date=""
15 13
16[ -n "$1" ] && date=$(date -d "$1" +%Y-%m-%d) 14[ -n "$1" ] && date=$(date -d "$1" +%Y-%m-%d)
diff --git a/scripts/sdep-checknow b/scripts/sdep-checknow
index 4771957..2cb8f68 100755
--- a/scripts/sdep-checknow
+++ b/scripts/sdep-checknow
@@ -3,7 +3,7 @@
3# Run this every minute (for example using cron) to receive a notification 3# Run this every minute (for example using cron) to receive a notification
4# when an event happens. 4# when an event happens.
5# 5#
6# The events are read from the following files in $sdepdata folder: 6# The events are read from the following files in SDEPDATA folder:
7# once: events that only happen once; full date needs to be specified 7# once: events that only happen once; full date needs to be specified
8# daily: events that happen every day; only specify the time in HH:MM format 8# daily: events that happen every day; only specify the time in HH:MM format
9# weekly: only specify Weekday + time 9# weekly: only specify Weekday + time
@@ -14,8 +14,6 @@
14# might have to change if you are not on Linux (on some systems you can 14# might have to change if you are not on Linux (on some systems you can
15# accomplish the same with -j). 15# accomplish the same with -j).
16 16
17sdepdata="${XDG_DATA_HOME:-$HOME/.local/share}/sdep"
18
19#notify="notify-send -t 3600000" 17#notify="notify-send -t 3600000"
20notify=herbe 18notify=herbe
21title="$(date +%H:%M)" 19title="$(date +%H:%M)"
@@ -25,17 +23,17 @@ sdepnotify() {
25} 23}
26 24
27# One-off events 25# One-off events
28sdepnotify <"$sdepdata/once" 26sdepnotify <"SDEPDATA/once"
29 27
30# Daily events 28# Daily events
31sed "s/^/$(date +%Y-%m-%d) /" <"$sdepdata/daily" | sdepnotify 29sed "s/^/$(date +%Y-%m-%d) /" <"SDEPDATA/daily" | sdepnotify
32 30
33# Weekly events - needs GNU date (try -j intead of -d on BSD) 31# Weekly events - needs GNU date (try -j intead of -d on BSD)
34while read line; do 32while read line; do
35 weekday=$(echo "$line" | sed "s/ .*$//") 33 weekday=$(echo "$line" | sed "s/ .*$//")
36 echo "$line" | sed "s/^[ ]*[^ ]* /$(date -d $weekday +%Y-%m-%d) /" 34 echo "$line" | sed "s/^[ ]*[^ ]* /$(date -d $weekday +%Y-%m-%d) /"
37done <"$sdepdata/weekly" | \ 35done <"SDEPDATA/weekly" | \
38sdepnotify 36sdepnotify
39 37
40# Monthly events 38# Monthly events
41sed "s/^[ ]*/$(date +%Y-%m-)/" <"$sdepdata/daily" | sdepnotify 39sed "s/^[ ]*/$(date +%Y-%m-)/" <"SDEPDATA/daily" | sdepnotify
diff --git a/scripts/sdep-clear b/scripts/sdep-clear
index ffd5a69..814f853 100755
--- a/scripts/sdep-clear
+++ b/scripts/sdep-clear
@@ -1,12 +1,10 @@
1#!/bin/sh 1#!/bin/sh
2 2
3# Removes old events from specified file (default: $sdepdata/once). 3# Removes old events from specified file (default: SDEPDATA/once).
4 4
5# Usage: sdep-clear [file] 5# Usage: sdep-clear [file]
6 6
7sdepdata="${XDG_DATA_HOME:-$HOME/.local/share}/sdep" 7file="SDEPDATA/${1:-once}"
8
9file="$sdepdata/${1:-once}"
10temp=$(mktemp) 8temp=$(mktemp)
11 9
12sdep -t <"$file" >"$temp" 10sdep -t <"$file" >"$temp"
diff --git a/scripts/sdep-edit b/scripts/sdep-edit
index 650526e..d19a3f5 100755
--- a/scripts/sdep-edit
+++ b/scripts/sdep-edit
@@ -5,9 +5,7 @@
5# Usage: sdep-edit [file] 5# Usage: sdep-edit [file]
6# No options = once 6# No options = once
7 7
8sdepdata="${XDG_DATA_HOME:-$HOME/.local/share}/sdep" 8file="SDEPDATA/${1:-once}"
9
10file="$sdepdata/${1:-once}"
11editor=${VISUAL:-vi} 9editor=${VISUAL:-vi}
12 10
13$editor "$file" 11$editor "$file"
diff --git a/scripts/sdep-list b/scripts/sdep-list
index 50d3fe7..1a9a1bf 100755
--- a/scripts/sdep-list
+++ b/scripts/sdep-list
@@ -4,7 +4,7 @@
4# Recurring events are listed at most once, and only if their first occurrence 4# Recurring events are listed at most once, and only if their first occurrence
5# is in the range. 5# is in the range.
6# 6#
7# The events are read from the following files in the $sdepdata folder: 7# The events are read from the following files in the SDEPDATA folder:
8# once: events that only happen once; full date needs to be specified 8# once: events that only happen once; full date needs to be specified
9# daily: events that happen every day; only specify the time in HH:MM format 9# daily: events that happen every day; only specify the time in HH:MM format
10# weekly: only specify Weekday + time 10# weekly: only specify Weekday + time
@@ -15,8 +15,6 @@
15# Usage: sdep-list [today|tomorrow|week|nextweek|past|future] 15# Usage: sdep-list [today|tomorrow|week|nextweek|past|future]
16# No options = all 16# No options = all
17 17
18sdepdata="${XDG_DATA_HOME:-$HOME/.local/share}/sdep"
19
20from="" 18from=""
21to="" 19to=""
22w="%d %b %H:%M" 20w="%d %b %H:%M"
@@ -54,13 +52,13 @@ esac
54 52
55tempfile=$(mktemp) 53tempfile=$(mktemp)
56 54
57cat "$sdepdata/once" > "$tempfile" 55cat "SDEPDATA/once" > "$tempfile"
58sed "s/^/$(date +%Y-%m-%d) /" <"$sdepdata/daily" >> "$tempfile" 56sed "s/^/$(date +%Y-%m-%d) /" <"SDEPDATA/daily" >> "$tempfile"
59while read line; do 57while read line; do
60 weekday=$(echo "$line" | sed "s/ .*$//") 58 weekday=$(echo "$line" | sed "s/ .*$//")
61 echo "$line" | sed "s/^[ ]*[^ ]* /$(date -d $weekday +%Y-%m-%d) /" 59 echo "$line" | sed "s/^[ ]*[^ ]* /$(date -d $weekday +%Y-%m-%d) /"
62done <"$sdepdata/weekly" >> "$tempfile" 60done <"SDEPDATA/weekly" >> "$tempfile"
63sed "s/^[ ]*/$(date +%Y-%m-)/" <"$sdepdata/daily" >> "$tempfile" 61sed "s/^[ ]*/$(date +%Y-%m-)/" <"SDEPDATA/daily" >> "$tempfile"
64 62
65sdep -w "$w" -f "$from" -t "$to" <"$tempfile" 63sdep -w "$w" -f "$from" -t "$to" <"$tempfile"
66 64

Generated with cgit - Back to sebastiano.tronto.net