A tool that puts your program usage in a CSV. Works only on niri.
| .gitignore | Initial commit | |
| analyze.lua | make comment better | |
| monitor.lua | make comment better | |
| README.md | Initial commit | |
| stylua.toml | Initial commit | |
Warning!!!
This is a project made specifically for me, to monitor my usage of programs. It will likely not work properly on your machine.
I am putting this out to the world in the hopes it will be useful for someone.
okoleko
A tool that puts your program usage in a CSV. Works only on niri.
The csv format is date,program_name,time_in_seconds
Requirements
- Some lua knowledge, you will need to modify the source code.
- Niri window manager, you may modify the code to work on hyprland too if you want to
notify-sendworkingluajit- a desire to run this
Usage
- Git clone the project
- Look into
monitor.luaANDanalyze.lua, changepath = "<whatever>"to the path where you want the csv - Create an empty file in that path (so if path was
/db.csv, you would create an empty file named that) - Give it a test run, run with
luajit monitor.luaand check the csv after some time - Customise in
monitor.luathegive_namefunction to things relevant to you. (Returned value must not contain commas or anything weird, you can get the app id by runningniri msg windows) - Deploy!! Inside
~/.config/niri/config.kdladdspawn-sh-at-startup "luajit </path/to/monitor.lua>"
The monitor.lua is the only file from this project that you need.
What to do with the data?
You can display the data for the current day by running analyze.lua. You can also modify analyze.lua to do some actual analysis (like the difference between yesterday's usage and today's), but that is an excercise for the reader.
Anything fun?
You can plot the data with matplotlib:
# The base of this code was LLM generated, sorry... i know.... :(
# But no other code in the repository has been impacted by LLMs, it would take away the fun
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("db.csv", header=None, parse_dates=[0])
plt.figure(figsize=(10, 5))
for app, g in df.groupby(1).filter(lambda x: x[2].mean() > 2000 and x[2].sum() > 10000).groupby(1):
g = g.sort_values(0)
plt.plot(g[0], g[2], marker="o", linewidth=1, label=app)
plt.xlabel("Date")
plt.ylabel("Time (seconds)")
plt.title("Program usage time over time")
plt.legend(title="Program")
plt.show()
License
BSD Zero Clause License
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Have fun!