Advertisement
Heroes_Killer

Toggl hours widget

Jun 4th, 2020
1,151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.54 KB | None | 0 0
  1. workspace_id=1234567
  2. API_TOKEN=bflmpsvz007
  3.  
  4. year=`date +%Y`
  5. month=`date +%m`
  6. url="https://toggl.com/reports/api/v2/summary?workspace_id=${workspace_id}&since=${year}-${month}-01&user_agent=toggl_hours"
  7.  
  8. toggled_ms=`curl -s -u ${API_TOKEN}:api_token -X GET "${url}" | json_pp | grep total_grand | tr -dc '0-9'`
  9.  
  10. month_hours=$(case $month in 05) echo 152 ;; 06) echo 176 ;; 07) echo 176 ;; 08) echo 168 ;; 09) echo 168 ;; 10) echo 168 ;; 11) echo 160 ;; 12) echo 168 ;; esac)
  11.  
  12. result=`echo $(($toggled_ms / 3600000)) / $month_hours`
  13.  
  14. echo $result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement