Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to export list of projects/tasks? #1

Closed
khughitt opened this issue Oct 20, 2020 · 3 comments
Closed

Add method to export list of projects/tasks? #1

khughitt opened this issue Oct 20, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@khughitt
Copy link
Contributor

Not sure if this is something you think would be worth including in the scope of zeit but, in thinking about how one might go about creating a polybar interface to zeit, one of the first things that would have to be solved is to determine a list of projects/tasks.

It seems like this could probably be parsed from the output of zeit stats, or from a dump from zeit export, but it would be nice if there were a way to do something along the lines of zeit export proj to print a JSON array mapping from projects -> tasks (along with any color assignments or other metadata associated with projects/tasks..)

To give you an idea of what I'm thinking w.r.t to a polybar app, it could look something like:

  1. == z [start]==
  2. clicking "start" shows proj/task selection
    • most likely use fzf to select project -> task
    • drop-downs also a possibility..
    • options displayed using assigned project colors
  3. == tracking [proj | task] 00:01 ==
  4. clicking again will either pause / prompt the user to stop tracking.

Either way, really cool project.

Thanks for taking the time to put this together and share it!

Cheers,
Keith

@mrusme mrusme self-assigned this Oct 20, 2020
@mrusme mrusme added the enhancement New feature or request label Oct 20, 2020
@mrusme
Copy link
Owner

mrusme commented Oct 20, 2020

Thank you for the suggestion @khughitt! I began implementing this in 2d7dbdd

It's now possible to pass --only-projects-and-tasks to the zeit list command in order to only get a structured overview of projects and tasks:

▲ Projects/@mrusme/zeit zeit list --only-projects-and-tasks
 ◆ Project1
 └── Development
 └── Planning, Alignment & Communication
 ◆ Project2
 └── Consultancy
 ◆ Project3
 └── Planning, Alignment & Communication
 └── Engineering
 ◆ Project4
 └── Development
 ◆ zeit
 └── Development
 ▲ Projects/@mrusme/zeit                                     

It can also be combined with the other flags (apart from --total), in order to limit the projects/tasks to a specific time-frame (--since/--until) or in case you're only interested in getting the tasks of a specific project (--project).

The project colours aren't displayed yet, though. Would it be suitable to simply print the projects in their respective colours (using the terminal escape codes) or would you need to get the actual hex color string per project? For the latter I'd suggest that I finish the zeit project command to actually display project settings when no flag is passed so that you could query each project's individual hex code through that.

As for the command flow, I think what you'd be doing would be:

zeit list --only-projects-and-tasks  # to show the projects/tasks and let the user pick one
zeit track -p project -t task        # to start tracking
zeit tracking                        # every minute, to show the currently running tracker
zeit finish                          # to stop/pause tracking

As there is no "pause" (since it's basically stopping one entry and creating a new one, because entries can't have time gaps in them, only start and end times) this is pretty much the whole flow. Finish would accept an optional --notes argument, in case the user would like to enter a few things at the end.

FYI: The project/task selector would need a way to let the user manually enter a new project/task. In zeit these can be created by simply tracking a new activity with them. There's no explicit new project/new task command.

@khughitt
Copy link
Contributor Author

khughitt commented Feb 5, 2021

@mrusme Greetings!

Apologies for the very late follow-up! I finally made some time to start using zeit in earnest though, and so far, it has been great!

I came across a couple minor bugs, and have some other feature requests I thought I'd share, but I'm going to post those in separate issues to make it easier to track.

I'm also going to close this issue since it is no longer an issue. Thanks for taking the time to add the --only-projects-and-tasks functionality!

In case anyone is interested, here is a simple polybar module for listing the currently tracked project:

zeit-status.sh

#!/usr/bin/env sh
# Polybar zeit status indicator

# get zeit status and strip ansi colors
tracking=`zeit tracking | sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g'`

if ! echo $tracking | grep -q "not running"; then
    # get current activity and time spent
    proj=`echo $tracking | grep --color='never' -o "on [a-z0-9\-]* for" | sed "s/on //" | sed "s/ for//"`
    time_spent=`echo ${tracking##* }`

    echo "$proj ($time_spent)"
else
    echo "⏳not tracking"
fi

And then in your polybar config:

[module/zeit]
type = custom/script
exec = /path/to/zeit-status.sh
interval = 15
format-prefix = " "
format-underline = ${xrdb:color4}

The prefix character uses the siji font.

Cheers,
Keith

@khughitt khughitt closed this as completed Feb 5, 2021
@mrusme
Copy link
Owner

mrusme commented Feb 5, 2021

Hey there, thank you for following up and sharing the polybar script! I've linked it from a new Integrations section in the README.md. :-)

Feel free to open up issues and feature requests!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants