Skip to content

Commit

Permalink
Changed uptime WITHDAYS to FORMATTED
Browse files Browse the repository at this point in the history
  • Loading branch information
mathoudebine committed Jul 21, 2024
1 parent 8af2e13 commit 8cf7150
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 15 deletions.
24 changes: 11 additions & 13 deletions library/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ class SystemUptime:
def stats():
if HW_SENSORS == "STATIC":
# For static sensors, use predefined uptime
uptimesec = "4294036"
uptimesec = 4294036
else:
uptimesec = int(uptime())

Expand All @@ -768,18 +768,16 @@ def stats():
systemuptime_theme_data = config.THEME_DATA['STATS']['UPTIME']

systemuptime_sec_theme_data = systemuptime_theme_data['SECONDS']['TEXT']
if systemuptime_sec_theme_data and systemuptime_sec_theme_data['SHOW']:
display_themed_value(
theme_data=systemuptime_sec_theme_data,
value=uptimesec
)

systemuptime_withdays_theme_data = systemuptime_theme_data['WITHDAYS']['TEXT']
if systemuptime_withdays_theme_data and systemuptime_withdays_theme_data['SHOW']:
display_themed_value(
theme_data=systemuptime_withdays_theme_data,
value=uptimeformatted
)
display_themed_value(
theme_data=systemuptime_sec_theme_data,
value=uptimesec
)

systemuptime_formatted_theme_data = systemuptime_theme_data['FORMATTED']['TEXT']
display_themed_value(
theme_data=systemuptime_formatted_theme_data,
value=uptimeformatted
)


class Custom:
Expand Down
4 changes: 2 additions & 2 deletions res/themes/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,11 @@ STATS:
TEXT:
SHOW: False
UPTIME:
INTERVAL: 100
INTERVAL: 0
SECONDS:
TEXT:
SHOW: False
WITHDAYS:
FORMATTED:
TEXT:
SHOW: False
CUSTOM:
Expand Down
39 changes: 39 additions & 0 deletions res/themes/theme_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1427,3 +1427,42 @@ STATS:
BACKGROUND_IMAGE: background.png
ALIGN: left # left / center / right
ANCHOR: lt # Check https://pillow.readthedocs.io/en/stable/handbook/text-anchors.html
UPTIME:
# For seconds display, it is recommended not to change the interval: keep to 1
INTERVAL: 1
SECONDS: # Uptime as seconds
TEXT:
SHOW: FALSE
X: 192
Y: 261
# Text sensors may vary in size and create "ghosting" effects where old value stay displayed under the new one.
# To avoid this use one of these 2 methods (or both):
# - either use a monospaced font (fonts with "mono" in name, see res/fonts/ for available fonts)
# - or force a static width/height for the text field. Be sure to have enough space for the longest value that can be displayed (e.g. "100%" for a percentage)
# WIDTH: 200 # Uncomment to force a static width
# HEIGHT: 50 # Uncomment to force static height
FONT: jetbrains-mono/JetBrainsMono-Bold.ttf
FONT_SIZE: 23
FONT_COLOR: 255, 255, 255
# BACKGROUND_COLOR: 132, 154, 165
BACKGROUND_IMAGE: background.png
ALIGN: left # left / center / right
ANCHOR: lt # Check https://pillow.readthedocs.io/en/stable/handbook/text-anchors.html
FORMATTED: # Uptime as formatted string with days e.g. "49 days, 16:47:16"
TEXT:
SHOW: FALSE
X: 192
Y: 261
# Text sensors may vary in size and create "ghosting" effects where old value stay displayed under the new one.
# To avoid this use one of these 2 methods (or both):
# - either use a monospaced font (fonts with "mono" in name, see res/fonts/ for available fonts)
# - or force a static width/height for the text field. Be sure to have enough space for the longest value that can be displayed (e.g. "100%" for a percentage)
# WIDTH: 200 # Uncomment to force a static width
# HEIGHT: 50 # Uncomment to force static height
FONT: jetbrains-mono/JetBrainsMono-Bold.ttf
FONT_SIZE: 23
FONT_COLOR: 255, 255, 255
# BACKGROUND_COLOR: 132, 154, 165
BACKGROUND_IMAGE: background.png
ALIGN: left # left / center / right
ANCHOR: lt # Check https://pillow.readthedocs.io/en/stable/handbook/text-anchors.html

0 comments on commit 8cf7150

Please sign in to comment.