Enhanced xbar plugin

This commit is contained in:
マリウス 2021-03-17 09:59:32 -05:00
parent 16b5625e78
commit 5aec5ed3e5
No known key found for this signature in database
GPG key ID: C228EF0A530AF06F
2 changed files with 107 additions and 4 deletions

View file

@ -275,7 +275,13 @@ zeit export --format tyme --project "my project" --since "2020-04-01T15:04:05+07
## Integrations
Here are a few integrations and extensions built by other people that make use of `zeit`:
Here are a few integrations and extensions built by myself as well as other
people that make use of `zeit`:
- [`zeit-status.sh`](https://github.com/khughitt/dotfiles/blob/master/polybar/scripts/zeit-status.sh), a [Polybar](https://github.com/polybar/polybar) integration for `zeit` by [@khughitt](https://github.com/khughitt) (see [#1](https://github.com/mrusme/zeit/issues/1))
- [`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),
a [Polybar](https://github.com/polybar/polybar) integration for `zeit` by
[@khughitt](https://github.com/khughitt)
(see [#1](https://github.com/mrusme/zeit/issues/1))
- your link here, feel free to PR! :-)

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# <xbar.title>zeit</xbar.title>
# <xbar.author>Marius</xbar.author>
@ -16,5 +16,102 @@
# by Marius (marius@xn--gckvb8fzb.com)
#
echo $($ZEIT_BIN tracking)
PLACEHOLDER_NO_PROJECT='[no project]'
PLACEHOLDER_NO_TASK='[no task]'
if [[ -z "$ZEIT_BIN" ]]
then
ZEIT_BIN=$1
fi
if [[ -z "$ZEIT_DB" ]]
then
export ZEIT_DB=$2
fi
case $3 in
"track")
flag_p=$4
flag_t=$5
$ZEIT_BIN --no-colors finish
if [[ "$flag_p" = "$PLACEHOLDER_NO_PROJECT" ]]
then
flag_p=''
fi
if [[ "$flag_t" = "$PLACEHOLDER_NO_TASK" ]]
then
flag_t=''
fi
$ZEIT_BIN --no-colors track -p "$flag_p" -t "$flag_t"
# exit 0
;;
"finish")
$ZEIT_BIN --no-colors finish
# exit 0
;;
esac
trackingProject=''
trackingTask=''
trackingDuration=''
tracking=$($ZEIT_BIN --no-colors tracking)
if [[ "${tracking:3:8}" = "tracking" ]]
then
if [[ "${tracking:12:8}" = "task for" ]]
then
trackingProject=$PLACEHOLDER_NO_PROJECT
trackingTask=$PLACEHOLDER_NO_TASK
trackingDuration=$(echo $tracking | sed -E 's/.*tracking task for (.+)/\1/g')
else
trackingProject=$(echo $tracking | sed -E 's/.*tracking (.+) on (.+) for (.+)/\2/g')
trackingTask=$(echo $tracking | sed -E 's/.*tracking (.+) on (.+) for (.+)/\1/g')
trackingDuration=$(echo $tracking | sed -E 's/.*tracking (.+) on (.+) for (.+)/\3/g')
fi
tracking=$trackingDuration
fi
echo $tracking
echo '---'
echo 'Projects'
project=''
$ZEIT_BIN --no-colors list --only-projects-and-tasks | while read line
do
if [[ $line = \◆* ]]
then
project=$(echo $line | sed 's/◆[[:space:]]\{0,1\}//g')
if [[ "$project" = "" ]]
then
project=$PLACEHOLDER_NO_PROJECT
fi
if [[ "$project" = "$trackingProject" ]]
then
echo "-- ▶ $project"
else
echo "-- $project"
fi
elif [[ $line = \└\─\─* ]]
then
task=$(echo $line | sed 's/└──[[:space:]]\{0,1\}//g')
if [[ "$task" = "" ]]
then
task=$PLACEHOLDER_NO_TASK
fi
if [[ "$project" = "$trackingProject" && "$task" = "$trackingTask" ]]
then
echo "---- ▶ $task | shell='$0' param1='$ZEIT_BIN' param2='$ZEIT_DB' param3=finish param4='$project' param5='$task' terminal=false refresh=true"
else
echo "---- $task | shell='$0' param1='$ZEIT_BIN' param2='$ZEIT_DB' param3=track param4='$project' param5='$task' terminal=false refresh=true"
fi
fi
#echo $line | sed 's/◆/--/g' | sed 's/└── \(.*\)/---- \1 \| shell="$0" param1=track param2="\1" terminal=false/g'; done
done
exit