summary refs log tree commit diff stats
path: root/bin
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 /bin
parent72902d98f8ad965011d02c57db881a322008fd99 (diff)
downloaddotfiles-e3130a8c9713c1dcf5d3711bdb08375f1f52c958.tar.gz
dotfiles-e3130a8c9713c1dcf5d3711bdb08375f1f52c958.zip
Add zeit config and waybar module
Diffstat (limited to 'bin')
-rwxr-xr-xbin/zeitbin0 -> 18071736 bytes
-rwxr-xr-xbin/zeit-waybar-dmenu53
2 files changed, 53 insertions, 0 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