From af9eaa8186b5c482639b617ab6dc04444dfbdf30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20N=C3=A1jera?= Date: Mon, 28 Sep 2020 22:11:03 +0200 Subject: Setup calendar by symlink --- .calendars.conf | 32 --------------------------- .gitignore | 1 - calendars.conf | 32 +++++++++++++++++++++++++++ install.scm | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 33 deletions(-) delete mode 100644 .calendars.conf create mode 100644 calendars.conf create mode 100755 install.scm diff --git a/.calendars.conf b/.calendars.conf deleted file mode 100644 index 7876df9..0000000 --- a/.calendars.conf +++ /dev/null @@ -1,32 +0,0 @@ -[DEFAULT] -agenda_outfile=~/org/caldav.org -contacts_outfile=~/org/contacts.org -ahead=90 -back=28 - - -[contacts] -outfile=~/org/contacts.org -user = oscar -passwordstore=CS_storage/cloud.oscarnajera.com:https -url=https://cloud.oscarnajera.com/remote.php/dav/addressbooks/users/oscar/{}?export -addressbooks=contacts - -[work] -user = on -passwordstore=Correos/mx.tribe29.com -url=https://mx.tribe29.com/home/on/{} -calendars = Calendar -#Entwickler%20Kalender - -[personal] -user = oscar -passwordstore=CS_storage/cloud.oscarnajera.com:https -url=https://cloud.oscarnajera.com/remote.php/dav/calendars/oscar/{}?export -calendars = habitual personal - -[15x4] -user=oscar.najera@15x4.org -passwordstore=google/oscar.najera@15x4.org -url=https://calendar.google.com/calendar/ical/{}/basic.ics -calendars = oscar.najera%%4015x4.org/private-ea73a6fd65fea99f4bbee2dd9ad1429c 15x4.org_v0gk3fde3m3aqg5v161hioaku0%%40group.calendar.google.com/private-d10be3f5decd67c58b99ab339ef76a2c \ No newline at end of file diff --git a/.gitignore b/.gitignore index ee640c5..b3ebf9e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -.* Documents/ Nextcloud/ dev/ diff --git a/calendars.conf b/calendars.conf new file mode 100644 index 0000000..7876df9 --- /dev/null +++ b/calendars.conf @@ -0,0 +1,32 @@ +[DEFAULT] +agenda_outfile=~/org/caldav.org +contacts_outfile=~/org/contacts.org +ahead=90 +back=28 + + +[contacts] +outfile=~/org/contacts.org +user = oscar +passwordstore=CS_storage/cloud.oscarnajera.com:https +url=https://cloud.oscarnajera.com/remote.php/dav/addressbooks/users/oscar/{}?export +addressbooks=contacts + +[work] +user = on +passwordstore=Correos/mx.tribe29.com +url=https://mx.tribe29.com/home/on/{} +calendars = Calendar +#Entwickler%20Kalender + +[personal] +user = oscar +passwordstore=CS_storage/cloud.oscarnajera.com:https +url=https://cloud.oscarnajera.com/remote.php/dav/calendars/oscar/{}?export +calendars = habitual personal + +[15x4] +user=oscar.najera@15x4.org +passwordstore=google/oscar.najera@15x4.org +url=https://calendar.google.com/calendar/ical/{}/basic.ics +calendars = oscar.najera%%4015x4.org/private-ea73a6fd65fea99f4bbee2dd9ad1429c 15x4.org_v0gk3fde3m3aqg5v161hioaku0%%40group.calendar.google.com/private-d10be3f5decd67c58b99ab339ef76a2c \ No newline at end of file diff --git a/install.scm b/install.scm new file mode 100755 index 0000000..1151500 --- /dev/null +++ b/install.scm @@ -0,0 +1,67 @@ +#!/usr/bin/guile \ +-e main -s +!# +(use-modules (ice-9 popen) + (logging logger) + (logging port-log) + (oop goops) + (term ansi-color)) + + +(define (ansi-color-log-formatter lvl time str) + (let ((color (cond ((eq? lvl 'CRITICAL) 'RED) + ((eq? lvl 'WARN) 'YELLOW) + ((eq? lvl 'OK) 'GREEN)))) + (string-append + (strftime "%F %H:%M:%S" (localtime time)) + (colorize-string + (string-append " (" (symbol->string lvl) "): ") color 'BOLD) + str "\n"))) + + +(define (setup-logging) + (let ((lgr (make )) + (std (make + #:port (current-output-port) + #:formatter ansi-color-log-formatter))) + + ;; add the handler to our logger + (add-handler! lgr std) + + ;; make this the application's default logger + (set-default-logger! lgr) + (open-log! lgr))) + +(define (shutdown-logging) + (flush-log) ;; since no args, it uses the default + (close-log!) ;; since no args, it uses the default + (set-default-logger! #f)) + + +(define (expand-file f) + ;; https://irreal.org/blog/?p=83 + (cond ((char=? (string-ref f 0) #\/) f) + ((string=? (substring f 0 2) "~/") + (let ((prefix (passwd:dir (getpwuid (geteuid))))) + (string-append prefix (substring f 1 (string-length f))))) + ((char=? (string-ref f 0) #\~) + (let* ((user-end (string-index f #\/)) + (user (substring f 1 user-end)) + (prefix (passwd:dir (getpwnam user)))) + (string-append prefix (substring f user-end (string-length f))))) + (else (string-append (getcwd) "/" f)))) + +(define (clean-file full-dest) + (when (file-exists? full-dest) + (log-msg 'WARN (string-append "Deleting previous file: " full-dest)) + (delete-file full-dest)) + full-dest) + +(define (main args) + (setup-logging) + (log-msg 'INFO "symlink PIM") + + (symlink (expand-file "calendars.conf") (clean-file (expand-file "~/.calendars.conf"))) + (log-msg 'OK "symlink agenda") + + (shutdown-logging)) -- cgit v1.2.3