Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a save file #1

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Mod4+s: mark swapee; focus right; swap container with mark swapee; unmark swapee
Mod4+8: workspace "8: " 1 (3%) ====
Mod4+9: workspace "9: " 1 (3%) ====
Mod4+0: workspace "10: " 1 (3%) ====
File saved to /home/tux/.config/scusage.txt
```

The idea is that this tool helps you identify which shortcuts you use most often,
Expand Down
9 changes: 8 additions & 1 deletion bin/scusage
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3

import os
import i3ipc
import tabulate

Expand All @@ -26,6 +27,7 @@ def bar(amount, max):
return "="*int((amount*width)/max)

def print_result(counts):
outpath = f"{os.getenv('XDG_CONFIG_HOME')}/scusage.txt"
data = []
print("")
total = sum(counts.values())
Expand All @@ -34,7 +36,12 @@ def print_result(counts):
if not max:
max = v
data.append([k, f"{v} ({v/total*100:.0f}%)", bar(v, max)])
print(tabulate.tabulate(data, headers=["shortcut", "count", ""]))

result = tabulate.tabulate(data, headers=["shortcut", "count", ""])
outfile = open(outpath, "a")
outfile.write(f"\n{result}\n")
outfile.close()
print(f"{result}\r\nFile saved to {outpath}\r\n")

if __name__ == "__main__":
run()