aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Waishnav <waishnavdeore@gmail.com>2022-07-12 16:17:39 +0530
committerLibravatar Waishnav <waishnavdeore@gmail.com>2022-07-12 16:17:39 +0530
commit27365936982c5e3fcab51f5d0f93ff4feea687ef (patch)
tree0047bff5bbd5193d7d86b2ac49c7df3fde6cad22
parent80db09037a96b7887c65f48e62d9ba3bc8cb5ba8 (diff)
downloadshopno-os-log-sync-27365936982c5e3fcab51f5d0f93ff4feea687ef.tar.gz
shopno-os-log-sync-27365936982c5e3fcab51f5d0f93ff4feea687ef.zip
Removing EWMH module as a dependancy (causing more RAM consumption over the time)
-rw-r--r--README.md9
-rwxr-xr-xsrc/Watcher/analysis.py4
-rwxr-xr-xsrc/Watcher/get_windows.py28
3 files changed, 18 insertions, 23 deletions
diff --git a/README.md b/README.md
index 414d7b4..5197f23 100644
--- a/README.md
+++ b/README.md
@@ -20,13 +20,10 @@ Day Summary | Week Summary
Funfact: You might be thinking how can someone has 14 hrs of screen time in a single day, Well ! short ans is AFK-feature is not implemented yet... Most of the time I left my laptop as it is so it also counts that AFK time as Screen-time
## Installation
-* Note: Install [```xprintidle```](https://github.com/g0hl1n/xprintidle) on your system ( its the only dependancy )
-* First, Install the following dependancy
-```xprintidle```
-```EWMH python module```
+* Note: Install [```xprintidle```](https://github.com/g0hl1n/xprintidle) and [```xdotool```](https://github.com/jordansissel/xdotool) on your system ( its the only dependancy )
+* First, Install the following dependancy ```xprintidle``` and ```xdotool```
```bash
-$ sudo [package-manager] install xprintidle
-$ pip install ewmh
+$ sudo [package-manager] install xprintidle xdotool
```
* Second, Clone this repository and cd into it-
```bash
diff --git a/src/Watcher/analysis.py b/src/Watcher/analysis.py
index 7a96b60..87acda3 100755
--- a/src/Watcher/analysis.py
+++ b/src/Watcher/analysis.py
@@ -39,6 +39,10 @@ def final_report(window_opened, time_spent):
#print(report)
if "User-logged-in" in report.keys():
report.pop("User-logged-in")
+ if "AFK" in report.keys():
+ report.pop("AFK")
+ if "Unknown" in report.keys():
+ report.pop("Unknown")
# sort report dictonary in decreasing order of Usages
sorted_values = []
for x,y in report.items():
diff --git a/src/Watcher/get_windows.py b/src/Watcher/get_windows.py
index 8cfbc70..65e8a93 100755
--- a/src/Watcher/get_windows.py
+++ b/src/Watcher/get_windows.py
@@ -1,33 +1,27 @@
import os
import time
from afk import get_afk_status
-from ewmh import EWMH
# get title name of app that user working on
def active_window_title():
- try:
- win = EWMH().getActiveWindow()
- active_window_title = win.get_wm_name()
- except AttributeError:
- active_window_title = "unknown"
+ active_window_title = os.popen("""xprop -id $(xprop -root _NET_ACTIVE_WINDOW | cut -d ' ' -f 5) WM_NAME | sed -nr 's/.*= "(.*)"$/\1/p'""").read()[:-1]
+ if "XGetWindowProperty[_NET_ACTIVE_WINDOW] failed" in active_window_title:
+ active_window_title = ""
+ if "\n" in active_window_title:
+ active_window_title = "Unknown"
active_window_title = active_window_title.capitalize()
return active_window_title
# get classname of app that user working on
def active_window():
- try:
- win = EWMH().getActiveWindow()
- active_window = win.get_wm_class()[1]
- except AttributeError:
- active_window = "unknown"
-
- if len(active_window) > 20:
- active_window = "unknown"
- elif "\n" in active_window:
- active_window = "unknown"
- active_window = active_window.capitalize()
+ active_window = os.popen("xprop -id $(xdotool getactivewindow) | grep CLASS | awk '{print $4}'").read()[:-1].replace('''"''', "")
+ if "XGetWindowProperty[_NET_ACTIVE_WINDOW] failed" in active_window:
+ active_window = ""
+ if "\n" in active_window:
+ active_window = "Unknown"
# check whether user is using nvim or vim
+ active_window = active_window.capitalize()
aw_title = active_window_title()
terminals = ["Kitty", "Alacritty", "Terminator", "Tilda", "Guake", "Yakuake", "Roxterm", "Eterm", "Rxvt", "Xterm", "Tilix", "Lxterminal", "Konsole", "St", "Gnome-terminal", "Xfce4-terminal", "Terminology", "Extraterm"]
if active_window in terminals: