waybar: add Time Warrior integration
This commit is contained in:
parent
0bd4029844
commit
79f7e8729b
2 changed files with 55 additions and 16 deletions
54
scripts/waybar/time_warrior_waybar.py
Executable file
54
scripts/waybar/time_warrior_waybar.py
Executable file
|
@ -0,0 +1,54 @@
|
||||||
|
#! /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"
|
||||||
|
output["class"] = "active"
|
||||||
|
else:
|
||||||
|
output["text"] = " Timer"
|
||||||
|
output["class"] = "inactive"
|
||||||
|
except Exception as e:
|
||||||
|
output["text"] = "Error"
|
||||||
|
|
||||||
|
print(json.dumps(output))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
||||||
|
|
||||||
|
print(timer_active())
|
|
@ -20,7 +20,6 @@
|
||||||
"battery",
|
"battery",
|
||||||
"custom/wakatime",
|
"custom/wakatime",
|
||||||
"clock",
|
"clock",
|
||||||
"idle_inhibitor",
|
|
||||||
"custom/logout"
|
"custom/logout"
|
||||||
],
|
],
|
||||||
"wlr/taskbar": {
|
"wlr/taskbar": {
|
||||||
|
@ -194,26 +193,12 @@
|
||||||
"custom/os": {
|
"custom/os": {
|
||||||
"format": " archbish"
|
"format": " archbish"
|
||||||
},
|
},
|
||||||
"custom/spotify": {
|
|
||||||
"exec": "/usr/bin/python3 $HOME/.config/waybar/resources/custom_modules/mediaplayer.py --player spotify",
|
|
||||||
"format": "{} ",
|
|
||||||
"return-type": "json",
|
|
||||||
"on-click": "playerctl play-pause",
|
|
||||||
"on-scroll-up": "playerctl next",
|
|
||||||
"on-scroll-down": "playerctl previous"
|
|
||||||
},
|
|
||||||
"custom/wakatime": {
|
"custom/wakatime": {
|
||||||
"exec": "source $HOME/dotfiles/.env && python3 $HOME/.config/waybar/resources/custom_modules/wakatime.py",
|
"exec": "source $HOME/dotfiles/.env && python3 $HOME/.config/waybar/resources/custom_modules/wakatime_waybar.py",
|
||||||
"format": " {}",
|
"format": " {}",
|
||||||
"return-type": "json",
|
"return-type": "json",
|
||||||
"interval": 600
|
"interval": 600
|
||||||
},
|
},
|
||||||
"custom/toggl": {
|
|
||||||
"exec": "source $HOME/dotfiles/.env && python3 $HOME/.config/waybar/resources/custom_modules/toggl_controller.py",
|
|
||||||
"format": "{}",
|
|
||||||
"return-type": "json",
|
|
||||||
"interval": 600
|
|
||||||
},
|
|
||||||
"custom/logout": {
|
"custom/logout": {
|
||||||
"format": "",
|
"format": "",
|
||||||
"on-click": "wlogout",
|
"on-click": "wlogout",
|
||||||
|
|
Loading…
Add table
Reference in a new issue