diff --git a/scripts/waybar/time_warrior_waybar.py b/scripts/waybar/time_warrior_waybar.py new file mode 100755 index 0000000..0cf83b4 --- /dev/null +++ b/scripts/waybar/time_warrior_waybar.py @@ -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()) diff --git a/waybar/config b/waybar/config index 3c0f3fd..2f00756 100644 --- a/waybar/config +++ b/waybar/config @@ -20,7 +20,6 @@ "battery", "custom/wakatime", "clock", - "idle_inhibitor", "custom/logout" ], "wlr/taskbar": { @@ -194,26 +193,12 @@ "custom/os": { "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": { - "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": "󰅱 {}", "return-type": "json", "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": { "format": "󰠜", "on-click": "wlogout",