moved config. saved a workable state
This commit is contained in:
@@ -4,29 +4,21 @@ import subprocess
|
||||
import time
|
||||
from pprint import pprint
|
||||
|
||||
import task
|
||||
import state
|
||||
from pymongo import MongoClient
|
||||
import task
|
||||
from config import logger, switches
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
client = MongoClient()
|
||||
desktops = ("Plan", "Think", "Work", "Other", "Away", "Work", "Work")
|
||||
work_desktops = {2: "default", 5: "dlt", 6: "vhs"}
|
||||
|
||||
unlabeled = "Away"
|
||||
|
||||
|
||||
def now():
|
||||
return datetime.datetime.now(ZoneInfo("America/Argentina/Buenos_Aires"))
|
||||
|
||||
|
||||
db = client.deskmeter
|
||||
switches = db.switch
|
||||
dailies = db.daily
|
||||
|
||||
|
||||
desktops = ("Plan", "Think", "Work", "Other", "Away", "Work", "Work")
|
||||
|
||||
|
||||
unlabeled = "Away"
|
||||
|
||||
|
||||
def active_workspace():
|
||||
workspaces = (
|
||||
subprocess.check_output(["wmctrl", "-d"])
|
||||
@@ -38,8 +30,6 @@ def active_workspace():
|
||||
for workspace in workspaces:
|
||||
if workspace[3] == "*":
|
||||
return int(workspace[0])
|
||||
return None
|
||||
return None
|
||||
|
||||
|
||||
def desktop(workspace_index):
|
||||
@@ -49,8 +39,12 @@ def desktop(workspace_index):
|
||||
return unlabeled
|
||||
|
||||
|
||||
task.read_and_extract(None)
|
||||
state.init_work_state(work_desktops)
|
||||
|
||||
|
||||
current_workspace = active_workspace()
|
||||
current_task = state.get_current_task()
|
||||
current_task = state.retrieve("current").get("task")
|
||||
last_switch_time = now()
|
||||
|
||||
switch = {
|
||||
@@ -63,13 +57,18 @@ switch = {
|
||||
switches.insert_one(switch)
|
||||
|
||||
while True:
|
||||
current_task = state.get_current_task()
|
||||
current_task = state.retrieve("current").get("task")
|
||||
current_workspace = active_workspace()
|
||||
state.update_current_workspace(current_workspace)
|
||||
|
||||
|
||||
state.save("current", workspace=current_workspace)
|
||||
|
||||
last_doc = switches.find_one(sort=[("_id", -1)])
|
||||
|
||||
# work workflow
|
||||
|
||||
if current_workspace in work_desktops.keys():
|
||||
pass
|
||||
|
||||
# regular flow
|
||||
if (
|
||||
last_doc["workspace"] == desktop(current_workspace)
|
||||
and last_doc["task"] == current_task
|
||||
|
||||
Reference in New Issue
Block a user