Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tobi-wan-kenobi committed Sep 15, 2022
0 parents commit 7c32443
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions bin/scusage
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python3

import i3ipc
import tabulate

def run():
i3 = i3ipc.Connection()

counts = {}
def on_binding(_, event):
binding = event.binding
sym = f"'{binding.input_code}'"
if binding.symbol:
sym = binding.symbol
b = f"{'+'.join(binding.event_state_mask)}+{sym}: {binding.command}"
counts[b] = counts.get(b, 0) + 1

i3.on(i3ipc.Event.BINDING, on_binding)

i3.main()

print_result(counts)

def bar(amount, max):
width = 30
print(f"{width} {amount} {max}")
return "="*int((amount*width)/max)

def print_result(counts):
data = []
print("")
total = sum(counts.values())
max = None
for k, v in sorted(counts.items(), key=lambda x: x[1], reverse=True):
if not max:
max = v
data.append([k, f"{v} ({v/total*100:.0f}%)", bar(v, max)])
print(tabulate.tabulate(data, headers=["binding", "count", ""]))

if __name__ == "__main__":
run()

0 comments on commit 7c32443

Please sign in to comment.