-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add experimental terminal version for status line
- Loading branch information
1 parent
40bb46f
commit 1164cc0
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Example of i3-status-rust config: | ||
|
||
''' | ||
[[block]] | ||
block = "custom" | ||
command = "easyPomo/terminal/easypomo_term.py" | ||
interval = 1 | ||
|
||
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!.venv/bin/python | ||
|
||
import requests | ||
import json | ||
import time | ||
from datetime import timedelta | ||
|
||
def get_online_step(): | ||
url = 'https://easypomo.duckdns.org:443/json-endpoint' | ||
|
||
try: | ||
response = requests.get(url) | ||
response.raise_for_status() # Raise an HTTPError for bad responses | ||
data = response.json() | ||
|
||
pomo_count = data["pomoCount"] | ||
curr_time = data["currTime"] | ||
is_resting = data["isResting"] | ||
is_long_resting = data["isLongResting"] | ||
|
||
# Format currTime as MM:SS | ||
formatted_time = str(timedelta(seconds=curr_time)).lstrip("0:") # Removing leading zeros and the hour field | ||
# Check if less than 1 minute, then format as 00:SS | ||
if curr_time < 60: | ||
formatted_time = f"00:{formatted_time}" | ||
|
||
status_icon = "⌛" if not is_resting else "☕" if is_long_resting else "☕" | ||
|
||
print(f'{pomo_count+1}{status_icon} {formatted_time}') | ||
|
||
except requests.exceptions.RequestException as e: | ||
print(f'Request failed. Exception: {e}') | ||
|
||
#while True: | ||
# get_online_step() | ||
# time.sleep(0.5) | ||
get_online_step() |