about summary refs log tree commit diff
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2021-10-04 18:16:01 +0200
committerProfpatsch <mail@profpatsch.de>2021-10-26 20:44:13 +0200
commitc8045aa11f4d9a56f72955f1189dbea3f46deef7 (patch)
tree20e000b3cccbd179391c26bbb63bc99d28104d1d
parent6c53c759b156be978462c4b82d83952cc850a694 (diff)
xdg-open: add ics files to the calendar & sync to webdav
Sync the calendar every 15 minutes with a user service, and add ics
file support to xdg-open.
-rw-r--r--machines/profpatsch/shiki.nix18
-rw-r--r--pkgs/profpatsch/xdg-open/config.dhall5
-rw-r--r--pkgs/profpatsch/xdg-open/default.nix22
-rw-r--r--pkgs/profpatsch/xdg-open/types.dhall1
4 files changed, 44 insertions, 2 deletions
diff --git a/machines/profpatsch/shiki.nix b/machines/profpatsch/shiki.nix
index 2cabac2e..939d7ea0 100644
--- a/machines/profpatsch/shiki.nix
+++ b/machines/profpatsch/shiki.nix
@@ -449,7 +449,7 @@ in {
           description = "run mbsync job every 15 minutes";
           wantedBy = [ "timers.target" ];
           timerConfig = {
-            OnStartupSec="10s";
+            OnStartupSec="30s";
             OnUnitActiveSec ="15m";
           };
         };
@@ -461,6 +461,22 @@ in {
           };
         };
 
+        services.calendar-sync = {
+          description = "syncronize private calendars";
+          serviceConfig = {
+            Restart = "no";
+            ExecStart = "${pkgs.vdirsyncer}/bin/vdirsyncer -vdebug sync";
+          };
+        };
+        timers.calendar-sync = {
+          description = "sync calendars every 15 minutes";
+          wantedBy = [ "timers.target" ];
+          timerConfig = {
+            OnStartupSec="30s";
+            OnUnitActiveSec ="15m";
+          };
+        };
+
         # I could fight against udev or I could just run this script every ten seconds
         timers.set-keyboard-speed = {
           description = "set the keyboard speed every 10 seconds in case a keyboard was plugged in";
diff --git a/pkgs/profpatsch/xdg-open/config.dhall b/pkgs/profpatsch/xdg-open/config.dhall
index dac815f9..6e5bacfe 100644
--- a/pkgs/profpatsch/xdg-open/config.dhall
+++ b/pkgs/profpatsch/xdg-open/config.dhall
@@ -53,6 +53,10 @@ in  λ(pkgs : { package : Text, binary : Text } → Executable) →
                     }
                   , xml =
                     { mime = [ "text", "xml" ], cmd = special.open-in-browser }
+                  , ical =
+                    { mime = [ "text", "calendar" ]
+                    , cmd = special.add-to-calendar
+                    }
                   , any =
                     { mime = [ "text", "any" ], cmd = special.open-in-editor }
                   }
@@ -116,6 +120,7 @@ in  λ(pkgs : { package : Text, binary : Text } → Executable) →
             , mime.text.gemini
             , mime.text.gopher
             , mime.text.xml
+            , mime.text.ical
             , mime.text.any
             , mime.mail-address
             , mime.torrent
diff --git a/pkgs/profpatsch/xdg-open/default.nix b/pkgs/profpatsch/xdg-open/default.nix
index 97418958..30ff275e 100644
--- a/pkgs/profpatsch/xdg-open/default.nix
+++ b/pkgs/profpatsch/xdg-open/default.nix
@@ -26,6 +26,7 @@ let
       // getBins pkgs.firefox [ "firefox" ]
       // getBins pkgs.lilyterm-git [ "lilyterm" ]
       // getBins pkgs.ranger [ "ranger" ]
+      // getBins pkgs.khal [ "khal" ]
       ;
 
   notify = msg: {
@@ -54,7 +55,24 @@ let
     args = file: [ file ];
   };
 
-
+  # TODO: interactive adding? Don’t want to add all ics files to my calendar
+  add-to-calendar = {
+    exe = writeExecline "add-to-calendar" { readNArgs = 1; } [
+      "if" [
+        bins.khal
+          "import"
+          "--batch"
+          # the private calendar is called calendar
+          "--include-calendar" "calendar"
+          "$1"
+      ]
+      "systemctl" "--user"
+        "start"
+        # defined as a user service (TODO: config variable?)
+        "calendar-sync"
+    ];
+    args = file: [ file ];
+  };
 
   open-in-browser = {
     exe = bins.firefox;
@@ -120,6 +138,7 @@ let
       , open-in-browser : Command
       , open-in-editor : Command
       , notify : Text -> Command
+      , add-to-calendar : Command
       }
     )
 → Text
@@ -150,6 +169,7 @@ let
         dmenu-list-binaries-and-exec
         exec-in-terminal-emulator
         notify
+        add-to-calendar
         ;
     };
 
diff --git a/pkgs/profpatsch/xdg-open/types.dhall b/pkgs/profpatsch/xdg-open/types.dhall
index e878ce86..9b0456f1 100644
--- a/pkgs/profpatsch/xdg-open/types.dhall
+++ b/pkgs/profpatsch/xdg-open/types.dhall
@@ -20,6 +20,7 @@ let Special =
       , exec-in-terminal-emulator : ∀(args : Command) → Command
       , dmenu-list-binaries-and-exec : Command
       , notify : ∀(message : Text) → Command
+      , add-to-calendar : Command
       }
 
 let