From 0df4a0bc2ef5ac23e55c63ab08a45eda8918cf83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=9E=E3=83=AA=E3=82=A6=E3=82=B9?= Date: Mon, 5 Jul 2021 19:44:32 -0500 Subject: [PATCH] Implemented waybar/wofi integration script --- README.md | 2 ++ extras/zeit-waybar-wofi.sh | 47 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100755 extras/zeit-waybar-wofi.sh diff --git a/README.md b/README.md index 822884b..ef31db8 100644 --- a/README.md +++ b/README.md @@ -278,6 +278,8 @@ zeit export --format tyme --project "my project" --since "2020-04-01T15:04:05+07 Here are a few integrations and extensions built by myself as well as other people that make use of `zeit`: +- [`zeit-waybar-wofi.sh`](https://github.com/mrusme/zeit/blob/main/extras/zeit-waybar-wofi.sh), + a script for integrating `zeit` into waybar, using wofi - [`zeit.1m.sh`](https://github.com/mrusme/zeit/blob/main/extras/zeit.1m.sh), an [`xbar`](https://github.com/matryer/xbar) plugin for `zeit` - [`zeit-status.sh`](https://github.com/khughitt/dotfiles/blob/master/polybar/scripts/zeit-status.sh), diff --git a/extras/zeit-waybar-wofi.sh b/extras/zeit-waybar-wofi.sh new file mode 100755 index 0000000..97478d7 --- /dev/null +++ b/extras/zeit-waybar-wofi.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# +# Example waybar configuration: +# +# "custom/zeit": { +# "format": "{}", +# "exec": "zeit-waybar-wofi.sh", +# "on-click": "zeit-waybar-wofi.sh click", +# "interval": 10 +# }, +# + +ZEIT_BIN=zeit + +tracking=$($ZEIT_BIN tracking --no-colors) + +if [[ "$1" == "click" ]] +then + if echo "$tracking" | grep -q '^ ▶ tracking' + then + $ZEIT_BIN finish + exit 0 + fi + + selection=$($ZEIT_BIN list \ + --only-projects-and-tasks \ + --append-project-id-to-task \ + | wofi \ + --dmenu \ + --sort-order default \ + --cache-file /dev/null\ + ) + + task=$(echo $selection | pcregrep -io1 '└── (.+) \[.+') + project=$(echo $selection | pcregrep -io1 '.+\[(.+)\]') + + if [[ "$task" == "" ]] || [[ "$project" == "" ]] + then + exit 1 + fi + + $ZEIT_BIN track -p "$project" -t "$task" + exit 0 +fi + +echo -n $tracking +