clean up and org
This commit is contained in:
10
dmapp/dm.sh
Normal file
10
dmapp/dm.sh
Normal file
@@ -0,0 +1,10 @@
|
||||
sudo systemctl start mongod.service
|
||||
. /home/mariano/wdir/venv/dm/bin/activate
|
||||
cd /home/mariano/wdir/def/deskmeter
|
||||
nohup python3 dmmain.py >dm.out 2>dm.err &
|
||||
|
||||
cd /home/mariano/wdir/def/deskmeter/dmapp
|
||||
nohup python3 run.py >dm.out 2>dm.err &
|
||||
|
||||
cd ~
|
||||
exit
|
||||
@@ -1,14 +0,0 @@
|
||||
class ActiveDesktop:
|
||||
|
||||
def __init__(self, desktops, unlabeled = "Other"):
|
||||
self.desktops = desktops
|
||||
|
||||
|
||||
def active_workspace():
|
||||
|
||||
workspaces = subprocess.check_output(["wmctrl", "-d"]) \
|
||||
.decode("utf-8").strip("\n").split("\n")
|
||||
|
||||
for workspace in workspaces:
|
||||
if workspace[3] == "*":
|
||||
return int(workspace[0])
|
||||
86
dmapp/dmcore/main.py
Normal file
86
dmapp/dmcore/main.py
Normal file
@@ -0,0 +1,86 @@
|
||||
import datetime
|
||||
import os
|
||||
import subprocess
|
||||
import time
|
||||
from pprint import pprint
|
||||
|
||||
import task
|
||||
from pymongo import MongoClient
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
client = MongoClient()
|
||||
|
||||
|
||||
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"])
|
||||
.decode("utf-8")
|
||||
.strip("\n")
|
||||
.split("\n")
|
||||
)
|
||||
|
||||
for workspace in workspaces:
|
||||
if workspace[3] == "*":
|
||||
return int(workspace[0])
|
||||
|
||||
|
||||
def desktop(workspace_index):
|
||||
try:
|
||||
return desktops[workspace_index]
|
||||
except IndexError:
|
||||
return unlabeled
|
||||
|
||||
|
||||
current_workspace = active_workspace()
|
||||
current_task = task.current()
|
||||
last_switch_time = now()
|
||||
|
||||
switch = {
|
||||
"workspace": desktop(current_workspace),
|
||||
"date": now(),
|
||||
"delta": 0,
|
||||
"task": current_task,
|
||||
}
|
||||
|
||||
switches.insert_one(switch)
|
||||
|
||||
while True:
|
||||
current_task = task.current()
|
||||
current_workspace = active_workspace()
|
||||
|
||||
last_doc = switches.find_one(sort=[("_id", -1)])
|
||||
if (
|
||||
last_doc["workspace"] == desktop(current_workspace)
|
||||
and last_doc["task"] == current_task
|
||||
):
|
||||
delta = round((now() - last_switch_time).total_seconds())
|
||||
switches.update_one(
|
||||
{"_id": last_doc["_id"]}, {"$set": {"delta": delta, "task": current_task}}
|
||||
)
|
||||
else:
|
||||
current_workspace = active_workspace()
|
||||
switch = {
|
||||
"workspace": desktop(current_workspace),
|
||||
"date": now(),
|
||||
"delta": 0,
|
||||
"task": current_task,
|
||||
}
|
||||
switches.insert_one(switch)
|
||||
last_switch_time = now()
|
||||
|
||||
time.sleep(2)
|
||||
161
dmapp/dmcore/sample_task_file
Normal file
161
dmapp/dmcore/sample_task_file
Normal file
@@ -0,0 +1,161 @@
|
||||
work
|
||||
default | ffbe198e *
|
||||
vhs | c851ce32
|
||||
dlt | b4378ac5
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
???
|
||||
|
||||
think
|
||||
lectura
|
||||
guitarra
|
||||
design patterns
|
||||
data structures
|
||||
politica
|
||||
|
||||
cursos
|
||||
code
|
||||
microsaas
|
||||
soft
|
||||
oratoria
|
||||
memoria |1dc8a7c2
|
||||
|
||||
video
|
||||
blender
|
||||
motion graphics
|
||||
unreal
|
||||
houdini
|
||||
nuke
|
||||
|
||||
plan
|
||||
entrevistas
|
||||
rapid fort |00799f93
|
||||
calestino |f58a2919
|
||||
celara |64898a2f
|
||||
|
||||
work
|
||||
boat
|
||||
spots |5fc751ec
|
||||
dani: si mejor extraer dl y sfr manual
|
||||
revisar ami -|
|
||||
publisher
|
||||
mapear codigo |462682ac
|
||||
credentials
|
||||
completar lista |d602b2d8
|
||||
simulations
|
||||
reunion caro
|
||||
OCIO class |f6f23db6
|
||||
|
||||
generar cache
|
||||
dani: tracker / entity
|
||||
graph?
|
||||
averiguar opciones |9d794a0b
|
||||
|
||||
personal
|
||||
deskmeter |ec01a5a8
|
||||
autoweekcal
|
||||
frontend apps
|
||||
qt / wxwidgets / c
|
||||
android remote control
|
||||
react native
|
||||
|
||||
meetdrop
|
||||
qtbase
|
||||
100ms
|
||||
|
||||
portfolio
|
||||
subtitulos
|
||||
|
||||
encript
|
||||
|
||||
video
|
||||
script canon linux
|
||||
audio
|
||||
compresor obs
|
||||
configurar hydrogen
|
||||
|
||||
|
||||
musica
|
||||
piano
|
||||
liebestraum
|
||||
arpegios and scales
|
||||
AbM
|
||||
course exercises
|
||||
encoding
|
||||
storing
|
||||
retrieve
|
||||
write chords
|
||||
sonata
|
||||
arpegios and scales
|
||||
C#m
|
||||
course exercises
|
||||
encoding
|
||||
storing
|
||||
retrieve
|
||||
write chords
|
||||
|
||||
guitar
|
||||
surf riders
|
||||
|
||||
dance
|
||||
elegir videos
|
||||
|
||||
|
||||
plan
|
||||
hablar con kimda para actualizar sombrero
|
||||
habilitar obsidian j
|
||||
|
||||
work
|
||||
config aws cli for boat/mcrn
|
||||
just start/stop ecs
|
||||
api
|
||||
spoty
|
||||
|
||||
think on the interview
|
||||
design patterns
|
||||
algos and ds
|
||||
|
||||
|
||||
maxi |9f551a34
|
||||
alinear month/date
|
||||
scroll, recenter (today)
|
||||
align sum
|
||||
show 3M before / 9M after
|
||||
|
||||
|
||||
dlt
|
||||
whatsapp |f217b606
|
||||
seo and analytics |7422cfe3
|
||||
dockerizar |acbd9f7f
|
||||
landing page |9719a462
|
||||
documento |c6b0af75
|
||||
carga |be7e496f
|
||||
update look |51c5b6d6
|
||||
instagram ads |76e7b629
|
||||
wrap up |92014034
|
||||
23
dmapp/dmcore/task.py
Normal file
23
dmapp/dmcore/task.py
Normal file
@@ -0,0 +1,23 @@
|
||||
task_file = "/home/mariano/LETRAS/org/task/main"
|
||||
|
||||
|
||||
def extract(line):
|
||||
if line.rstrip().endswith("*"):
|
||||
pipe_index = line.find("|")
|
||||
if pipe_index != -1 and len(line) > pipe_index + 8:
|
||||
value = line[pipe_index + 1 : pipe_index + 9]
|
||||
return value
|
||||
return None
|
||||
|
||||
|
||||
def read_and_extract(file_path):
|
||||
with open(file_path, "r") as file:
|
||||
for line in file:
|
||||
value = extract(line)
|
||||
if value:
|
||||
return value
|
||||
return None
|
||||
|
||||
|
||||
def current():
|
||||
return read_and_extract(task_file)
|
||||
Reference in New Issue
Block a user