scripts: remove double-symlinked waybar scripts
This commit is contained in:
parent
dc872cbcb3
commit
1deb2b803d
2 changed files with 0 additions and 111 deletions
|
@ -1,54 +0,0 @@
|
|||
#! /usr/local/bin/python3
|
||||
|
||||
import subprocess
|
||||
import json
|
||||
|
||||
|
||||
def invoke_shell(proc):
|
||||
try:
|
||||
result = subprocess.run(
|
||||
proc,
|
||||
shell=True,
|
||||
check=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
)
|
||||
return result.stdout.strip()
|
||||
except subprocess.CalledProcessError as e:
|
||||
return e.stderr.strip()
|
||||
|
||||
|
||||
def timer_active() -> bool:
|
||||
status = invoke_shell("timew get dom.active")
|
||||
if status == "1":
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def generate_tooltip():
|
||||
tooltip = invoke_shell("timew summary :week")
|
||||
return tooltip
|
||||
|
||||
|
||||
def main():
|
||||
output = {}
|
||||
try:
|
||||
if timer_active():
|
||||
output["text"] = "Timer active"
|
||||
output["class"] = "active"
|
||||
else:
|
||||
output["text"] = "Timer inactive"
|
||||
output["class"] = "inactive"
|
||||
except Exception as e:
|
||||
output["text"] = "Error"
|
||||
|
||||
print(json.dumps(output))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
print(timer_active())
|
|
@ -1,57 +0,0 @@
|
|||
#! /usr/local/bin/python3
|
||||
import requests
|
||||
import os
|
||||
import json
|
||||
import textwrap
|
||||
|
||||
WAKATIME_API_KEY = os.getenv("WAKATIME_API_KEY")
|
||||
WAKATIME_ENDPOINT = "https://wakatime.com/api/v1/users/current/status_bar/today"
|
||||
|
||||
|
||||
def get_data(url):
|
||||
response = requests.get(url)
|
||||
if response.status_code == 200:
|
||||
return response.json()
|
||||
else:
|
||||
raise Exception(
|
||||
f"Failed to fetch data from API. Status code: {response.status_code}"
|
||||
)
|
||||
|
||||
|
||||
def generate_tooltip(time, languages, projects):
|
||||
return textwrap.dedent(
|
||||
f"""\
|
||||
Time coding: {time}
|
||||
Languages: {languages}
|
||||
Projects: {projects}"""
|
||||
)
|
||||
|
||||
|
||||
def format_metric(metrics):
|
||||
return ", ".join(
|
||||
[f'{metric["name"]} ({metric["percent"]}%)' for metric in metrics[:3]]
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
output = {}
|
||||
try:
|
||||
data = get_data(WAKATIME_ENDPOINT + "?api_key=" + WAKATIME_API_KEY)
|
||||
digital_time = data["data"]["grand_total"]["digital"]
|
||||
human_time = data["data"]["grand_total"]["text"]
|
||||
langs = data["data"]["languages"]
|
||||
projects = data["data"]["projects"]
|
||||
tooltip = generate_tooltip(
|
||||
human_time, format_metric(langs), format_metric(projects)
|
||||
)
|
||||
output["text"] = digital_time
|
||||
output["tooltip"] = tooltip
|
||||
|
||||
except Exception as e:
|
||||
output["text"] = "Error"
|
||||
|
||||
print(json.dumps(output))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Add table
Reference in a new issue