eww clock no longer spawns a new process every 0.5 seconds
This commit is contained in:
parent
362f4c1d0b
commit
c2f6e81215
@ -1,6 +1,6 @@
|
||||
;; -*-lisp-*-
|
||||
(defpoll clock--data :interval "500ms"
|
||||
`date +'{"hour": "%H", "minute": "%M", "second": "%S", "year": "%Y", "day": "%d", "month": "%m", "dow": "%A", "month_name": "%B", "unix": %s}'`)
|
||||
(deflisten clock--data :initial "{}"
|
||||
`~/.config/eww/scripts/date.py`)
|
||||
|
||||
(defvar clock--show "clock")
|
||||
|
||||
|
||||
24
.config/eww/scripts/date.py
Executable file
24
.config/eww/scripts/date.py
Executable file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""A simple Python script to output the current date and time as a JSON object string every 0.5 seconds.
|
||||
|
||||
Used instead of the `date` command in order to avoid spawning a new process every 0.5 seconds.
|
||||
"""
|
||||
|
||||
import datetime
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
def get_date():
|
||||
"""Return the current date as a JSON object string."""
|
||||
return datetime.datetime.now().strftime(
|
||||
'{"hour": "%H", "minute": "%M", "second": "%S", "day": "%d", "month": "%m", "year": "%Y", "dow": "%w","month_name": "%B", "unix": %s}'
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
while True:
|
||||
print(get_date())
|
||||
sys.stdout.flush()
|
||||
time.sleep(0.5)
|
||||
Loading…
x
Reference in New Issue
Block a user