matryer / matryer/xbar-plugins

earnings.1m.py.rtf:

Open
#2,121 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
2.6k
Forks
1.1k
Avg merge
9d 15h
Merged PRs (30d)
1

Description

fao @ -
{\rtf1\ansi\ansicpg1252\cocoartf2761
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\margl1440\margr1440\vieww11520\viewh8400\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0

\f0\fs24 \cf0 #!/usr/bin/env python3\
# Earnings Tracker\
# v1.1\
# You\
# Tracks live work earnings at $25/hr + $0.10 per task\
\
import os, time, json, sys\
\
# File to store data\
DATA_FILE = os.path.expanduser("~/.xbar_earnings.json")\
\
# Settings\
HOURLY_RATE = 25.0\
TASK_RATE = 0.10\
\
# Load saved data\
if os.path.exists(DATA_FILE):\
with open(DATA_FILE, "r") as f:\
data = json.load(f)\
else:\
data = \{"start_time": None, "tasks": 0\}\
\
def save():\
with open(DATA_FILE, "w") as f:\
json.dump(data, f)\
\
def elapsed_hours():\
if data["start_time"] is None:\
return 0\
return (time.time() - data["start_time"]) / 3600\
\
def earnings():\
return elapsed_hours() * HOURLY_RATE + data["tasks"] * TASK_RATE\
\
def format_time(seconds):\
m, s = divmod(int(seconds), 60)\
h, m = divmod(m, 60)\
return f"\{h\}h \{m\}m"\
\
# Main Display (menu bar text)\
elapsed_seconds = (time.time() - data["start_time"]) if data["start_time"] else 0\
print(f"\uc0\u55357 \u56501 $\{earnings():.2f\} (\{format_time(elapsed_seconds)\}, \{data['tasks']\} tasks)")\
\
# Dropdown menu\
print("---")\
print("\uc0\u9654 \u65039 Start | bash=/usr/bin/env python3 param1="+__file__+" param2=start terminal=false refresh=true")\
print("\uc0\u9208 \u65039 Stop | bash=/usr/bin/env python3 param1="+__file__+" param2=stop terminal=false refresh=true")\
print("\uc0\u10133 Add Task | bash=/usr/bin/env python3 param1="+__file__+" param2=task terminal=false refresh=true")\
print("\uc0\u55357 \u56580 Reset | bash=/usr/bin/env python3 param1="+__file__+" param2=reset terminal=false refresh=true")\
\
# Handle actions\
if len(sys.argv) > 1:\
action = sys.argv[1]\
if action == "start":\
data["start_time"] = time.time()\
elif action == "stop":\
data["start_time"] = None\
elif action == "task":\
data["tasks"] += 1\
elif action == "reset":\
data = \{"start_time": None, "tasks": 0\}\
save()}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the submitted earnings.1m.py.rtf body and the repository's expectations for plugin files. Confirm whether this RTF-wrapped Python script is an acceptable xbar plugin and what changes or validation are required; done means the submission follows the repository's plugin format and its intended actions work.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.