1
0
Fork 0

Improve Calendar handling

This commit is contained in:
Malte Brandy 2022-02-20 16:58:23 +01:00
parent 433cb7f560
commit fde1205c8b
6 changed files with 45 additions and 8 deletions

View file

@ -57,7 +57,7 @@ let
let
all = extra ++ on-my-machines ++ [
(import ./roles/firefox.nix "http://localhost:7000")
(makeAutostart "kassandra2")
(makeAutostart "planning")
(makeAutostart "unlock-ssh")
./roles/beets.nix
./roles/daily-driver-programs.nix

View file

@ -5,7 +5,7 @@ let
statusScript = pkgs.writeHaskellScript
{
name = "status-script";
bins = [ pkgs.notmuch pkgs.coreutils pkgs.git pkgs.playerctl ];
bins = [ pkgs.notmuch pkgs.coreutils pkgs.git pkgs.playerctl pkgs.khal ];
imports = [
"Control.Exception"
"System.Directory"
@ -26,6 +26,7 @@ let
main = do
playing <- Text.intercalate " " . fmap decodeUtf8 . filter (/= "") <$> mapM tryCmd [playerctl "status", playerctl "metadata" "title", playerctl "metadata" "artist"]
appointments <- Text.intercalate "; ". lines . decodeUtf8 <$> (tryCmd $ khal ["list", "-a", "Standard", "-a", "Planung", "-a", "Uni", "-a", "Maltaire", "now", "2h", "-df", ""])
mode <- getMode
unread <- notmuch "count" "folder:hera/Inbox" "tag:unread" |> captureTrim
inbox <- notmuch "count" "folder:hera/Inbox" |> captureTrim
@ -33,8 +34,8 @@ let
dirs <- listDirectory "/home/maralorn/git"
dirty <- fmap toText <$> filterM (isDirty . ("/home/maralorn/git/"<>)) dirs
unpushed <- fmap toText <$> filterM (isUnpushed . ("/home/maralorn/git/"<>)) dirs
say . Text.intercalate " " $
[playing, show mode] ++
say . Text.intercalate " | " $
[appointments,playing, show mode] ++
memptyIfFalse ((unread /= "0") && mode >= Orga) (one [i|Unread: #{unread}|]) ++
memptyIfFalse ((inbox /= "0") && mode == Leisure) (one [i|Inbox: #{inbox}|]) ++
memptyIfFalse ((codeMails /= "0") && mode == Code) (one [i|Code: #{codeMails}|]) ++

View file

@ -5,8 +5,8 @@ in
[
{
Orga = [
{ Kassandra = fork "kassandra2"; }
{ Kalendar = "ikhal -d Serien"; }
{ Kassandra = fork "planning"; }
{ Kalendar = "calendar"; }
{ Habitica = fork "firefox https://habitica.com"; }
{ Tasks = "tasksh"; }
{ Meditate = "meditate"; }

View file

@ -1,10 +1,45 @@
{ pkgs, ... }:
let
calendars = pkgs.privateValue [ ] "calendars";
plans = pkgs.privateValue
{
"workDay" = "pass";
"weekend" = "pass";
}
"plans";
planning = pkgs.writeShellScriptBin "planning" ''
create-plans; kassandra2
'';
ui = pkgs.writeShellScriptBin "calendar" ''
create-plans; ikhal -d Serien
'';
createPlans = pkgs.writeHaskellScript
{
name = "create-plans";
bins = [ pkgs.khal pkgs.vdirsyncer ];
imports = [
"Data.Time"
];
} ''
main = do
today <- localDay . zonedTimeToLocalTime <$> getZonedTime
[0..7] & fmap (`addDays` today) & mapM_ \day -> do
planned <- khal ["list", "-a", "Planung", show day, "06:00", "24h", "--notstarted"] |> captureTrim
when (planned == "No events") $ do
say $ "Creating events for " <> show day
if (dayOfWeek day `elem` [Saturday, Sunday]) then do
${plans.weekend}
else do
${plans.workDay}
'';
in
{
home.packages = [ pkgs.khal ];
home.packages = [ pkgs.khal createPlans planning ui ];
xdg.configFile."khal/config".text = ''
[locale]
dateformat = "%Y-%m-%d"
datetimeformat = "%Y-%m-%d %H:%M"
timeformat = "%H:%M"
[default]
default_calendar = Standard
[calendars]

View file

@ -64,6 +64,7 @@ in
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE BlockArguments #-}
import Shh
import Relude

@ -1 +1 @@
Subproject commit 5913f4e0157f966ffd09494b9fbe72149e34e610
Subproject commit 4d24f7ecc3d92f8cca743da3709d594fb0e84544