From 6f20e7f76a73c1214a499cb3db35f0f66360c9af Mon Sep 17 00:00:00 2001 From: traxys Date: Tue, 26 Mar 2024 18:23:11 +0100 Subject: [PATCH] personal-gui,thinkpad-nixos: Introduce khal --- hostconfig/thinkpad-nixos/hm.nix | 97 ++++++++++++++++++++------------ personal-gui/wm/sway.nix | 10 ++++ personal-gui/wm/waybar-khal.py | 29 ++++++++++ personal-gui/wm/waybar.css | 6 ++ 4 files changed, 106 insertions(+), 36 deletions(-) create mode 100755 personal-gui/wm/waybar-khal.py diff --git a/hostconfig/thinkpad-nixos/hm.nix b/hostconfig/thinkpad-nixos/hm.nix index 75a9ab6..a6e5294 100644 --- a/hostconfig/thinkpad-nixos/hm.nix +++ b/hostconfig/thinkpad-nixos/hm.nix @@ -319,43 +319,68 @@ in { }; }; - accounts.email = { - accounts.work = rec { - address = "quentin.boyer@***REMOVED***"; - imap = { - host = "localhost"; - port = 1143; - tls.enable = false; - }; - mbsync = { - enable = true; - create = "maildir"; - subFolders = "Verbatim"; - extraConfig.account = { - AuthMechs = "LOGIN"; - Timeout = 60; - }; - }; - passwordCommand = "echo foobar"; - notmuch.enable = true; - msmtp = { - enable = true; - extraConfig.auth = "plain"; - }; - primary = true; - realName = "Quentin Boyer"; - userName = address; - smtp = { - host = "localhost"; - port = 1025; - tls.enable = false; - }; + services.vdirsyncer.enable = true; + programs.vdirsyncer.enable = true; + programs.khal.enable = true; - aerc = { - enable = true; - extraAccounts = { - check-mail-cmd = "notmuch new"; - check-mail-timeout = "60s"; + programs.zsh.shellAliases = { + "khal-today" = "khal list today today -f '{start-time}-{end-time}: {title}'"; + }; + + accounts = { + calendar = { + basePath = ".calendar"; + accounts.work = { + primary = true; + remote = { + url = "http://localhost:1080/users/${config.workAddr}/calendar/"; + type = "caldav"; + userName = "${config.workAddr}"; + passwordCommand = ["echo" "foobar"]; + }; + khal.enable = true; + vdirsyncer.enable = true; + }; + }; + + email = { + accounts.work = rec { + address = "quentin.boyer@***REMOVED***"; + imap = { + host = "localhost"; + port = 1143; + tls.enable = false; + }; + mbsync = { + enable = true; + create = "maildir"; + subFolders = "Verbatim"; + extraConfig.account = { + AuthMechs = "LOGIN"; + Timeout = 60; + }; + }; + passwordCommand = "echo foobar"; + notmuch.enable = true; + msmtp = { + enable = true; + extraConfig.auth = "plain"; + }; + primary = true; + realName = "Quentin Boyer"; + userName = address; + smtp = { + host = "localhost"; + port = 1025; + tls.enable = false; + }; + + aerc = { + enable = true; + extraAccounts = { + check-mail-cmd = "notmuch new"; + check-mail-timeout = "60s"; + }; }; }; }; diff --git a/personal-gui/wm/sway.nix b/personal-gui/wm/sway.nix index 468f2dc..651fecc 100644 --- a/personal-gui/wm/sway.nix +++ b/personal-gui/wm/sway.nix @@ -80,6 +80,16 @@ in { is = ""; ie = ""; in { + "custom/khal" = { + format = "{}"; + tooltip = true; + interval = 300; + format-icons = { + default = ""; + }; + exec = "${lib.getExe pkgs.python3} ${./waybar-khal.py}"; + return-type = "json"; + }; "sway/workspaces" = { persistent_workspaces = { "" = []; diff --git a/personal-gui/wm/waybar-khal.py b/personal-gui/wm/waybar-khal.py new file mode 100755 index 0000000..24d02e0 --- /dev/null +++ b/personal-gui/wm/waybar-khal.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +import json +import subprocess +from html import escape + +data = {} + +output = subprocess.check_output( + 'khal list now 7days --format "{start-end-time-style} {title}"', shell=True +).decode("utf-8") +lines = output.split("\n") + +new_lines = [] + +for line in lines: + line = escape(line) + if len(line) and line[0].isalpha(): + line = "\n" + line + "" + new_lines.append(line) + +output = "\n".join(new_lines).strip() + +if "Today" in output: + data["text"] = " " + output.split("\n")[1] +else: + data["text"] = "" +data["tooltip"] = output + +print(json.dumps(data)) diff --git a/personal-gui/wm/waybar.css b/personal-gui/wm/waybar.css index 93c3e69..61b9583 100644 --- a/personal-gui/wm/waybar.css +++ b/personal-gui/wm/waybar.css @@ -139,6 +139,12 @@ label:focus { color: #000000; } +#custom-khal { + padding-bottom: 0; + border-bottom: 3px solid #209050; + border-top: 2px solid transparent; +} + #memory { background-color: #9b59b6; }