summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorChristian Krinitsin <mail@krinitsin.com>2025-12-14 22:13:33 +0100
committerChristian Krinitsin <mail@krinitsin.com>2025-12-14 22:13:33 +0100
commite3130a8c9713c1dcf5d3711bdb08375f1f52c958 (patch)
treecfec7db1805bffc00d4f297c08fa4763040e590e
parent72902d98f8ad965011d02c57db881a322008fd99 (diff)
downloaddotfiles-e3130a8c9713c1dcf5d3711bdb08375f1f52c958.tar.gz
dotfiles-e3130a8c9713c1dcf5d3711bdb08375f1f52c958.zip
Add zeit config and waybar module
-rwxr-xr-xbin/zeitbin0 -> 18071736 bytes
-rwxr-xr-xbin/zeit-waybar-dmenu53
-rw-r--r--waybar/.config/waybar/config9
3 files changed, 61 insertions, 1 deletions
diff --git a/bin/zeit b/bin/zeit
new file mode 100755
index 0000000..b06d2b1
--- /dev/null
+++ b/bin/zeit
Binary files differdiff --git a/bin/zeit-waybar-dmenu b/bin/zeit-waybar-dmenu
new file mode 100755
index 0000000..e075146
--- /dev/null
+++ b/bin/zeit-waybar-dmenu
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+ZEIT_BIN=zeit
+DMENU_PROGRAM=dmenu
+
+as_hms() {
+  local nanoseconds=$1
+
+  seconds=$((nanoseconds / 1000000000))
+
+  hours=$((seconds / 3600))
+
+  minutes=$(((seconds % 3600) / 60))
+
+  seconds_r=$((seconds % 60))
+
+  printf "%02d:%02d:%02d" "$hours" "$minutes" "$seconds_r"
+}
+
+statusOut=$($ZEIT_BIN --format json)
+for key in $(echo "$statusOut" | jq -r 'keys[]'); do
+  value=$(echo "$statusOut" | jq -r ".${key}")
+  export "$key"="$value"
+done
+
+if [[ "$1" == "click" ]]; then
+  if [[ "$is_running" == "true" ]]; then
+    $ZEIT_BIN end
+    exit 0
+  fi
+
+  selection=$(zeit projects -f json |
+    jq -r '.[] | .sid as $parent_sid | .tasks? // [] | .[] | "\($parent_sid)/\(.sid)"' |
+    $DMENU_PROGRAM)
+
+  task=$(printf "%s" "$selection" | cut -d '/' -f2)
+  project=$(printf "%s" "$selection" | cut -d '/' -f1)
+
+  if [[ "$task" == "" ]] || [[ "$project" == "" ]]; then
+    exit 1
+  fi
+
+  $ZEIT_BIN start -p "$project" -t "$task"
+  exit 0
+fi
+
+if [[ "$is_running" == "true" ]]; then
+  timer_fmt=$(as_hms "$timer")
+  printf "{\"text\": \"%s<span color='#ffffff'>/</span>%s <span color='#ffffff'>%s</span>\", \"class\": \"custom-zeit\", \"alt\": \"%s\" }\n" "$project_sid" "$task_sid" "$timer_fmt" "$status"
+else
+  total=$(as_hms $(zeit stats --format json today at 00:00 am | jq -r '."*"."*"."*"'))
+  printf "{\"text\": \"%s\", \"class\": \"custom-zeit\", \"alt\": \"%s\" }\n" "$total" "$status"
+fi
diff --git a/waybar/.config/waybar/config b/waybar/.config/waybar/config
index dafbb9a..77f7318 100644
--- a/waybar/.config/waybar/config
+++ b/waybar/.config/waybar/config
@@ -4,7 +4,7 @@
     "height": 20, // Waybar height (to be removed for auto height)
     "spacing": 2, // Gaps between modules (4px)
     "modules-left": ["sway/workspaces", "sway/mode", "sway/scratchpad", "custom/media"],
-    "modules-right": ["custom/pomodoro", "pulseaudio", "network", "cpu", "memory", "disk", "temperature", "battery", "clock", "tray"],
+    "modules-right": ["custom/zeit", "custom/pomodoro", "pulseaudio", "network", "cpu", "memory", "disk", "temperature", "battery", "clock", "tray"],
 
     "keyboard-state": {
         "numlock": true,
@@ -162,6 +162,13 @@
         "exec": "waybar-module-pomodoro",
         "on-click": "waybar-module-pomodoro toggle",
         "on-click-right": "waybar-module-pomodoro reset",
+    },
+    "custom/zeit": {
+      "format": "{} ",
+      "return-type": "json",
+      "exec": "zeit-waybar-dmenu",
+      "on-click": "zeit-waybar-dmenu click",
+      "interval": 1
     }
 }