polybar / polybar-scripts

This is a community project. We write and collect scripts for polybar!
The Unlicense
2.46k stars 338 forks source link

Wakatime status #378

Closed thomasabishop closed 2 years ago

thomasabishop commented 2 years ago

Hi I've made a clean pull request for this script. It takes account of previous feedback regarding unsatisfactory security options.

x70b1 commented 2 years ago

Very cool, I will check it later!

thomasabishop commented 2 years ago

Renamed dir, script and readme.

x70b1 commented 2 years ago

I made some changes:

I removed some obvious and/or little interesting lines. The TOKEN var should contain the pure token only. In that way you can't change the script by mistake and is easier to understand.

Some additional things:

thomasabishop commented 2 years ago

Thank you for your feedback.

  1. I think the time should be discretionary. It's for the user to decide. Most users will understand how to adapt a module declaration to suit their specific needs. I appreciate this may not chime with your ethos but for my part I would want to be less prescriptive.
  2. Handling curl errors is difficult for me. If you think this is necessary I would welcome your assistance.
  3. Again I think this should be discretionary. Not everyone uses font awesome. Maybe let's not have an icon at all and instead use # as contributors to other scripts have done.
x70b1 commented 2 years ago

My idea would something like this:

#!/bin/sh

TOKEN=""

wakatime_today="$(curl -sf --header "Authorization: Basic $(echo "$TOKEN" | base64)" https://wakatime.com/api/v1/users/current/status_bar/today)"

if [ -n "$wakatime_today" ]; then
    echo "#1 $(wakatime_today | jq -r '.data.grand_total.text')"
else
    echo "#2"
fi

Can you test it?

thomasabishop commented 2 years ago

Thanks for your help. Your formulation generated the following error: ./info-wakatime.sh: line 14: wakatime_today: command not found

I have adapted it to resolve this error whilst maintaining the conditional and hash outputs. I have tested and works fine.

x70b1 commented 2 years ago

Welcome to your first script here :sunglasses:

thomasabishop commented 2 years ago

Great! Thank you for your help with this ☺️